From gitlab at gitlab.haskell.org Thu Sep 1 03:18:51 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 31 Aug 2022 23:18:51 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 7 commits: Hadrian: disable shared libs for JS target Message-ID: <6310249ba9d6a_2f2e5816becc681044615@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: c3a9c0e8 by Sylvain Henry at 2022-09-01T02:19:22+02:00 Hadrian: disable shared libs for JS target - - - - - 6a9726e3 by Sylvain Henry at 2022-09-01T02:20:37+02:00 Support -ddump-stg-final with the JS backend - - - - - d6da694a by Sylvain Henry at 2022-09-01T02:21:33+02:00 Add ticky_ghc0 flavour transformer to ticky stage1 - - - - - 0f98be8c by Sylvain Henry at 2022-09-01T03:40:58+02:00 Don't read object file when -ddump-js isn't passed - - - - - 5340cd7b by Sylvain Henry at 2022-09-01T04:06:19+02:00 Object: remove dead code + renaming - - - - - 5a2f2223 by Sylvain Henry at 2022-09-01T04:24:25+02:00 Object: replace SymbolTableR with Dictionary - - - - - b24014b8 by Sylvain Henry at 2022-09-01T04:48:50+02:00 Object: refactoring - - - - - 5 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Object.hs - hadrian/src/Flavour.hs - hadrian/src/Oracles/Flag.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1753,6 +1753,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do stub_c_exists = Nothing foreign_fps = [] + putDumpFileMaybe logger Opt_D_dump_stg_final "Final STG:" FormatSTG + (pprGenStgTopBindings (initStgPprOpts dflags) stg_binds) + -- do the unfortunately effectual business stgToJS logger js_config stg_binds this_mod spt_entries foreign_stubs0 cost_centre_info output_filename return (output_filename, stub_c_exists, foreign_fps, cg_infos) ===================================== compiler/GHC/StgToJS/CodeGen.hs ===================================== @@ -92,13 +92,14 @@ stgToJS logger config stg_binds0 this_mod spt_entries foreign_stubs cccs output_ return (ts ++ luOtherExports u, luStat u) deps <- genDependencyData this_mod lus - lift $ Object.object' (moduleName this_mod) sym_table deps (map (second BL.fromStrict) p) + lift $ Object.writeObject' (moduleName this_mod) sym_table deps (map (second BL.fromStrict) p) -- Doc to dump when -ddump-js is enabled let mod_name = renderWithContext defaultSDocContext (ppr this_mod) - o <- Object.readObject mod_name obj - putDumpFileMaybe logger Opt_D_dump_js "JavaScript code" FormatJS - $ vcat (fmap (docToSDoc . jsToDoc . Object.oiStat) o) + when (logHasDumpFlag logger Opt_D_dump_js) $ do + o <- Object.readObject mod_name obj + putDumpFileMaybe logger Opt_D_dump_js "JavaScript code" FormatJS + $ vcat (fmap (docToSDoc . jsToDoc . Object.oiStat) o) BL.writeFile output_fn obj @@ -240,7 +241,8 @@ serializeLinkableUnit :: HasDebugCallStack -> G (Object.SymbolTable, [FastString], BS.ByteString) serializeLinkableUnit _m st i ci si stat rawStat fe fi = do !i' <- mapM idStr i - !(!st', !o) <- lift $ Object.serializeStat st ci si stat rawStat fe fi + !(!st', !lo) <- lift $ Object.runPutS st $ \bh -> Object.putLinkableUnit bh ci si stat rawStat fe fi + let !o = BL.toStrict lo return (st', i', o) -- deepseq results? where idStr i = itxt <$> identForId i ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -30,7 +30,10 @@ -- serialized [Text] -> ([ClosureInfo], JStat) blocks -- -- file layout: --- - header ["GHCJSOBJ", length of symbol table, length of dependencies, length of index] +-- - magic "GHCJSOBJ" +-- - length of symbol table +-- - length of dependencies +-- - length of index -- - compiler version tag -- - symbol table -- - dependency info @@ -40,8 +43,7 @@ ----------------------------------------------------------------------------- module GHC.StgToJS.Object - ( object - , object' + ( writeObject' , readDepsFile , readDepsFileEither , hReadDeps @@ -51,7 +53,7 @@ module GHC.StgToJS.Object , readObjectFileKeys , readObject , readObjectKeys - , serializeStat + , putLinkableUnit , emptySymbolTable , isGlobalUnit , isExportsUnit -- XXX verify that this is used @@ -62,6 +64,7 @@ module GHC.StgToJS.Object , Deps (..), BlockDeps (..), DepsLocation (..) , ExpFun (..), ExportedFun (..) , versionTag, versionTagLength + , runPutS ) where @@ -118,12 +121,20 @@ data Header = Header , hdrIdxLen :: !Int64 } deriving (Eq, Ord, Show) +type BlockId = Int +type BlockIds = IntSet + -- | dependencies for a single module data Deps = Deps - { depsModule :: !Module -- ^ module - , depsRequired :: !IntSet -- ^ blocks that always need to be linked when this object is loaded (e.g. everything that contains initializer code or foreign exports) - , depsHaskellExported :: !(Map ExportedFun Int) -- ^ exported Haskell functions -> block - , depsBlocks :: !(Array Int BlockDeps) -- ^ info about each block + { depsModule :: !Module + -- ^ module + , depsRequired :: !BlockIds + -- ^ blocks that always need to be linked when this object is loaded (e.g. + -- everything that contains initializer code or foreign exports) + , depsHaskellExported :: !(Map ExportedFun BlockId) + -- ^ exported Haskell functions -> block + , depsBlocks :: !(Array BlockId BlockDeps) + -- ^ info about each block } deriving (Generic) instance Outputable Deps where @@ -208,22 +219,18 @@ insertSymbol s st@(SymbolTable n t) = Nothing -> (SymbolTable (n+1) (addToUniqMap t s n), n) data ObjEnv = ObjEnv - { oeSymbols :: SymbolTableR - , _oeName :: String - } - -data SymbolTableR = SymbolTableR - { strText :: Array Int FastString - , _strString :: Array Int String + { oeSymbols :: Dictionary + , _oeName :: String } -runGetS :: HasDebugCallStack => String -> SymbolTableR -> (BinHandle -> IO a) -> ByteString -> IO a +runGetS :: HasDebugCallStack => String -> Dictionary -> (BinHandle -> IO a) -> ByteString -> IO a runGetS name st m bl = do let bs = B.toStrict bl bh0 <- unpackBinBuffer (BS.length bs) bs let bh = setUserData bh0 (newReadState undefined (readTable (ObjEnv st name))) m bh +-- temporary kludge to bridge BinHandle and ByteString runPutS :: SymbolTable -> (BinHandle -> IO ()) -> IO (SymbolTable, ByteString) runPutS st ps = do bh0 <- openBinMem (1024 * 1024) @@ -235,7 +242,7 @@ runPutS st ps = do insertTable :: IORef SymbolTable -> BinHandle -> FastString -> IO () insertTable t_r bh s = do t <- readIORef t_r - let (t', n) = insertSymbol s t + let !(t', n) = insertSymbol s t writeIORef t_r t' put_ bh n return () @@ -243,11 +250,7 @@ insertTable t_r bh s = do readTable :: ObjEnv -> BinHandle -> IO FastString readTable e bh = do n :: Int <- get bh - return $ strText (oeSymbols e) ! fromIntegral n - --- unexpected :: String -> GetS a --- unexpected err = ask >>= \e -> --- error (oeName e ++ ": " ++ err) + return $ (oeSymbols e) ! fromIntegral n -- one toplevel block in the object file data ObjUnit = ObjUnit @@ -260,39 +263,23 @@ data ObjUnit = ObjUnit , oiFImports :: [ForeignJSRef] } --- | build an object file -object :: ModuleName -- ^ the module name - -> Deps -- ^ the dependencies - -> [ObjUnit] -- ^ units, the first unit is the module-global one - -> IO ByteString -- ^ serialized object -object mname ds units = do - (xs, symbs) <- go emptySymbolTable units - object' mname symbs ds xs - where - go st0 (ObjUnit sy cl si st str fe fi : ys) = do - (st1, bs ) <- serializeStat st0 cl si st str fe fi - (bss, st2) <- go st1 ys - return ((sy,B.fromChunks [bs]):bss, st2) - go st0 [] = return ([], st0) - -serializeStat :: SymbolTable - -> [ClosureInfo] - -> [StaticInfo] - -> JStat - -> FastString - -> [ExpFun] - -> [ForeignJSRef] - -> IO (SymbolTable, BS.ByteString) -serializeStat st ci si s sraw fe fi = do - -- TODO: Did any of the Objectable instances previously used here interact with the `State`? - (st', bs) <- runPutS st $ \bh -> do - put_ bh ci - put_ bh si - put_ bh s - put_ bh sraw - put_ bh fe - put_ bh fi - return (st', B.toStrict bs) +-- | Write a linkable unit +putLinkableUnit + :: BinHandle + -> [ClosureInfo] + -> [StaticInfo] + -> JStat + -> FastString + -> [ExpFun] + -> [ForeignJSRef] + -> IO () +putLinkableUnit bh ci si s sraw fe fi = do + put_ bh ci + put_ bh si + put_ bh s + put_ bh sraw + put_ bh fe + put_ bh fi -- tag to store the module name in the object file moduleNameTag :: ModuleName -> BS.ByteString @@ -304,20 +291,19 @@ moduleNameTag (ModuleName fs) = case compare len moduleNameLength of !tag = SBS.fromShort (fs_sbs fs) !len = n_chars fs -object' +writeObject' :: ModuleName -- ^ module -> SymbolTable -- ^ final symbol table -> Deps -- ^ dependencies -> [([FastString],ByteString)] -- ^ serialized units and their exported symbols, the first unit is module-global -> IO ByteString -object' mod_name st0 deps0 os = do +writeObject' mod_name st0 deps0 os = do (sti, idx) <- putIndex st0 os let symbs = putSymbolTable sti deps1 <- putDepsSection deps0 + let bl = fromIntegral . B.length let hdr = putHeader (Header (moduleNameTag mod_name) (bl symbs) (bl deps1) (bl idx)) return $ hdr <> symbs <> deps1 <> idx <> mconcat (map snd os) - where - bl = fromIntegral . B.length putIndex :: SymbolTable -> [([FastString], ByteString)] -> IO (SymbolTable, ByteString) putIndex st xs = runPutS st (\bh -> put_ bh $ zip symbols offsets) @@ -325,13 +311,13 @@ putIndex st xs = runPutS st (\bh -> put_ bh $ zip symbols offsets) (symbols, values) = unzip xs offsets = scanl (+) 0 (map B.length values) -getIndex :: HasDebugCallStack => String -> SymbolTableR -> ByteString -> IO [([FastString], Int64)] +getIndex :: HasDebugCallStack => String -> Dictionary -> ByteString -> IO [([FastString], Int64)] getIndex name st bs = runGetS name st get bs putDeps :: SymbolTable -> Deps -> IO (SymbolTable, ByteString) putDeps st deps = runPutS st (\bh -> put_ bh deps) -getDeps :: HasDebugCallStack => String -> SymbolTableR -> ByteString -> IO Deps +getDeps :: HasDebugCallStack => String -> Dictionary -> ByteString -> IO Deps getDeps name st bs = runGetS name st get bs toI32 :: Int -> Int32 @@ -451,7 +437,7 @@ readObjectKeys name p bs = readObjectKeys' :: HasDebugCallStack => String -> (Int -> [FastString] -> Bool) - -> SymbolTableR + -> Dictionary -> ByteString -> ByteString -> IO [ObjUnit] @@ -466,8 +452,8 @@ readObjectKeys' name p st bsidx bsobjs = do | otherwise = return Nothing getOU bh = (,,,,,) <$> get bh <*> get bh <*> get bh <*> get bh <*> get bh <*> get bh -getSymbolTable :: HasDebugCallStack => ByteString -> SymbolTableR -getSymbolTable bs = SymbolTableR (listArray (0,n-1) xs) (listArray (0,n-1) (map unpackFS xs)) +getSymbolTable :: HasDebugCallStack => ByteString -> Dictionary +getSymbolTable bs = listArray (0,n-1) xs where (n,xs) = DB.runGet getter bs getter :: DB.Get (Int, [FastString]) @@ -530,19 +516,6 @@ tag = put_ getTag :: BinHandle -> IO Word8 getTag = get --- instance Binary ShortText where --- put_ bh t = put_ bh (mkFastString $ ST.unpack t) --- get bh = ST.pack . unpackFS <$> get bh - -- put_ bh t = do - -- symbols <- St.get - -- let (symbols', n) = insertSymbol t symbols - -- St.put symbols' - -- lift (DB.putWord32le $ fromIntegral n) - -- get bh = do - -- st <- oeSymbols <$> ask - -- n <- lift DB.getWord32le - -- return (strText st ! fromIntegral n) - instance Binary JStat where put_ bh (DeclStat i) = tag bh 1 >> put_ bh i put_ bh (ReturnStat e) = tag bh 2 >> put_ bh e ===================================== hadrian/src/Flavour.hs ===================================== @@ -41,6 +41,7 @@ flavourTransformers = M.fromList [ "werror" =: werror , "debug_info" =: enableDebugInfo , "ticky_ghc" =: enableTickyGhc + , "ticky_ghc0" =: enableTickyGhc0 , "split_sections" =: splitSections , "thread_sanitizer" =: enableThreadSanitizer , "llvm" =: viaLlvmBackend @@ -90,13 +91,14 @@ parseFlavour baseFlavours transformers str = baseFlavour = P.choice [ f <$ P.try (P.string (name f)) | f <- reverse (sortOn name baseFlavours) - ] -- needed to parse e.g. "quick-debug" before "quick" + ] -- reverse&sort needed to parse e.g. "quick-debug" before "quick" flavourTrans :: Parser (Flavour -> Flavour) flavourTrans = do void $ P.char '+' P.choice [ trans <$ P.try (P.string nm) - | (nm, trans) <- M.toList transformers + | (nm, trans) <- reverse $ sortOn fst $ M.toList transformers + -- reverse&sort needed to parse e.g. "ticky_ghc0" before "ticky_ghc" ] -- | Add arguments to the 'args' of a 'Flavour'. @@ -121,19 +123,28 @@ enableDebugInfo = addArgs $ notStage0 ? mconcat enableTickyGhc :: Flavour -> Flavour enableTickyGhc = addArgs $ stage1 ? mconcat - [ builder (Ghc CompileHs) ? ticky - , builder (Ghc LinkHs) ? ticky + [ builder (Ghc CompileHs) ? tickyArgs + , builder (Ghc LinkHs) ? tickyArgs ] - where - ticky = mconcat - [ arg "-ticky" - , arg "-ticky-allocd" - , arg "-ticky-dyn-thunk" - -- You generally need STG dumps to interpret ticky profiles - , arg "-ddump-to-file" - , arg "-ddump-stg-final" + +-- | Enable the ticky-ticky profiler in stage1 GHC +enableTickyGhc0 :: Flavour -> Flavour +enableTickyGhc0 = + addArgs $ stage0 ? mconcat + [ builder (Ghc CompileHs) ? tickyArgs + , builder (Ghc LinkHs) ? tickyArgs ] +tickyArgs :: Args +tickyArgs = mconcat + [ arg "-ticky" + , arg "-ticky-allocd" + , arg "-ticky-dyn-thunk" + -- You generally need STG dumps to interpret ticky profiles + , arg "-ddump-to-file" + , arg "-ddump-stg-final" + ] + -- | Enable Core, STG, and (not C--) linting in all compilations with the stage1 compiler. enableLinting :: Flavour -> Flavour enableLinting = ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -74,8 +74,9 @@ platformSupportsSharedLibs = do windows <- isWinTarget ppc_linux <- anyTargetPlatform [ "powerpc-unknown-linux" ] solaris <- anyTargetPlatform [ "i386-unknown-solaris2" ] + javascript <- anyTargetArch [ "js" ] solarisBroken <- flag SolarisBrokenShld - return $ not (windows || ppc_linux || solaris && solarisBroken) + return $ not (windows || ppc_linux || (solaris && solarisBroken) || javascript) -- | Does the target support the threaded runtime system? targetSupportsSMP :: Action Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b782512356aeded56d8191f1fe51348fecb69be...b24014b836cf1f3cd781a72ba70e268783a99e26 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b782512356aeded56d8191f1fe51348fecb69be...b24014b836cf1f3cd781a72ba70e268783a99e26 You're receiving 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 Sep 1 05:19:10 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Sep 2022 01:19:10 -0400 Subject: [Git][ghc/ghc][master] Add regression test for #21550 Message-ID: <631040ce25a9a_2f2e5813a03c9c105411f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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" - - - - - 2 changed files: - + testsuite/tests/typecheck/should_compile/T21550.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== testsuite/tests/typecheck/should_compile/T21550.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE UndecidableInstances #-} + +module Main where + +import Data.Function +import Data.Kind +import GHC.Generics +import GHC.TypeLits + +-- inlined generic-data imports: +from' :: Generic a => a -> Rep a () +from' = from + +geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool +geq = (==) `on` from' + +gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering +gcompare = compare `on` from' + + +-- test case: +data A (v :: Symbol -> Type -> Type) a b deriving (Generic,Generic1) + +instance (Eq a , (forall w z . Eq z => Eq (v w z)) , Eq b) => Eq (A v a b) where + {-# INLINE (==) #-} + (==) = geq + +instance (Ord a , (forall w z . Eq z => Eq (v w z)) , (forall w z . Ord z => Ord (v w z)) , Ord b) => Ord (A v a b) where + {-# INLINE compare #-} + compare = gcompare + +main :: IO () +main = pure () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -855,3 +855,4 @@ test('DeepSubsumption08', normal, compile, ['']) test('DeepSubsumption09', normal, compile, ['']) test('T21951a', normal, compile, ['-Wredundant-strictness-flags']) test('T21951b', normal, compile, ['-Wredundant-strictness-flags']) +test('T21550', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15111af6adb1c85af5b17088134c9e71bee025e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15111af6adb1c85af5b17088134c9e71bee025e3 You're receiving 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 Sep 1 05:19:44 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Sep 2022 01:19:44 -0400 Subject: [Git][ghc/ghc][master] Minor cleanup Message-ID: <631040f06ede5_2f2e584887810577b9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 12 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Outputable.hs - ghc/GHCi/UI.hs - testsuite/tests/corelint/T21115b.stderr Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -772,7 +772,7 @@ However, join points have simpler invariants in other ways e.g. let j :: Int# = factorial x in ... 6. The RHS of join point is not required to have a fixed runtime representation, - e.g. let j :: r :: TYPE l = fail void# in ... + e.g. let j :: r :: TYPE l = fail (##) in ... This happened in an intermediate program #13394 Examples: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -45,7 +45,6 @@ module GHC.Core.Coercion ( mkKindCo, castCoercionKind, castCoercionKind1, castCoercionKind2, - mkHeteroCoercionType, mkPrimEqPred, mkReprPrimEqPred, mkPrimEqPredRole, mkHeteroPrimEqPred, mkHeteroReprPrimEqPred, @@ -77,7 +76,6 @@ module GHC.Core.Coercion ( -- ** Coercion variables mkCoVar, isCoVar, coVarName, setCoVarName, setCoVarUnique, - isCoVar_maybe, -- ** Free variables tyCoVarsOfCo, tyCoVarsOfCos, coVarsOfCo, @@ -521,7 +519,9 @@ decomposePiCos orig_co (Pair orig_k1 orig_k2) orig_args -- didn't have enough binders go acc_arg_cos _ki1 co _ki2 _tys = (reverse acc_arg_cos, co) --- | Attempts to obtain the type variable underlying a 'Coercion' +-- | Extract a covar, if possible. This check is dirty. Be ashamed +-- of yourself. (It's dirty because it cares about the structure of +-- a coercion, which is morally reprehensible.) getCoVar_maybe :: Coercion -> Maybe CoVar getCoVar_maybe (CoVarCo cv) = Just cv getCoVar_maybe _ = Nothing @@ -953,13 +953,6 @@ it's a relatively expensive test and perhaps better done in optCoercion. Not a big deal either way. -} --- | Extract a covar, if possible. This check is dirty. Be ashamed --- of yourself. (It's dirty because it cares about the structure of --- a coercion, which is morally reprehensible.) -isCoVar_maybe :: Coercion -> Maybe CoVar -isCoVar_maybe (CoVarCo cv) = Just cv -isCoVar_maybe _ = Nothing - mkAxInstCo :: Role -> CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Coercion -- mkAxInstCo can legitimately be called over-staturated; @@ -2558,11 +2551,6 @@ mkCoercionType Phantom = \ty1 ty2 -> in TyConApp eqPhantPrimTyCon [ki1, ki2, ty1, ty2] -mkHeteroCoercionType :: Role -> Kind -> Kind -> Type -> Type -> Type -mkHeteroCoercionType Nominal = mkHeteroPrimEqPred -mkHeteroCoercionType Representational = mkHeteroReprPrimEqPred -mkHeteroCoercionType Phantom = panic "mkHeteroCoercionType" - -- | Creates a primitive type equality predicate. -- Invariant: the types are not Coercions mkPrimEqPred :: Type -> Type -> Type ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Prelude import GHC.Platform -import GHC.Types.Id.Make ( voidPrimId ) +import GHC.Types.Id.Make ( unboxedUnitExpr ) import GHC.Types.Id import GHC.Types.Literal import GHC.Types.Name.Occurrence ( occNameFS ) @@ -2107,7 +2107,7 @@ builtinBignumRules = let ret n v = pure $ mkCoreUbxSum 2 n [unboxedUnitTy,naturalTy] v platform <- getPlatform if x < y - then ret 1 $ Var voidPrimId + then ret 1 unboxedUnitExpr else ret 2 $ mkNaturalExpr platform (x - y) -- unary operations ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -129,7 +129,6 @@ module GHC.Core.Type ( isUnliftedType, isBoxedType, isUnboxedTupleType, isUnboxedSumType, kindBoxedRepLevity_maybe, mightBeLiftedType, mightBeUnliftedType, - isStateType, isAlgType, isDataFamilyAppType, isPrimitiveType, isStrictType, isLevityTy, isLevityVar, @@ -2482,13 +2481,6 @@ isUnliftedType ty = Nothing -> pprPanic "isUnliftedType" (ppr ty <+> dcolon <+> ppr (typeKind ty)) --- | State token type. -isStateType :: Type -> Bool -isStateType ty - = case tyConAppTyCon_maybe ty of - Just tycon -> tycon == statePrimTyCon - _ -> False - -- | Returns: -- -- * 'False' if the type is /guaranteed/ unlifted or ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -5023,7 +5023,6 @@ initSDocContext dflags style = SDC , sdocSuppressStgExts = gopt Opt_SuppressStgExts dflags , sdocErrorSpans = gopt Opt_ErrorSpans dflags , sdocStarIsType = xopt LangExt.StarIsType dflags - , sdocImpredicativeTypes = xopt LangExt.ImpredicativeTypes dflags , sdocLinearTypes = xopt LangExt.LinearTypes dflags , sdocListTuplePuns = True , sdocPrintTypeAbbreviations = True ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -795,7 +795,7 @@ dsHsConLike (PatSynCon ps) = do { builder_id <- dsLookupGlobalId builder_name ; return (if add_void then mkCoreApp (text "dsConLike" <+> ppr ps) - (Var builder_id) (Var voidPrimId) + (Var builder_id) unboxedUnitExpr else Var builder_id) } | otherwise = pprPanic "dsConLike" (ppr ps) ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -917,7 +917,7 @@ mkFailurePair expr ; fail_fun_arg <- newSysLocalDs Many unboxedUnitTy ; let real_arg = setOneShotLambda fail_fun_arg ; return (NonRec fail_fun_var (Lam real_arg expr), - App (Var fail_fun_var) (Var voidPrimId)) } + App (Var fail_fun_var) unboxedUnitExpr) } where ty = exprType expr ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Tc.Types.Evidence import GHC.Tc.Types.Origin import GHC.Tc.TyCl.Build import GHC.Types.Var.Set -import GHC.Types.Id.Make import GHC.Tc.TyCl.Utils import GHC.Core.ConLike import GHC.Types.FieldLabel @@ -796,8 +795,8 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn res_ty = mkTyVarTy res_tv is_unlifted = null args && null prov_dicts (cont_args, cont_arg_tys) - | is_unlifted = ([nlHsVar voidPrimId], [unboxedUnitTy]) - | otherwise = (args, arg_tys) + | is_unlifted = ([nlHsDataCon unboxedUnitDataCon], [unboxedUnitTy]) + | otherwise = (args, arg_tys) cont_ty = mkInfSigmaTy ex_tvs prov_theta $ mkVisFunTysMany cont_arg_tys res_ty @@ -818,7 +817,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn inst_wrap = mkWpEvApps prov_dicts <.> mkWpTyApps ex_tys cont' = foldl' nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args - fail' = nlHsApps fail [nlHsVar voidPrimId] + fail' = nlHsApps fail [nlHsDataCon unboxedUnitDataCon] args = map nlVarPat [scrutinee, cont, fail] lwpat = noLocA $ WildPat pat_ty ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -25,6 +25,7 @@ module GHC.Types.Id.Make ( DataConBoxer(..), vanillaDataConBoxer, mkDataConRep, mkDataConWorkId, DataConBangOpts (..), BangOpts (..), + unboxedUnitExpr, -- And some particular Ids; see below for why they are wired in wiredInIds, ghcPrimIds, @@ -1812,9 +1813,10 @@ voidPrimId :: Id -- Global constant :: Void# -- We cannot define it in normal Haskell, since it's -- a top-level unlifted value. voidPrimId = pcMiscPrelId voidPrimIdName unboxedUnitTy - (noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding defaultSimpleOpts rhs) - where rhs = Var (dataConWorkId unboxedUnitDataCon) + (noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding defaultSimpleOpts unboxedUnitExpr) +unboxedUnitExpr :: CoreExpr +unboxedUnitExpr = Var (dataConWorkId unboxedUnitDataCon) voidArgId :: Id -- Local lambda-bound :: Void# voidArgId = mkSysLocal (fsLit "void") voidArgIdKey Many unboxedUnitTy ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -390,7 +390,6 @@ data SDocContext = SDC , sdocErrorSpans :: !Bool , sdocStarIsType :: !Bool , sdocLinearTypes :: !Bool - , sdocImpredicativeTypes :: !Bool , sdocListTuplePuns :: !Bool , sdocPrintTypeAbbreviations :: !Bool , sdocUnitIdForUser :: !(FastString -> SDoc) @@ -450,7 +449,6 @@ defaultSDocContext = SDC , sdocSuppressStgExts = False , sdocErrorSpans = False , sdocStarIsType = False - , sdocImpredicativeTypes = False , sdocLinearTypes = False , sdocListTuplePuns = True , sdocPrintTypeAbbreviations = True ===================================== ghc/GHCi/UI.hs ===================================== @@ -57,7 +57,7 @@ import GHC.Driver.Config.Diagnostic import qualified GHC import GHC ( LoadHowMuch(..), Target(..), TargetId(..), Resume, SingleStep, Ghc, - GetDocsFailure(..), putLogMsgM, pushLogHookM, + GetDocsFailure(..), pushLogHookM, getModuleGraph, handleSourceError, ms_mod ) import GHC.Driver.Main (hscParseModuleWithLocation, hscParseStmtWithLocation) import GHC.Hs.ImpExp @@ -3289,7 +3289,8 @@ showCmd str = do , action "bindings" $ showBindings , action "linker" $ do msg <- liftIO $ Loader.showLoaderState (hscInterp hsc_env) - putLogMsgM MCDump noSrcSpan msg + dflags <- getDynFlags + liftIO $ putStrLn $ showSDoc dflags msg , action "breaks" $ showBkptTable , action "context" $ showContext , action "packages" $ showUnits ===================================== testsuite/tests/corelint/T21115b.stderr ===================================== @@ -22,7 +22,7 @@ foo case patError "T21115b.hs:(10,4)-(15,4)|\\case"# of wild { } } in let { fail = \ ds -> 5# } in case ds of ds { - __DEFAULT -> fail void#; + __DEFAULT -> fail (##); 0.0## -> 2#; 2.0## -> 3# } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d3a055d4df6842f8fbcfbc1ca96e2a45a47d351 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d3a055d4df6842f8fbcfbc1ca96e2a45a47d351 You're receiving 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 Sep 1 09:51:17 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Sep 2022 05:51:17 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Add regression test for #21550 Message-ID: <63108095839fb_2f2e5813a03c9c111188f@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 3ccc27db by Tommy Bidne at 2022-09-01T05:50:57-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - fce81df1 by Matthew Pickering at 2022-09-01T05:50:57-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. - - - - - 18 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/9.6.1-notes.rst - ghc/GHCi/UI.hs - libraries/base/changelog.md - libraries/ghc-prim/GHC/Classes.hs - testsuite/tests/corelint/T21115b.stderr - + testsuite/tests/typecheck/should_compile/T21550.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -772,7 +772,7 @@ However, join points have simpler invariants in other ways e.g. let j :: Int# = factorial x in ... 6. The RHS of join point is not required to have a fixed runtime representation, - e.g. let j :: r :: TYPE l = fail void# in ... + e.g. let j :: r :: TYPE l = fail (##) in ... This happened in an intermediate program #13394 Examples: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -45,7 +45,6 @@ module GHC.Core.Coercion ( mkKindCo, castCoercionKind, castCoercionKind1, castCoercionKind2, - mkHeteroCoercionType, mkPrimEqPred, mkReprPrimEqPred, mkPrimEqPredRole, mkHeteroPrimEqPred, mkHeteroReprPrimEqPred, @@ -77,7 +76,6 @@ module GHC.Core.Coercion ( -- ** Coercion variables mkCoVar, isCoVar, coVarName, setCoVarName, setCoVarUnique, - isCoVar_maybe, -- ** Free variables tyCoVarsOfCo, tyCoVarsOfCos, coVarsOfCo, @@ -521,7 +519,9 @@ decomposePiCos orig_co (Pair orig_k1 orig_k2) orig_args -- didn't have enough binders go acc_arg_cos _ki1 co _ki2 _tys = (reverse acc_arg_cos, co) --- | Attempts to obtain the type variable underlying a 'Coercion' +-- | Extract a covar, if possible. This check is dirty. Be ashamed +-- of yourself. (It's dirty because it cares about the structure of +-- a coercion, which is morally reprehensible.) getCoVar_maybe :: Coercion -> Maybe CoVar getCoVar_maybe (CoVarCo cv) = Just cv getCoVar_maybe _ = Nothing @@ -953,13 +953,6 @@ it's a relatively expensive test and perhaps better done in optCoercion. Not a big deal either way. -} --- | Extract a covar, if possible. This check is dirty. Be ashamed --- of yourself. (It's dirty because it cares about the structure of --- a coercion, which is morally reprehensible.) -isCoVar_maybe :: Coercion -> Maybe CoVar -isCoVar_maybe (CoVarCo cv) = Just cv -isCoVar_maybe _ = Nothing - mkAxInstCo :: Role -> CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Coercion -- mkAxInstCo can legitimately be called over-staturated; @@ -2558,11 +2551,6 @@ mkCoercionType Phantom = \ty1 ty2 -> in TyConApp eqPhantPrimTyCon [ki1, ki2, ty1, ty2] -mkHeteroCoercionType :: Role -> Kind -> Kind -> Type -> Type -> Type -mkHeteroCoercionType Nominal = mkHeteroPrimEqPred -mkHeteroCoercionType Representational = mkHeteroReprPrimEqPred -mkHeteroCoercionType Phantom = panic "mkHeteroCoercionType" - -- | Creates a primitive type equality predicate. -- Invariant: the types are not Coercions mkPrimEqPred :: Type -> Type -> Type ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Prelude import GHC.Platform -import GHC.Types.Id.Make ( voidPrimId ) +import GHC.Types.Id.Make ( unboxedUnitExpr ) import GHC.Types.Id import GHC.Types.Literal import GHC.Types.Name.Occurrence ( occNameFS ) @@ -2107,7 +2107,7 @@ builtinBignumRules = let ret n v = pure $ mkCoreUbxSum 2 n [unboxedUnitTy,naturalTy] v platform <- getPlatform if x < y - then ret 1 $ Var voidPrimId + then ret 1 unboxedUnitExpr else ret 2 $ mkNaturalExpr platform (x - y) -- unary operations ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {- ToDo [Oct 2013] ~~~~~~~~~~~~~~~ @@ -974,6 +975,14 @@ lookupHowBound env id = lookupVarEnv (sc_how_bound env) id scSubstId :: ScEnv -> InId -> OutExpr scSubstId env v = lookupIdSubst (sc_subst env) v + +-- Solo is only defined in base starting from ghc-9.2 +#if !(MIN_VERSION_base(4, 16, 0)) + +data Solo a = Solo a + +#endif + -- The !subst ensures that we force the selection `(sc_subst env)`, which avoids -- retaining all of `env` when we only need `subst`. The `Solo` means that the -- substitution itself is lazy, because that type is often discarded. ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -129,7 +129,6 @@ module GHC.Core.Type ( isUnliftedType, isBoxedType, isUnboxedTupleType, isUnboxedSumType, kindBoxedRepLevity_maybe, mightBeLiftedType, mightBeUnliftedType, - isStateType, isAlgType, isDataFamilyAppType, isPrimitiveType, isStrictType, isLevityTy, isLevityVar, @@ -2482,13 +2481,6 @@ isUnliftedType ty = Nothing -> pprPanic "isUnliftedType" (ppr ty <+> dcolon <+> ppr (typeKind ty)) --- | State token type. -isStateType :: Type -> Bool -isStateType ty - = case tyConAppTyCon_maybe ty of - Just tycon -> tycon == statePrimTyCon - _ -> False - -- | Returns: -- -- * 'False' if the type is /guaranteed/ unlifted or ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -5023,7 +5023,6 @@ initSDocContext dflags style = SDC , sdocSuppressStgExts = gopt Opt_SuppressStgExts dflags , sdocErrorSpans = gopt Opt_ErrorSpans dflags , sdocStarIsType = xopt LangExt.StarIsType dflags - , sdocImpredicativeTypes = xopt LangExt.ImpredicativeTypes dflags , sdocLinearTypes = xopt LangExt.LinearTypes dflags , sdocListTuplePuns = True , sdocPrintTypeAbbreviations = True ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -795,7 +795,7 @@ dsHsConLike (PatSynCon ps) = do { builder_id <- dsLookupGlobalId builder_name ; return (if add_void then mkCoreApp (text "dsConLike" <+> ppr ps) - (Var builder_id) (Var voidPrimId) + (Var builder_id) unboxedUnitExpr else Var builder_id) } | otherwise = pprPanic "dsConLike" (ppr ps) ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -917,7 +917,7 @@ mkFailurePair expr ; fail_fun_arg <- newSysLocalDs Many unboxedUnitTy ; let real_arg = setOneShotLambda fail_fun_arg ; return (NonRec fail_fun_var (Lam real_arg expr), - App (Var fail_fun_var) (Var voidPrimId)) } + App (Var fail_fun_var) unboxedUnitExpr) } where ty = exprType expr ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Tc.Types.Evidence import GHC.Tc.Types.Origin import GHC.Tc.TyCl.Build import GHC.Types.Var.Set -import GHC.Types.Id.Make import GHC.Tc.TyCl.Utils import GHC.Core.ConLike import GHC.Types.FieldLabel @@ -796,8 +795,8 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn res_ty = mkTyVarTy res_tv is_unlifted = null args && null prov_dicts (cont_args, cont_arg_tys) - | is_unlifted = ([nlHsVar voidPrimId], [unboxedUnitTy]) - | otherwise = (args, arg_tys) + | is_unlifted = ([nlHsDataCon unboxedUnitDataCon], [unboxedUnitTy]) + | otherwise = (args, arg_tys) cont_ty = mkInfSigmaTy ex_tvs prov_theta $ mkVisFunTysMany cont_arg_tys res_ty @@ -818,7 +817,7 @@ tcPatSynMatcher (L loc ps_name) lpat prag_fn inst_wrap = mkWpEvApps prov_dicts <.> mkWpTyApps ex_tys cont' = foldl' nlHsApp (mkLHsWrap inst_wrap (nlHsVar cont)) cont_args - fail' = nlHsApps fail [nlHsVar voidPrimId] + fail' = nlHsApps fail [nlHsDataCon unboxedUnitDataCon] args = map nlVarPat [scrutinee, cont, fail] lwpat = noLocA $ WildPat pat_ty ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -25,6 +25,7 @@ module GHC.Types.Id.Make ( DataConBoxer(..), vanillaDataConBoxer, mkDataConRep, mkDataConWorkId, DataConBangOpts (..), BangOpts (..), + unboxedUnitExpr, -- And some particular Ids; see below for why they are wired in wiredInIds, ghcPrimIds, @@ -1812,9 +1813,10 @@ voidPrimId :: Id -- Global constant :: Void# -- We cannot define it in normal Haskell, since it's -- a top-level unlifted value. voidPrimId = pcMiscPrelId voidPrimIdName unboxedUnitTy - (noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding defaultSimpleOpts rhs) - where rhs = Var (dataConWorkId unboxedUnitDataCon) + (noCafIdInfo `setUnfoldingInfo` mkCompulsoryUnfolding defaultSimpleOpts unboxedUnitExpr) +unboxedUnitExpr :: CoreExpr +unboxedUnitExpr = Var (dataConWorkId unboxedUnitDataCon) voidArgId :: Id -- Local lambda-bound :: Void# voidArgId = mkSysLocal (fsLit "void") voidArgIdKey Many unboxedUnitTy ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -390,7 +390,6 @@ data SDocContext = SDC , sdocErrorSpans :: !Bool , sdocStarIsType :: !Bool , sdocLinearTypes :: !Bool - , sdocImpredicativeTypes :: !Bool , sdocListTuplePuns :: !Bool , sdocPrintTypeAbbreviations :: !Bool , sdocUnitIdForUser :: !(FastString -> SDoc) @@ -450,7 +449,6 @@ defaultSDocContext = SDC , sdocSuppressStgExts = False , sdocErrorSpans = False , sdocStarIsType = False - , sdocImpredicativeTypes = False , sdocLinearTypes = False , sdocListTuplePuns = True , sdocPrintTypeAbbreviations = True ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -94,6 +94,10 @@ This can be convenient when pasting large multi-line blocks of code into GHCi. label (:base-ref:`GHC.Conc.threadLabel`) and status (:base-ref:`GHC.Conc.threadStatus`). +- Change default ``Ord`` implementation of ``(>=)``, ``(>)``, and ``(<)`` to use + ``(<=)`` instead of ``compare`` per CLC proposal: + https://github.com/haskell/core-libraries-committee/issues/24 + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== ghc/GHCi/UI.hs ===================================== @@ -57,7 +57,7 @@ import GHC.Driver.Config.Diagnostic import qualified GHC import GHC ( LoadHowMuch(..), Target(..), TargetId(..), Resume, SingleStep, Ghc, - GetDocsFailure(..), putLogMsgM, pushLogHookM, + GetDocsFailure(..), pushLogHookM, getModuleGraph, handleSourceError, ms_mod ) import GHC.Driver.Main (hscParseModuleWithLocation, hscParseStmtWithLocation) import GHC.Hs.ImpExp @@ -3289,7 +3289,8 @@ showCmd str = do , action "bindings" $ showBindings , action "linker" $ do msg <- liftIO $ Loader.showLoaderState (hscInterp hsc_env) - putLogMsgM MCDump noSrcSpan msg + dflags <- getDynFlags + liftIO $ putStrLn $ showSDoc dflags msg , action "breaks" $ showBkptTable , action "context" $ showContext , action "packages" $ showUnits ===================================== libraries/base/changelog.md ===================================== @@ -22,6 +22,9 @@ * `GHC.Conc.Sync.threadLabel` was added, allowing the user to query the label of a given `ThreadId`. * Add `inits1` and `tails1` to `Data.List.NonEmpty`. + * Change default `Ord` implementation of `(>=)`, `(>)`, and `(<)` to use + `(<=)` instead of `compare` per + [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/24). ## 4.17.0.0 *August 2022* ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -333,10 +333,11 @@ class (Eq a) => Ord a where else if x <= y then LT else GT - x < y = case compare x y of { LT -> True; _ -> False } x <= y = case compare x y of { GT -> False; _ -> True } - x > y = case compare x y of { GT -> True; _ -> False } - x >= y = case compare x y of { LT -> False; _ -> True } + x >= y = y <= x + x > y = not (x <= y) + x < y = not (y <= x) + -- These two default methods use '<=' rather than 'compare' -- because the latter is often more expensive ===================================== testsuite/tests/corelint/T21115b.stderr ===================================== @@ -22,7 +22,7 @@ foo case patError "T21115b.hs:(10,4)-(15,4)|\\case"# of wild { } } in let { fail = \ ds -> 5# } in case ds of ds { - __DEFAULT -> fail void#; + __DEFAULT -> fail (##); 0.0## -> 2#; 2.0## -> 3# } ===================================== testsuite/tests/typecheck/should_compile/T21550.hs ===================================== @@ -0,0 +1,39 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE UndecidableInstances #-} + +module Main where + +import Data.Function +import Data.Kind +import GHC.Generics +import GHC.TypeLits + +-- inlined generic-data imports: +from' :: Generic a => a -> Rep a () +from' = from + +geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool +geq = (==) `on` from' + +gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering +gcompare = compare `on` from' + + +-- test case: +data A (v :: Symbol -> Type -> Type) a b deriving (Generic,Generic1) + +instance (Eq a , (forall w z . Eq z => Eq (v w z)) , Eq b) => Eq (A v a b) where + {-# INLINE (==) #-} + (==) = geq + +instance (Ord a , (forall w z . Eq z => Eq (v w z)) , (forall w z . Ord z => Ord (v w z)) , Ord b) => Ord (A v a b) where + {-# INLINE compare #-} + compare = gcompare + +main :: IO () +main = pure () ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -855,3 +855,4 @@ test('DeepSubsumption08', normal, compile, ['']) test('DeepSubsumption09', normal, compile, ['']) test('T21951a', normal, compile, ['-Wredundant-strictness-flags']) test('T21951b', normal, compile, ['-Wredundant-strictness-flags']) +test('T21550', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4307eb2f67e08ed761469949ed8d8379d1decc0f...fce81df1c5d187c23acc16cb3f8e6978bf003d2a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4307eb2f67e08ed761469949ed8d8379d1decc0f...fce81df1c5d187c23acc16cb3f8e6978bf003d2a You're receiving 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 Sep 1 10:50:27 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 01 Sep 2022 06:50:27 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: RTS: link platform.js before the others! Message-ID: <63108e73b02fa_2f2e5848800112443b@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 536b9109 by Sylvain Henry at 2022-09-01T11:34:50+02:00 RTS: link platform.js before the others! - - - - - 9885b9cc by Sylvain Henry at 2022-09-01T12:02:50+02:00 Hadrian: treat JS objects similarly to other objects - - - - - 3 changed files: - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Program.hs - rts/rts.cabal.in Changes: ===================================== hadrian/src/Rules/Library.hs ===================================== @@ -58,9 +58,8 @@ buildStaticLib root archivePath = do archivePath let context = libAContext l objs <- libraryObjects context - resources <- libraryResources context removeFile archivePath - build $ target context (Ar Pack stage) (objs ++ resources) [archivePath] + build $ target context (Ar Pack stage) objs [archivePath] synopsis <- pkgSynopsis (package context) putSuccess $ renderLibrary (quote pkgname ++ " (" ++ show stage ++ ", way " ++ show way ++ ").") @@ -120,10 +119,11 @@ nonHsObjects context = do asmObjs <- mapM (objectPath context) asmSrcs cObjs <- cObjects context cxxObjs <- cxxObjects context + jsObjs <- jsObjects context cmmSrcs <- interpretInContext context (getContextData cmmSrcs) cmmObjs <- mapM (objectPath context) cmmSrcs eObjs <- extraObjects context - return $ asmObjs ++ cObjs ++ cxxObjs ++ cmmObjs ++ eObjs + return $ asmObjs ++ cObjs ++ cxxObjs ++ cmmObjs ++ jsObjs ++ eObjs -- | Return all the Cxx object files needed to build the given library context. cxxObjects :: Context -> Action [FilePath] @@ -140,15 +140,9 @@ cObjects context = do then objs else filter ((`notElem` ["Evac_thr", "Scav_thr"]) . takeBaseName) objs -libraryResources :: Context -> Action [FilePath] -libraryResources context = do - jsFls <- jsFiles context - need jsFls - return jsFls - --- | Return all the JS sources to be included in the library. -jsFiles :: Context -> Action [FilePath] -jsFiles context = do +-- | Return all the JS object files to be included in the library. +jsObjects :: Context -> Action [FilePath] +jsObjects context = do srcs <- interpretInContext context (getContextData jsSrcs) mapM (objectPath context) srcs ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -120,10 +120,12 @@ buildBinary rs bin context at Context {..} = do asmObjs <- mapM (objectPath context) asmSrcs cSrcs <- interpretInContext context (getContextData cSrcs) cxxSrcs <- interpretInContext context (getContextData cxxSrcs) + jsSrcs <- interpretInContext context (getContextData jsSrcs) cObjs <- mapM (objectPath context) cSrcs cxxObjs <- mapM (objectPath context) cxxSrcs + jsObjs <- mapM (objectPath context) jsSrcs hsObjs <- hsObjects context - let binDeps = asmObjs ++ cObjs ++ cxxObjs ++ hsObjs + let binDeps = asmObjs ++ cObjs ++ cxxObjs ++ jsObjs ++ hsObjs need binDeps buildWithResources rs $ target context (Ghc LinkHs stage) binDeps [bin] synopsis <- pkgSynopsis package ===================================== rts/rts.cabal.in ===================================== @@ -75,30 +75,35 @@ library -- dummy file to force the build of a .a lib -- FIXME (Luite, 2022-08) do we still need the c-sources file? c-sources: version.c - js-sources: js/structs.js - js/arith.js - js/compact.js - js/debug.js - js/enum.js - js/environment.js - js/gc.js - js/goog.js - js/hscore.js - js/md5.js - js/mem.js - js/node-exports.js - js/object.js - js/platform.js - js/profiling.js - js/rts.js - js/stableptr.js - js/staticpointer.js - js/stm.js - js/string.js - js/thread.js - js/unicode.js - js/verify.js - js/weak.js + + js-sources: + -- "platform" must be linked first because it defines global constants + -- (e.g. h$isNode) + js/platform.js + + js/structs.js + js/arith.js + js/compact.js + js/debug.js + js/enum.js + js/environment.js + js/gc.js + js/goog.js + js/hscore.js + js/md5.js + js/mem.js + js/node-exports.js + js/object.js + js/profiling.js + js/rts.js + js/stableptr.js + js/staticpointer.js + js/stm.js + js/string.js + js/thread.js + js/unicode.js + js/verify.js + js/weak.js install-includes: HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b24014b836cf1f3cd781a72ba70e268783a99e26...9885b9cc1b2655036777fadb15f01f1be500c472 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b24014b836cf1f3cd781a72ba70e268783a99e26...9885b9cc1b2655036777fadb15f01f1be500c472 You're receiving 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 Sep 1 12:51:20 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Sep 2022 08:51:20 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Change Ord defaults per CLC proposal Message-ID: <6310aac821aea_2f2e5848878114329b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 08b76fbf by Tommy Bidne at 2022-09-01T08:51:10-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 44a6a9ca by Matthew Pickering at 2022-09-01T08:51:11-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. - - - - - 4 changed files: - compiler/GHC/Core/Opt/SpecConstr.hs - docs/users_guide/9.6.1-notes.rst - libraries/base/changelog.md - libraries/ghc-prim/GHC/Classes.hs Changes: ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {- ToDo [Oct 2013] ~~~~~~~~~~~~~~~ @@ -974,6 +975,14 @@ lookupHowBound env id = lookupVarEnv (sc_how_bound env) id scSubstId :: ScEnv -> InId -> OutExpr scSubstId env v = lookupIdSubst (sc_subst env) v + +-- Solo is only defined in base starting from ghc-9.2 +#if !(MIN_VERSION_base(4, 16, 0)) + +data Solo a = Solo a + +#endif + -- The !subst ensures that we force the selection `(sc_subst env)`, which avoids -- retaining all of `env` when we only need `subst`. The `Solo` means that the -- substitution itself is lazy, because that type is often discarded. ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -94,6 +94,10 @@ This can be convenient when pasting large multi-line blocks of code into GHCi. label (:base-ref:`GHC.Conc.threadLabel`) and status (:base-ref:`GHC.Conc.threadStatus`). +- Change default ``Ord`` implementation of ``(>=)``, ``(>)``, and ``(<)`` to use + ``(<=)`` instead of ``compare`` per CLC proposal: + https://github.com/haskell/core-libraries-committee/issues/24 + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/changelog.md ===================================== @@ -22,6 +22,9 @@ * `GHC.Conc.Sync.threadLabel` was added, allowing the user to query the label of a given `ThreadId`. * Add `inits1` and `tails1` to `Data.List.NonEmpty`. + * Change default `Ord` implementation of `(>=)`, `(>)`, and `(<)` to use + `(<=)` instead of `compare` per + [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/24). ## 4.17.0.0 *August 2022* ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -333,10 +333,11 @@ class (Eq a) => Ord a where else if x <= y then LT else GT - x < y = case compare x y of { LT -> True; _ -> False } x <= y = case compare x y of { GT -> False; _ -> True } - x > y = case compare x y of { GT -> True; _ -> False } - x >= y = case compare x y of { LT -> False; _ -> True } + x >= y = y <= x + x > y = not (x <= y) + x < y = not (y <= x) + -- These two default methods use '<=' rather than 'compare' -- because the latter is often more expensive View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fce81df1c5d187c23acc16cb3f8e6978bf003d2a...44a6a9caf7c3c6daa5cd61654046bdc868278953 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fce81df1c5d187c23acc16cb3f8e6978bf003d2a...44a6a9caf7c3c6daa5cd61654046bdc868278953 You're receiving 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 Sep 1 16:01:37 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Sep 2022 12:01:37 -0400 Subject: [Git][ghc/ghc][master] Change Ord defaults per CLC proposal Message-ID: <6310d761330bd_2f2e584909f1c11729a6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 3 changed files: - docs/users_guide/9.6.1-notes.rst - libraries/base/changelog.md - libraries/ghc-prim/GHC/Classes.hs Changes: ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -94,6 +94,10 @@ This can be convenient when pasting large multi-line blocks of code into GHCi. label (:base-ref:`GHC.Conc.threadLabel`) and status (:base-ref:`GHC.Conc.threadStatus`). +- Change default ``Ord`` implementation of ``(>=)``, ``(>)``, and ``(<)`` to use + ``(<=)`` instead of ``compare`` per CLC proposal: + https://github.com/haskell/core-libraries-committee/issues/24 + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/changelog.md ===================================== @@ -22,6 +22,9 @@ * `GHC.Conc.Sync.threadLabel` was added, allowing the user to query the label of a given `ThreadId`. * Add `inits1` and `tails1` to `Data.List.NonEmpty`. + * Change default `Ord` implementation of `(>=)`, `(>)`, and `(<)` to use + `(<=)` instead of `compare` per + [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/24). ## 4.17.0.0 *August 2022* ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -333,10 +333,11 @@ class (Eq a) => Ord a where else if x <= y then LT else GT - x < y = case compare x y of { LT -> True; _ -> False } x <= y = case compare x y of { GT -> False; _ -> True } - x > y = case compare x y of { GT -> True; _ -> False } - x >= y = case compare x y of { LT -> False; _ -> True } + x >= y = y <= x + x > y = not (x <= y) + x < y = not (y <= x) + -- These two default methods use '<=' rather than 'compare' -- because the latter is often more expensive View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31a8989a1d4aa5fe1e3ed0b2e789145bb64a8ba8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31a8989a1d4aa5fe1e3ed0b2e789145bb64a8ba8 You're receiving 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 Sep 1 16:02:09 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Sep 2022 12:02:09 -0400 Subject: [Git][ghc/ghc][master] Fix bootstrap with ghc-9.0 Message-ID: <6310d7811d988_2f2e5816becc681176276@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - compiler/GHC/Core/Opt/SpecConstr.hs Changes: ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {- ToDo [Oct 2013] ~~~~~~~~~~~~~~~ @@ -974,6 +975,14 @@ lookupHowBound env id = lookupVarEnv (sc_how_bound env) id scSubstId :: ScEnv -> InId -> OutExpr scSubstId env v = lookupIdSubst (sc_subst env) v + +-- Solo is only defined in base starting from ghc-9.2 +#if !(MIN_VERSION_base(4, 16, 0)) + +data Solo a = Solo a + +#endif + -- The !subst ensures that we force the selection `(sc_subst env)`, which avoids -- retaining all of `env` when we only need `subst`. The `Solo` means that the -- substitution itself is lazy, because that type is often discarded. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f527f01c8b4b61047fa87905750ee962f527e36 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f527f01c8b4b61047fa87905750ee962f527e36 You're receiving 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 Sep 2 09:55:47 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Fri, 02 Sep 2022 05:55:47 -0400 Subject: [Git][ghc/ghc][wip/js-staging] fix javascript FFI calls for read and write Message-ID: <6311d323abfef_2f2e5848878125552d@gitlab.mail> Luite Stegeman pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: add3cfd9 by Luite Stegeman at 2022-09-02T11:55:09+02:00 fix javascript FFI calls for read and write - - - - - 1 changed file: - libraries/base/System/Posix/Internals.hs Changes: ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -462,17 +462,17 @@ foreign import javascript interruptible "(($1_1,$1_2,$2,$3,$c) => { return h$bas c_interruptible_open_ :: CFilePath -> CInt -> CMode -> IO CInt foreign import javascript interruptible "(($1_1,$1_2,$2,$3,$c) => { return h$base_open($1_1,$1_2,$2,$3,$c); })" c_safe_open_ :: CFilePath -> CInt -> CMode -> IO CInt -foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$4,$c) => { return h$base_read($1,$2_1,$2_2,$3,$4,$c); })" +foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$c) => { return h$base_read($1,$2_1,$2_2,$3,$c); })" c_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize -foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$4,$c) => { return h$base_read($1,$2_1,$2_2,$3,$4,$c); })" +foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$c) => { return h$base_read($1,$2_1,$2_2,$3,$c); })" c_safe_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize foreign import javascript interruptible "(($1_1,$1_2,$2_1,$2_2,$c) => { return h$base_stat($1_1,$1_2,$2_1,$2_2,$c); })" -- fixme wrong type c_stat :: CFilePath -> Ptr CStat -> IO CInt foreign import javascript unsafe "(($1) => { return h$base_umask($1); })" c_umask :: CMode -> IO CMode -foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$4,$c) => { return h$base_write($1,$2_1,$2_2,$3,$4,$c); })" +foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$c) => { return h$base_write($1,$2_1,$2_2,$3,$c); })" c_write :: CInt -> Ptr Word8 -> CSize -> IO CSsize -foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$4,$c) => { return h$base_write($1,$2_1,$2_2,$3,$4,$c); })" +foreign import javascript interruptible "(($1,$2_1,$2_2,$3,$c) => { return h$base_write($1,$2_1,$2_2,$3,$c); })" c_safe_write :: CInt -> Ptr Word8 -> CSize -> IO CSsize foreign import javascript interruptible "(($1,$2_1,$2_2,$c) => { return h$base_ftruncate($1,$2_1,$2_2,$c); })" -- fixme COff c_ftruncate :: CInt -> FileOffset -> IO CInt View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/add3cfd9bf129cfd8eeddafc17116c3b99beb91d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/add3cfd9bf129cfd8eeddafc17116c3b99beb91d You're receiving 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 Sep 2 13:52:11 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 02 Sep 2022 09:52:11 -0400 Subject: [Git][ghc/ghc][wip/diagnostics-config] 306 commits: desugar: Look through ticks when warning about possible literal overflow Message-ID: <63120a8b22fec_2f2e5848878127897c@gitlab.mail> Matthew Pickering pushed to branch wip/diagnostics-config at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 60d66f8c by Matthew Pickering at 2022-09-02T11:53:44+01: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. - - - - - bb702c88 by Matthew Pickering at 2022-09-02T11:53:44+01: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. - - - - - e8792a47 by Matthew Pickering at 2022-09-02T11:53:44+01: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. - - - - - 51f17df4 by Matthew Pickering at 2022-09-02T11:53:44+01: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 - - - - - dc538c03 by Matthew Pickering at 2022-09-02T11:53:44+01: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 - - - - - 1ac25129 by Matthew Pickering at 2022-09-02T14:31:31+01: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. - - - - - ad7702ba by Matthew Pickering at 2022-09-02T14:35:10+01: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 - - - - - 29 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − bindisttest/ghc.mk - boot - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Dataflow/Graph.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b90cbcf003c4124cbb7abb37d45e35828aa8bca...ad7702ba9f2da6a5af56c7ed3a122d1ee27aa04b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b90cbcf003c4124cbb7abb37d45e35828aa8bca...ad7702ba9f2da6a5af56c7ed3a122d1ee27aa04b You're receiving 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 Sep 2 13:54:09 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 02 Sep 2022 09:54:09 -0400 Subject: [Git][ghc/ghc][wip/diagnostics-config] 2 commits: Allow configuration of error message printing Message-ID: <63120b01a2490_2f2e58d8b793412795d6@gitlab.mail> Matthew Pickering pushed to branch wip/diagnostics-config at Glasgow Haskell Compiler / GHC Commits: 289be036 by Matthew Pickering at 2022-09-02T14:53:48+01: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 - - - - - 5d817ea0 by Matthew Pickering at 2022-09-02T14:54:01+01: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 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Config/Diagnostic.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Types/Error.hs - compiler/GHC/Types/SourceError.hs - compiler/GHC/Utils/Error.hs - docs/users_guide/using.rst - ghc/GHCi/UI.hs - ghc/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad7702ba9f2da6a5af56c7ed3a122d1ee27aa04b...5d817ea0a9072c0f1d6d7b1f79b75448e6734742 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ad7702ba9f2da6a5af56c7ed3a122d1ee27aa04b...5d817ea0a9072c0f1d6d7b1f79b75448e6734742 You're receiving 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 Sep 2 21:42:28 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 02 Sep 2022 17:42:28 -0400 Subject: [Git][ghc/ghc][wip/T21286] 25 commits: Various Hadrian bootstrapping fixes Message-ID: <631278c4585ec_2f2e58488001303175@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - f5c76c51 by Simon Peyton Jones at 2022-09-02T22:41:01+01: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 modules * 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: Metrics: compile_time/bytes allocated -------------------------------------------------------- LargeRecord(normal) -50.2% GOOD MultiLayerModulesTH_OneShot(normal) +2.0% T10547(normal) +1.3% T12545(normal) -3.9% T13056(optasm) -8.4% GOOD T14052(ghci) +1.9% T15164(normal) -3.5% GOOD T16577(normal) -2.6% GOOD T18223(normal) -33.4% GOOD T3064(normal) +1.5% T8095(normal) +1.3% T9630(normal) 32.9% GOOD WWRec(normal) -9.8% GOOD hie002(normal) +1.8% geo. mean -1.5% I diligently investigated all these big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlesslly specialising wrappers LargeRecord, T9630 Metric Decrease: LargeRecord T13056 T15164 T16577 T18223 T9630 WWRec - - - - - 28ba1e1e by Simon Peyton Jones at 2022-09-02T22:42:37+01:00 Refactor UnfoldingSource and IfaceUnfolding - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.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/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/564b4fda0f88e768b70d44c50da692852570bdb8...28ba1e1ec695a4e7d66b22414c274cbb58f6539d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/564b4fda0f88e768b70d44c50da692852570bdb8...28ba1e1ec695a4e7d66b22414c274cbb58f6539d You're receiving 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 Sep 5 09:29:14 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 05 Sep 2022 05:29:14 -0400 Subject: [Git][ghc/ghc][wip/T21286] Refactor UnfoldingSource and IfaceUnfolding Message-ID: <6315c16a54bd7_2f2e5870d0cbe8151807b@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: cc429374 by Simon Peyton Jones at 2022-09-05T10:30:34+01:00 Refactor UnfoldingSource and IfaceUnfolding - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Make.hs - testsuite/tests/deSugar/should_compile/T19969.stderr - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/numeric/should_compile/T7116.stdout - testsuite/tests/simplCore/should_compile/OpaqueNoRebox.stderr - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc429374475d3dc9523a263ffda6018c2bdf92ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cc429374475d3dc9523a263ffda6018c2bdf92ca You're receiving 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 Sep 5 09:50:14 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 05 Sep 2022 05:50:14 -0400 Subject: [Git][ghc/ghc][wip/T21470] 23 commits: Fix typo in Any docs: stray "--" Message-ID: <6315c65684ef1_2f2e58488b41520667@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - c128682f by Simon Peyton Jones at 2022-09-05T10:51:45+01: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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - 4ecab78a by Simon Peyton Jones at 2022-09-05T10:51:45+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/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/Subst.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - config.guess - config.sub - docs/users_guide/9.6.1-notes.rst - docs/users_guide/packages.rst - ghc/GHCi/UI.hs - hadrian/src/Flavour.hs - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Development.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd3f0c275091944b9dc5ae4b2b5e5484cfd3b171...4ecab78ab29c619b91a31704f6b2f435fc9595ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd3f0c275091944b9dc5ae4b2b5e5484cfd3b171...4ecab78ab29c619b91a31704f6b2f435fc9595ea You're receiving 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 Sep 5 16:17:49 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 05 Sep 2022 12:17:49 -0400 Subject: [Git][ghc/ghc][wip/T21623] Deal with rejigConRes Message-ID: <6316212d4e4a_2f2e58488b415676c6@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 7183bcc0 by Simon Peyton Jones at 2022-09-05T17:18:53+01:00 Deal with rejigConRes Needs a Note to be written by Richard - - - - - 7 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/CallArity.hs - compiler/GHC/Data/Graph/UnVar.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Types/Var/Env.hs - testsuite/tests/typecheck/should_fail/T12102.hs Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -20,7 +20,7 @@ module GHC.Core.DataCon ( -- ** Equality specs EqSpec, mkEqSpec, eqSpecTyVar, eqSpecType, eqSpecPair, eqSpecPreds, - substEqSpec, filterEqSpec, + substEqSpec, -- ** Field labels FieldLabel(..), FieldLabelString, @@ -58,7 +58,7 @@ module GHC.Core.DataCon ( isTupleDataCon, isBoxedTupleDataCon, isUnboxedTupleDataCon, isUnboxedSumDataCon, isVanillaDataCon, isNewDataCon, classDataCon, dataConCannotMatch, - dataConUserTyVarsArePermuted, + dataConUserTyVarsArePermuted, checkDataConTyVars, isBanged, isMarkedStrict, cbvFromStrictMark, eqHsBang, isSrcStrict, isSrcUnpacked, specialPromotedDc, @@ -94,7 +94,7 @@ import GHC.Utils.Binary import GHC.Types.Unique.FM ( UniqFM ) import GHC.Types.Unique.Set import GHC.Builtin.Uniques( mkAlphaTyVarUnique ) - +import GHC.Data.Graph.UnVar -- UnVarSet and operations import GHC.Utils.Outputable import GHC.Utils.Misc @@ -796,13 +796,6 @@ substEqSpec subst (EqSpec tv ty) where tv' = getTyVar (substTyVar subst tv) --- | Filter out any 'TyVar's mentioned in an 'EqSpec'. -filterEqSpec :: [EqSpec] -> [TyVar] -> [TyVar] -filterEqSpec eq_spec - = filter not_in_eq_spec - where - not_in_eq_spec var = all (not . (== var) . eqSpecTyVar) eq_spec - instance Outputable EqSpec where ppr (EqSpec tv ty) = ppr (tv, ty) @@ -1681,14 +1674,35 @@ dataConCannotMatch tys con -- "MkId", and so 'dataConUserTyVarsArePermuted' is only called at most once -- during a data constructor's lifetime. +checkDataConTyVars :: DataCon -> Bool +-- Check that the worker and wrapper have the same set of type variables +-- See Note [DataCon user type variable binders], as well as +checkDataConTyVars dc + = mkUnVarSet (dataConUnconstrainedTyVars dc) == mkUnVarSet (dataConUserTyVars dc) + -- Worker tyvars ...should be the same set as...wrapper tyvars + +dataConUserTyVarsArePermuted :: DataCon -> Bool +-- Check whether the worker and wapper have their tpye variables in +-- the same order. If not, we need a wrapper to swizzle them. -- See Note [DataCon user type variable binders], as well as -- Note [Data con wrappers and GADT syntax] for an explanation of what -- mkDataConRep is doing with this function. -dataConUserTyVarsArePermuted :: DataCon -> Bool -dataConUserTyVarsArePermuted (MkData { dcUnivTyVars = univ_tvs - , dcExTyCoVars = ex_tvs, dcEqSpec = eq_spec - , dcUserTyVarBinders = user_tvbs }) = - (filterEqSpec eq_spec univ_tvs ++ ex_tvs) /= binderVars user_tvbs +dataConUserTyVarsArePermuted dc + = dataConUnconstrainedTyVars dc /= dataConUserTyVars dc + -- Worker tyvars Wrapper tyvars + +-- | Return the quantified variables (universal and existential) +-- that are unconstrained by dcEqSpec, in the order that the /worker/ expects +dataConUnconstrainedTyVars :: DataCon -> [TyVar] +dataConUnconstrainedTyVars (MkData { dcUnivTyVars = univ_tvs + , dcExTyCoVars = ex_tvs + , dcEqSpec = eq_spec }) + = [ univ_tv | univ_tv <- univ_tvs + , not (isConstraintLikeKind (typeKind (tyVarKind univ_tv))) + , not (univ_tv `elemUnVarSet` eq_spec_tvs) ] + ++ ex_tvs + where + eq_spec_tvs = mkUnVarSet (map eqSpecTyVar eq_spec) {- %************************************************************************ ===================================== compiler/GHC/Core/Opt/CallArity.hs ===================================== @@ -728,7 +728,7 @@ resDel :: Var -> CallArityRes -> CallArityRes resDel v (!g, !ae) = (g `delNode` v, ae `delVarEnv` v) domRes :: CallArityRes -> UnVarSet -domRes (_, ae) = varEnvDom ae +domRes (_, ae) = varEnvDomain ae -- In the result, find out the minimum arity and whether the variable is called -- at most once. ===================================== compiler/GHC/Data/Graph/UnVar.hs ===================================== @@ -16,7 +16,7 @@ equal to g, but twice as expensive and large. -} module GHC.Data.Graph.UnVar ( UnVarSet - , emptyUnVarSet, mkUnVarSet, varEnvDom, unionUnVarSet, unionUnVarSets + , emptyUnVarSet, mkUnVarSet, unionUnVarSet, unionUnVarSets , extendUnVarSet, extendUnVarSetList, delUnVarSet, delUnVarSetList , elemUnVarSet, isEmptyUnVarSet , UnVarGraph @@ -26,13 +26,13 @@ module GHC.Data.Graph.UnVar , neighbors , hasLoopAt , delNode + , domUFMUnVarSet ) where import GHC.Prelude -import GHC.Types.Id -import GHC.Types.Var.Env -import GHC.Types.Unique.FM +import GHC.Types.Unique.FM( UniqFM, ufmToSet_Directly ) +import GHC.Types.Var import GHC.Utils.Outputable import GHC.Types.Unique @@ -50,6 +50,9 @@ newtype UnVarSet = UnVarSet (S.IntSet) k :: Var -> Int k v = getKey (getUnique v) +domUFMUnVarSet :: UniqFM key elt -> UnVarSet +domUFMUnVarSet ae = UnVarSet $ ufmToSet_Directly ae + emptyUnVarSet :: UnVarSet emptyUnVarSet = UnVarSet S.empty @@ -75,9 +78,6 @@ sizeUnVarSet (UnVarSet s) = S.size s mkUnVarSet :: [Var] -> UnVarSet mkUnVarSet vs = UnVarSet $ S.fromList $ map k vs -varEnvDom :: VarEnv a -> UnVarSet -varEnvDom ae = UnVarSet $ ufmToSet_Directly ae - extendUnVarSet :: Var -> UnVarSet -> UnVarSet extendUnVarSet v (UnVarSet s) = UnVarSet $ S.insert (k v) s ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -4039,13 +4039,18 @@ mkGADTVars tmpl_tvs dc_tvs subst r_ty' = mkTyVarTy r_tv1 -- Not a simple substitution: make an equality predicate - _ -> choose (t_tv':univs) (mkEqSpec t_tv' r_ty : eqs) + + _ -> choose (t_tv':univs) eqs' (extendTvSubst t_sub t_tv (mkTyVarTy t_tv')) -- We've updated the kind of t_tv, -- so add it to t_sub (#14162) r_sub t_tvs where - t_tv' = updateTyVarKind (substTy t_sub) t_tv + 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 = mkEqSpec t_tv' r_ty : eqs | otherwise = pprPanic "mkGADTVars" (ppr tmpl_tvs $$ ppr subst) @@ -4476,17 +4481,8 @@ checkValidDataCon dflags existential_ok tc con -- checked here because we sometimes build invalid DataCons before -- erroring above here ; when debugIsOn $ - do { let (univs, exs, eq_spec, _, _, _) = dataConFullSig con - user_tvs = dataConUserTyVars con - user_tvbs_invariant - = Set.fromList (filterEqSpec eq_spec univs ++ exs) - == Set.fromList user_tvs - ; massertPpr user_tvbs_invariant - $ vcat ([ ppr con - , ppr univs - , ppr exs - , ppr eq_spec - , ppr user_tvs ]) } + massertPpr (checkDataConTyVars con) $ + ppr con $$ ppr (dataConFullSig con) ; traceTc "Done validity of data con" $ vcat [ ppr con ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -80,6 +80,7 @@ import GHC.Tc.Utils.TcType as TcType import GHC.Utils.Misc import GHC.Utils.Outputable import GHC.Utils.Panic +import GHC.Utils.Trace import GHC.Utils.Panic.Plain import GHC.Data.FastString @@ -741,11 +742,11 @@ mkDataConRep dc_bang_opts fam_envs wrap_name data_con , dcr_bangs = arg_ibangs }) } where - (univ_tvs, ex_tvs, eq_spec, theta, orig_arg_tys, _orig_res_ty) + (univ_tvs, ex_tvs, eq_spec, theta, orig_arg_tys, orig_res_ty) = dataConFullSig data_con stupid_theta = dataConStupidTheta data_con wrap_tvs = dataConUserTyVars data_con - res_ty_args = substTyVars (mkTvSubstPrs (map eqSpecPair eq_spec)) univ_tvs + res_ty_args = tyConAppArgs orig_res_ty tycon = dataConTyCon data_con -- The representation TyCon (not family) wrap_ty = dataConWrapperType data_con ===================================== compiler/GHC/Types/Var/Env.hs ===================================== @@ -23,7 +23,7 @@ module GHC.Types.Var.Env ( isEmptyVarEnv, elemVarEnvByKey, filterVarEnv, restrictVarEnv, - partitionVarEnv, + partitionVarEnv, varEnvDomain, -- * Deterministic Var environments (maps) DVarEnv, DIdEnv, DTyVarEnv, @@ -82,6 +82,7 @@ import GHC.Types.Name.Occurrence import GHC.Types.Name import GHC.Types.Var as Var import GHC.Types.Var.Set +import GHC.Data.Graph.UnVar -- UnVarSet import GHC.Types.Unique.Set import GHC.Types.Unique.FM import GHC.Types.Unique.DFM @@ -504,6 +505,7 @@ extendVarEnv_Acc :: (a->b->b) -> (a->b) -> VarEnv b -> Var -> a -> VarEnv b plusVarEnv :: VarEnv a -> VarEnv a -> VarEnv a plusVarEnvList :: [VarEnv a] -> VarEnv a extendVarEnvList :: VarEnv a -> [(Var, a)] -> VarEnv a +varEnvDomain :: VarEnv elt -> UnVarSet partitionVarEnv :: (a -> Bool) -> VarEnv a -> (VarEnv a, VarEnv a) -- | Only keep variables contained in the VarSet @@ -560,7 +562,9 @@ mkVarEnv_Directly= listToUFM_Directly emptyVarEnv = emptyUFM unitVarEnv = unitUFM isEmptyVarEnv = isNullUFM -partitionVarEnv = partitionUFM +partitionVarEnv = partitionUFM +varEnvDomain = domUFMUnVarSet + restrictVarEnv env vs = filterUFM_Directly keep env where ===================================== testsuite/tests/typecheck/should_fail/T12102.hs ===================================== @@ -17,3 +17,26 @@ type family IsTypeLit a where data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where MkNat :: T 42 MkSymbol :: T "Don't panic!" + +{- Notes + +MkNat [InlPrag=CONLIKE] + :: forall {a1} {a2 :: IsTypeLit a1 ~ 'True} {b :: a1}. + (a1 ~# Natural, a2 ~# 'Eq#, b ~# 42) => + T b + +MkNat :: forall a (c :: IsTypeLit a ~ 'True) (b :: a). + (a ~# Natural, b ~# 42) -> T @a @~c b + +We don't want to include `c` at all in the constraints. +No point, and something goes wrong. + (~#) :: forall (k1 :: Type) (k2 :: Type). k1 -> k2 -> CONSTRAINT (TupleRep '[]) + +So (a ~# Natural) is short for (~#) Type Type a Natural +And (b ~# 42) is short for (~#) a Natural b 42 + +c ~# Eq# ... ==> (~#) (IsTypeLit a ~ True) ... c (Eq# ...) +and that application of (~#) is ill-kinded. + +Could generalise (~#), or have four versions of it. But let's not. +-} \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7183bcc0d725688254b508908b1003429d648fd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7183bcc0d725688254b508908b1003429d648fd3 You're receiving 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 Sep 5 17:09:35 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Sep 2022 13:09:35 -0400 Subject: [Git][ghc/ghc][wip/fix-ci] 5913 commits: Banish reportFloatingViaTvs to the shadow realm (#15831, #16181) Message-ID: <63162d4fa8889_2f2e586a3f35f815706cd@gitlab.mail> Ben Gamari pushed to branch wip/fix-ci at Glasgow Haskell Compiler / GHC Commits: 30b6f391 by Ryan Scott at 2019-07-26T00:57:02-04:00 Banish reportFloatingViaTvs to the shadow realm (#15831, #16181) GHC used to reject programs of this form: ``` newtype Age = MkAge Int deriving Eq via Const Int a ``` That's because an earlier implementation of `DerivingVia` would generate the following instance: ``` instance Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Note that the `a` in `Const Int a` is not bound anywhere, which causes all sorts of issues. I figured that no one would ever want to write code like this anyway, so I simply banned "floating" `via` type variables like `a`, checking for their presence in the aptly named `reportFloatingViaTvs` function. `reportFloatingViaTvs` ended up being implemented in a subtly incorrect way, as #15831 demonstrates. Following counsel with the sage of gold fire, I decided to abandon `reportFloatingViaTvs` entirely and opt for a different approach that would _accept_ the instance above. This is because GHC now generates this instance instead: ``` instance forall a. Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Notice that we now explicitly quantify the `a` in `instance forall a. Eq Age`, so everything is peachy scoping-wise. See `Note [Floating `via` type variables]` in `TcDeriv` for the full scoop. A pleasant benefit of this refactoring is that it made it much easier to catch the problem observed in #16181, so this patch fixes that issue too. Fixes #15831. Fixes #16181. - - - - - aae0457f by nineonine at 2019-07-26T00:57:39-04:00 Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930) - - - - - 00d9d284 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00 TemplateHaskell: reifyType (#16976) - - - - - ea08fa37 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00 reifyTypeOfThing: panic on impossible cases - - - - - 7c9fb2f0 by Adam Sandberg Eriksson at 2019-07-26T09:49:14-04:00 ghc-heap: implement WEAK closure type #16974 - - - - - 26314386 by nineonine at 2019-07-26T09:49:51-04:00 Add regression test for #16946 - - - - - cd11f81f by Fumiaki Kinoshita at 2019-07-28T19:47:50-04:00 base: add Functor, Applicative, Monad, Alternative, MonadPlus, Generic and Generic1 instances to Kleisli - - - - - c1a06d49 by Dale Wijnand at 2019-07-28T19:48:27-04:00 hadrian: relink to the flavours doc in the ghc repo - - - - - 9f8cdb35 by Richard Eisenberg at 2019-07-29T19:32:16-04:00 Add Note [RuntimeRep and PrimRep] in RepType Also adds Note [Getting from RuntimeRep to PrimRep], which deocuments a related thorny process. This Note addresses #16964, which correctly observes that documentation for this thorny design is lacking. Documentation only. - - - - - 86f47b8e by Dale Wijnand at 2019-07-29T19:32:52-04:00 hadrian: Drop a stale limitation tracking issue https://github.com/snowleopard/hadrian/issues/187 was superseded by https://github.com/snowleopard/hadrian/issues/669, which has also been closed. So, optimistically, dropping this as a limitation issue. - - - - - 9c8a211a by Andreas Klebinger at 2019-07-30T01:33:50-04:00 Expand the preallocated Int range to [-16,255] Effects as I measured them: RTS Size: +0.1% Compile times: -0.5% Runtine nofib: -1.1% Nofib runtime result seems to mostly come from the `CS` benchmark which is very sensible to alignment changes so this is likely over represented. However the compile time changes are realistic. This is related to #16961. - - - - - 2829f6da by Simon Peyton Jones at 2019-07-30T01:34:27-04:00 Apply a missing substitution in mkEtaWW (#16979) The `mkEtaWW` case for newtypes forgot to apply the substitution to the newtype coercion, resulting in the Core Lint errors observed in #16979. Easily fixed. Fixes #16979. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - 371dadfb by Ben Gamari at 2019-07-31T04:27:59-04:00 Break up TyCoRep This breaks up the monstrous TyCoReps module into several new modules by topic: * TyCoRep: Contains the `Coercion`, `Type`, and related type definitions and a few simple predicates but nothing further * TyCoPpr: Contains the the pretty-printer logic * TyCoFVs: Contains the free variable computations (and `tyConAppNeedsKindSig`, although I suspect this should change) * TyCoSubst: Contains the substitution logic for types and coercions * TyCoTidy: Contains the tidying logic for types While we are able to eliminate a good number of `SOURCE` imports (and make a few others smaller) with this change, we must introduce one new `hs-boot` file for `TyCoPpr` so that `TyCoRep` can define `Outputable` instances for the types it defines. Metric Increase: haddock.Cabal haddock.compiler - - - - - b6fa7fe3 by Ben Gamari at 2019-07-31T04:27:59-04:00 gitignore: Add .mypy_cache - - - - - 88410e77 by Ben Gamari at 2019-07-31T04:27:59-04:00 Move tyConAppNeedsKindSig to Type Previously it was awkwardly in TyCoFVs (and before that in TyCoRep). Type seems like a sensible place for it to live. - - - - - 787fab43 by Ben Gamari at 2019-07-31T04:27:59-04:00 Work around redundant import issue As mentioned in #16997, GHC currently complains about this import. In general I'm reluctant to paper over things like this but in the case of an hs-boot file I think adding an import list is the right thing to do regardless of the bug. - - - - - 5e04841c by Ben Gamari at 2019-07-31T13:53:58-04:00 gitlab-ci: Fix it after upgrade It seems that the regular expression parser changed in GitLab 12.1 and now does now support forward slashes in the RE, even when escaped. - - - - - 986643cb by Ivan Kasatenko at 2019-08-01T13:49:50-04:00 Fix T16916 CI failures (#16966) 1. Slightly increased the waiting time for the tested effect to be more profound. 2. Introduced measuring of the actual time spent waiting and adjusing CPU time by it to compensate for threadDelay waiting time inconsistencies. - - - - - 95521140 by Andreas Klebinger at 2019-08-02T08:14:10-04:00 Add StandaloneDeriving example for DerivingVia. [skip-ci] - - - - - 1b9d32b8 by Ryan Scott at 2019-08-02T08:14:47-04:00 Rip out 9-year-old pattern variable hack (#17007) GHC had an ad hoc validity check in place to rule out pattern variables bound by type synonyms, such as in the following example: ```hs type ItemColID a b = Int -- Discards a,b get :: ItemColID a b -> ItemColID a b get (x :: ItemColID a b) = x :: ItemColID a b ``` This hack is wholly unnecessary nowadays, since OutsideIn(X) is more than capable of instantiating `a` and `b` to `Any`. In light of this, let's rip out this validity check. Fixes #17007. - - - - - 93bed40a by Ryan Scott at 2019-08-02T08:15:25-04:00 Use injectiveVarsOfType to catch dodgy type family instance binders (#17008) Previously, we detected dodgy type family instances binders by expanding type synonyms (via `exactTyCoVarsOfType`) and looking for type variables on the RHS that weren't mentioned on the (expanded) LHS. But this doesn't account for type families (like the example in #17008), so we instead use `injectiveVarsOfType` to only count LHS type variables that are in injective positions. That way, the `a` in `type instance F (x :: T a) = a` will not count if `T` is a type synonym _or_ a type family. Along the way, I moved `exactTyCoVarsOfType` to `TyCoFVs` to live alongside its sibling functions that also compute free variables. Fixes #17008. - - - - - c902f56b by Krzysztof Gogolewski at 2019-08-02T08:16:03-04:00 Remove build.nix.sh This file refers to shell.nix, which was removed in 430e6fedfda and c00d2f59d. - - - - - 5e960287 by Adam Sandberg Eriksson at 2019-08-02T08:16:45-04:00 docs: fixs -prof links in rts-flags section - - - - - 0c5cd771 by Alp Mestanogullari at 2019-08-02T22:20:14-04:00 compiler: emit finer grained codegen events to eventlog - - - - - 0ecacb1e by Alp Mestanogullari at 2019-08-02T22:20:14-04:00 Add Note [withTiming] in compiler/main/ErrUtils.hs - - - - - 4664bafc by Ben Gamari at 2019-08-02T22:20:50-04:00 rts: Always truncate output files Previously there were numerous places in the RTS where we would fopen with the "w" flag string. This is wrong as it will not truncate the file. Consequently if we write less data than the previous length of the file we will leave garbage at its end. Fixes #16993. - - - - - e3cbe319 by Ben Gamari at 2019-08-02T22:21:26-04:00 Packages: Add timing for package database initialization - - - - - a5227080 by Alp Mestanogullari at 2019-08-02T22:22:06-04:00 Hadrian: make settings, platformConstants, etc dependencies of lib:ghc This fixes #17003, where a user directly asked for the 'docs-haddock' target without building a complete stage 2 GHC first. Since haddock only depends on lib:ghc, the stage 2 GHC executable wasn't built, and neither were the settings, platformConstants, llvm-passes and llvm-targets files, since they are declared to be dependencies of exe:ghc. This makes sense in general since all GHC API users (haddock is one) will likely want those files to be there. - - - - - 7e404afd by Ben Gamari at 2019-08-04T18:16:51-04:00 gitlab-ci: Manually set SPHINXBUILD on Windows For some reason configure seems unable to find it on its own. Let's try giving it a hint. Addresses #16398. - - - - - 8a061d18 by Matthew Pickering at 2019-08-04T18:17:28-04:00 Update .gitignore Add some files generated by hadrian and some tooling files - - - - - 7d8d0012 by Simon Peyton Jones at 2019-08-04T18:18:08-04:00 Don't float unlifted join points to top level Ticket #16978 showed that we were floating a recursive, unlifted join point to top level. It's very much a corner case: joinrec j :: Int# j = jump j in ... But somehow it showed up in a real program. For non-recursive bindings in SetLevels.lvlBind we were already (correctly) checking for unlifted bindings, but when I wrote that code I didn't think that a /recursive/ binding could be unlifted but /join-points/ can be! Actually I don't think that SetLevels should be floating join points at all. SetLevels really floats things to move stuff out of loops and save allocation; but none of that applies to join points. The only reason to float join points is in cases like join j1 x = join j2 y = ... in ... which we might want to swizzle to join j2 x y = ... in join j1 x = ... in ... because now j1 looks small and might be inlined away altogether. But this is a very local float perhaps better done in the simplifier. Still: this patch fixes the crash, and does so in a way that is harmless if/when we change our strategy for floating join points. - - - - - 3b31a94d by Ben Gamari at 2019-08-04T18:18:08-04:00 testsuite: Add testsuite for #16978 - - - - - 2e031806 by Ben Gamari at 2019-08-04T18:18:45-04:00 configure: Search for LLVM executables with two-number versions Fedora uses the naming llc-7.0 while Debian uses llc-7. Ensure that both are found. Fixes #16990. - - - - - 6e5dfcd2 by Ben Gamari at 2019-08-04T18:19:21-04:00 testsuite: Rework tracking of fragile tests Breaks fragile tests into two groups, allowing us to easily preserve stdout/stderr of failing fragile tests. - - - - - ea16f6cb by Simon Peyton Jones at 2019-08-06T20:24:41-04:00 Remove dead parameter from coreToStgApp - - - - - 0c1ccf3c by James Foster at 2019-08-06T20:25:18-04:00 hadrian: Refactor file patterns for future Shake changes (fixes #17005) Shake will be moving from its current implementation of ?== to one from System.FilePattern. Support for `//` is being dropped, leaving only `*` and `**` as special forms. This commit converts the existing file patterns in Hadrian to the new format. It also removes all occurances of <//> and changes the user-settings docs to remove references to // and add **. The conversion is as follows: - //a ==> **/a - a// ==> a/** - a//b ==> a/**/b - - - - - c83e39bf by Matthew Pickering at 2019-08-06T20:25:54-04:00 Remove old/broken(?) .ghci script I was attempting to load hadrian into ghci by using `cabal new-repl exe:hadrian` but it failed because it tried to use this `.ghci` configuration. I'm not sure who used this script but you should really use the new-repl method. - - - - - 6f116005 by Ömer Sinan Ağacan at 2019-08-06T20:26:32-04:00 Introduce a type for "platform word size", use it instead of Int We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config. - - - - - 2073745c by mniip at 2019-08-07T10:18:07-04:00 Add a -fprint-axiom-incomps option (#15546) Supply branch incomps when building an IfaceClosedSynFamilyTyCon `pprTyThing` now has access to incomps. This also causes them to be written out to .hi files, but that doesn't pose an issue other than a more faithful bijection between `tyThingToIfaceDecl` and `tcIfaceDecl`. The machinery for displaying axiom incomps was already present but not in use. Since this is now a thing that pops up in ghci's :info the format was modified to look like a haskell comment. Documentation and a test for the new feature included. Test Plan: T15546 Reviewers: simonpj, bgamari, goldfire Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15546 Differential Revision: https://phabricator.haskell.org/D5097 - - - - - bca79345 by mniip at 2019-08-07T10:18:07-04:00 Fix test - - - - - 3d32286d by mniip at 2019-08-07T10:18:07-04:00 Explicitly number equations when printing axiom incompatibilities - - - - - ca8efc49 by mniip at 2019-08-07T10:18:07-04:00 Fix documentation - - - - - 2c1b1ad7 by mniip at 2019-08-07T10:18:07-04:00 Fix test - - - - - 8e2fe575 by Zubin Duggal at 2019-08-07T10:18:44-04:00 Fix bug preventing information about patterns from being serialized in .hie files - - - - - f1d0e49f by Ben Gamari at 2019-08-07T10:19:21-04:00 testsuite: Add tests for #16943 - - - - - 83ca42de by Ben Gamari at 2019-08-07T10:19:21-04:00 Revert "Make scanr a good producer and consumer" This reverts commit 4e1dfc3767167dddd0e151a2df8305b12aa0f49c. Due to #16943. - - - - - 81860281 by Joachim Breitner at 2019-08-10T14:39:27-04:00 Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548) `TablesNextToCode` is now a substituted by configure, where it has the correct defaults and error handling. Nowhere else needs to duplicate that, though we may want the compiler to to guard against bogus settings files. I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to: - Help me guard against any unfixed usages - Remove any lingering connotation that this flag needs to be combined with `GhcUnreigsterised`. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 422ffce0 by Ben Gamari at 2019-08-10T14:40:03-04:00 Add timing on loadInterface AndreasK recently mentioned that he thought that interface file loading may be a non-trivial cost. Let's measure. - - - - - 0424de2d by Ömer Sinan Ağacan at 2019-08-10T14:40:46-04:00 Add test for #16893 - - - - - 672cbab2 by Ömer Sinan Ağacan at 2019-08-10T14:41:26-04:00 Reformat comments in StgSyn This does not make any changes in the contents -- formatting only. Previously the comments were too noisy and I've always found it very hard to read. Hopefully it's easier to read now. - - - - - 328a0efa by Sebastian Graf at 2019-08-13T17:30:15-04:00 Add Foldable, Traversable instances for Uniq(D)FM The `UniqDFM` is deterministic, of course, while we provide an unsafe `NonDetUniqFM` wrapper for `UniqFM` to opt into nondeterministic instances. - - - - - b1d29c67 by Tamar Christina at 2019-08-13T17:30:50-04:00 Fix binary distribution - - - - - a38104b4 by Andreas Klebinger at 2019-08-14T16:55:42-04:00 Rework the Binary Integer instance. We used to serialise large integers as strings. Now they are serialized as a list of Bytes. This changes the size for a Integer in the higher 64bit range from 77 to 9 bytes when written to disk. The impact on the general case is small (<1% for interface files) as we don't use many Integers. But for code that uses many this should be a nice benefit. - - - - - aa4d8b07 by Andreas Klebinger at 2019-08-14T16:56:20-04:00 Use os.devnull instead of '/dev/null' in the testsuite driver. The later caused issues on windows by being translated into "\\dev\\null" and python then trying to open this non-existant file. So we now use os.devnull inside python and convert it to "/dev/null" when calling out to the shell, which is bound to run in a unix like environment. This fixes an issue a test producing unexpected stderr output failed with a framework failure instead of showing a diff of the output. - - - - - 6329c70a by Richard Eisenberg at 2019-08-14T17:47:25-04:00 GHCi supports not-necessarily-lifted join points Fixes #16509. See Note [Not-necessarily-lifted join points] in ByteCodeGen, which tells the full story. This commit also adds some comments and cleans some code in the byte-code generator, as I was exploring around trying to understand it. (This commit removes an old test -- this is really a GHCi problem, not a pattern-synonym problem.) test case: ghci/scripts/T16509 - - - - - ca71d551 by James Foster at 2019-08-15T12:01:43-04:00 Remove unused imports of the form 'import foo ()' (Fixes #17065) These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies. - - - - - 95837c0f by Tobias Dammers at 2019-08-15T22:13:13-04:00 Add test cases for #16615 - - - - - 8d076841 by Tobias Dammers at 2019-08-15T22:13:13-04:00 Make add_info attach unfoldings (#16615) - - - - - 14208853 by Sylvain Henry at 2019-08-15T22:13:52-04:00 Cmm: constant folding `quotRem x 2^N` `quot` and `rem` are implemented efficiently when the second argument is a constant power of 2. This patch uses the same implementations for `quotRem` primop. - - - - - 47e16237 by Ömer Sinan Ağacan at 2019-08-15T22:14:31-04:00 Document types of LitNumbers, minor refactoring in Literal.hs - - - - - ac73c1b1 by Sylvain Henry at 2019-08-18T05:16:40-04:00 Faster exactLog2 Make `exactLog2` faster (use `countLeadingZeros` and Int32 bit-ops). On my Core i7-9700k Criterion reports ~50% speedup (from 16 to 8ns). - - - - - 1230d6f9 by Ömer Sinan Ağacan at 2019-08-18T05:17:20-04:00 Typo fix in CoreToStg - - - - - d0716279 by Ryan Scott at 2019-08-18T05:18:01-04:00 Fix #17067 by making data family type constructors actually injective `TcTyClsDecls.tcFamDecl1` was using `NotInjective` when creating data family type constructors, which is just plain wrong. This tweaks it to use `Injective` instead. Fixes #17067. - - - - - 993804bf by Sam Halliday at 2019-08-18T16:39:21-04:00 expose ModuleInfo.minf_rdr_env for tooling authors - - - - - 5b713aa3 by Ömer Sinan Ağacan at 2019-08-18T16:40:03-04:00 Fix COMPACT_NFDATA closure size, more CNF sanity checking We now do a shallow closure check on objects in compact regions. See the new comment on why we can't do a "normal" closure check. - - - - - ac7c738b by Richard Lupton at 2019-08-19T02:11:59-04:00 Generalized MonadUtils folds to Foldable (#16969) - - - - - 3a1efe1a by Richard Lupton at 2019-08-19T02:12:00-04:00 Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969) - - - - - 2a394246 by Richard Lupton at 2019-08-19T02:12:00-04:00 Use Foldable instance of Bag for specialised Bag folds (#16969) - - - - - ac79dfe9 by Richard Lupton at 2019-08-19T02:12:00-04:00 Remove Bag fold specialisations (#16969) - - - - - 5e40356f by Ben Gamari at 2019-08-19T02:12:36-04:00 gitlab-ci: Update bootstrap compiled used for Darwin builds - - - - - d5055248 by Ben Gamari at 2019-08-22T09:25:08-04:00 gitlab-ci: Add Windows full build during the nightly pipeline - - - - - a33bad2d by Sylvain Henry at 2019-08-22T09:25:47-04:00 Doc: add Haddocks for quotRemWord2 primop - - - - - 605bce26 by James Foster at 2019-08-22T18:47:20-04:00 Add documentation for Hadrian expressions This commit adds documentation on Hadrian's 'Expr' type and references the documentation in hadrian/README.md - - - - - 8f32d2bc by TDecki at 2019-08-22T18:47:57-04:00 base: Reintroduce fusion for scanr While avoiding #16943. - - - - - c3e26ab3 by Ömer Sinan Ağacan at 2019-08-22T22:19:26-04:00 Remove special case in SRT generation with -split-sections Previously we were using an empty ModuleSRTInfo for each Cmm group with -split-section. As far as I can see this has no benefits, and simplifying this makes another patch simpler (!1304). We also remove some outdated comments: we no longer generate one module-level SRT. - - - - - a8300520 by Ömer Sinan Ağacan at 2019-08-23T12:04:15+03:00 Make non-streaming LLVM and C backends streaming This adds a Stream.consume function, uses it in LLVM and C code generators, and removes the use of Stream.collect function which was used to collect streaming Cmm generation results into a list. LLVM and C backends now properly use streamed Cmm generation, instead of collecting Cmm groups into a list before generating LLVM/C code. - - - - - 47070144 by Andreas Klebinger at 2019-08-23T19:26:42-04:00 Use variable length encoding for Binary instances. Use LEB128 encoding for Int/Word variants. This reduces the size of interface files significantly. (~19%). Also includes a few small optimizations to make unboxing work better that I have noticed while looking at the core. - - - - - cff44d86 by Sergei Trofimovich at 2019-08-23T19:27:21-04:00 configure.ac: fix '--disable-dwarf-debug' Before the change ./configure --disable-dwarf-debug enabled DWARF debugging unconditionally. This happened due to use of 5-argument form of `AC_ARG_ENABLE` without actually checking the passed `$enableval` parameter: ``` AC_ARG_ENABLE(dwarf-unwind, [AC_HELP_STRING([--enable-dwarf-unwind], [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])], [AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES], [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])] [UseLibdw=NO] ) ``` Note: - `[UseLibdw=NO]` is called when `--{enable,disable}-dwarf-unwind` is not passed at all as a parameter (ok). - `[AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES],` is called for both: * `--enable-dwarf-unwind` being passed: `$enableval = "yes"` (ok). * --disable-dwarf-unwind` being passed: `$enableval = "no"` (bad). The change is to use 3-argument `AC_ARG_ENABLE` and check for passed value as `"$enable_dwarf_unwind" = "yes"`. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 10763ce0 by Ömer Sinan Ağacan at 2019-08-27T10:45:02+03:00 Some more documentation for typePrimRep1 stuff [skip ci] - - - - - 89487be2 by Ömer Sinan Ağacan at 2019-08-27T15:21:50-04:00 Some tweaks in GHC.Compact haddocks - - - - - ee2fad9e by Andreas Klebinger at 2019-08-27T15:22:28-04:00 Remove redundant OPTIONS_GHC in BlockLayout.hs - - - - - 1c7ec449 by Ömer Sinan Ağacan at 2019-08-28T12:51:12+03:00 Return results of Cmm streams in backends This generalizes code generators (outputAsm, outputLlvm, outputC, and the call site codeOutput) so that they'll return the return values of the passed Cmm streams. This allows accumulating data during Cmm generation and returning it to the call site in HscMain. Previously the Cmm streams were assumed to return (), so the code generators returned () as well. This change is required by !1304 and !1530. Skipping CI as this was tested before and I only updated the commit message. [skip ci] - - - - - a308b435 by Sebastian Graf at 2019-08-28T11:33:49-04:00 Fix #17112 The `mkOneConFull` function of the pattern match checker used to try to guess the type arguments of the data type's type constructor by looking at the ambient type of the match. This doesn't work well for Pattern Synonyms, where the result type isn't even necessarily a TyCon application, and it shows in #11336 and #17112. Also the effort seems futile; why try to try hard when the type checker has already done the hard lifting? After this patch, we instead supply the type constructors arguments as an argument to the function and lean on the type-annotated AST. - - - - - 137c24e1 by Ryan Scott at 2019-08-28T22:36:40-04:00 Balance parentheses in GHC 8.10.1 release notes [ci skip] - - - - - 66282ba5 by luca at 2019-08-28T22:37:19-04:00 Remove Unused flag -ddump-shape [skip ci] - - - - - bf9dfe1c by Ömer Sinan Ağacan at 2019-08-29T04:28:35-04:00 Fix LLVM version check yet again There were two problems with LLVM version checking: - The parser would only parse x and x.y formatted versions. E.g. 1.2.3 would be rejected. - The version check was too strict and would reject x.y formatted versions. E.g. when we support version 7 it'd reject 7.0 ("LLVM version 7.0") and only accept 7 ("LLVM version 7"). We now parse versions with arbitrarily deep minor numbering (x.y.z.t...) and accept versions as long as the major version matches the supported version (e.g. 7.1, 7.1.2, 7.1.2.3 ...). - - - - - fc746e98 by Ben Gamari at 2019-08-29T04:29:13-04:00 gitlab-ci: Fix URL of Darwin's cabal-install tarball This was inadvertently referring to the cabal-install-latest/ directory which is volatile. - - - - - 304067a0 by Ömer Sinan Ağacan at 2019-08-29T09:38:25-04:00 Small optimization in the SRT algorithm Noticed by @simonmar in !1362: If the srtEntry is Nothing, then it should be safe to omit references to this SRT from other SRTs, even if it is a static function. When updating SRT map we don't omit references to static functions (see Note [Invalid optimisation: shortcutting]), but there's no reason to add an SRT entry for a static function if the function is not CAFFY. (Previously we'd add SRT entries for static functions even when they're not CAFFY) Using 9151b99e I checked sizes of all SRTs when building GHC and containers: - GHC: 583736 (HEAD), 581695 (this patch). 2041 less SRT entries. - containers: 2457 (HEAD), 2381 (this patch). 76 less SRT entries. - - - - - 78afc2c9 by Sergei Trofimovich at 2019-08-30T06:14:44-04:00 configure.ac: add --enable-numa switch Before the change ./configure detected numa support automatically withoun a nice way to disable autodetection. The change adds `--enable-numa` / `--disable-numa` switch to override the default. If `--enable-numa` is passed and `libnuma` is not present then configure will fail. Reported-by: Sergey Alirzaev Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/955 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c0956c14 by Vladislav Zavialov at 2019-08-30T06:15:21-04:00 Remove HsUtils/userHsLTyVarBndrs This patch removes 'userHsLTyVarBndrs' and 'userHsTyVarBndrs' from HsUtils. These helper functions were not used anywhere. - - - - - 7e6aeb13 by Eric Wolf at 2019-08-31T10:25:39+02:00 Add additional step to T16804 Add another small test step Use the same identifier name in different scopes and see, if ':uses' handles that. Add another test step to check wether local bindings with the same identifier name might get confused Add easier to understand test output Fix annotated lines from file correctly - - - - - e56251f6 by Ömer Sinan Ağacan at 2019-08-31T17:55:13-04:00 Remove redundant special case in STG pretty-printer This special case existed for no reason, and made things inconsistent. Before Boolean.$bT :: Boolean.Boolean [GblId, Str=m, Unf=OtherCon []] = CAF_ccs \ u [] Boolean.$bT1; After Boolean.$bF :: Boolean.Boolean [GblId, Str=m, Unf=OtherCon []] = \u [] Boolean.$bF1; The cost-centre is now hidden when not profiling, as is the case with other types of closures. - - - - - cfab4abe by Gershom Bazerman at 2019-09-01T00:34:05-04:00 cap max stack size at 32 bit limit (#17019) - - - - - 9acba780 by John Ericson at 2019-09-01T22:44:45-04:00 Use C99 Fixed width types to avoid hack in base's configure Define MD5Context in terms of `uint*_t` and don't use `HsFFI.h`. - - - - - 11679e5b by Ömer Sinan Ağacan at 2019-09-02T13:17:49+03:00 Few tweaks in -ddump-debug output, minor refactoring - Fixes crazy indentation in -ddump-debug output - We no longer dump empty sections in -ddump-debug when a code block does not have any generated debug info - Minor refactoring in Debug.hs and AsmCodeGen.hs - - - - - f96d57b8 by John Ericson at 2019-09-05T18:50:19-04:00 Make the C-- O and C types constructors with DataKinds The tightens up the kinds a bit. I use type synnonyms to avoid adding promotion ticks everywhere. - - - - - b55ee979 by John Ericson at 2019-09-05T18:50:56-04:00 Make sure all boolean settings entries use `YES` / `NO` Some where using `True` / `False`, a legacy of when they were in `Config.hs`. See #16914 / d238d3062a9858 for a similar problem. Also clean up the configure variables names for consistency and clarity while we're at it. "Target" makes clear we are talking about outputted code, not where GHC itself runs. - - - - - 821bece9 by Ömer Sinan Ağacan at 2019-09-07T04:50:21-04:00 Minor refactoring in deriveConstants Mainly we now generate this data PlatformConstants = PlatformConstants { pc_CONTROL_GROUP_CONST_291 :: Int, pc_STD_HDR_SIZE :: Int, pc_PROF_HDR_SIZE :: Int, pc_BLOCK_SIZE :: Int, } instead of data PlatformConstants = PlatformConstants { pc_platformConstants :: () , pc_CONTROL_GROUP_CONST_291 :: Int , pc_STD_HDR_SIZE :: Int , pc_PROF_HDR_SIZE :: Int , pc_BLOCK_SIZE :: Int ... } The first field has no use and according to (removed) comments it was to make code generator's work easier.. if anything this version is simpler because it has less repetition (the commas in strings are gone). - - - - - b0fdd7fe by Alp Mestanogullari at 2019-09-07T04:50:59-04:00 hadrian: fix _build/ghc-stage1 to make it callable from any directory - - - - - 51379b89 by Ömer Sinan Ağacan at 2019-09-08T21:40:32-04:00 Add a new flag -dno-typeable-binds for debugging See the user manual entry -- this helps when debugging as generated Core gets smaller without these bindings. - - - - - d0b45ac6 by Moritz Kiefer at 2019-09-08T21:41:12-04:00 Fix GHC version guard for Int32Rep/Word32Rep Those constructors have been added after GHC 8.8. The version guards in `binary` are correct, see https://github.com/kolmodin/binary/pull/167/files. - - - - - 4cf91d1a by Daniel Gröber at 2019-09-09T05:42:33-04:00 Use lazyness for FastString's z-encoding memoization Having an IORef in FastString to memoize the z-encoded version is unecessary because there is this amazing thing Haskell can do natively, it's called "lazyness" :) We simply remove the UNPACK and strictness annotations from the constructor field corresponding to the z-encoding, making it lazy, and store the (pure) z-encoded string there. The only complication here is 'hasZEncoding' which allows cheking if a z-encoding was computed for a given string. Since this is only used for compiler performance statistics though it's not actually necessary to have the current per-string granularity. Instead I add a global IORef counter to the FastStringTable and use unsafePerformIO to increment the counter whenever a lazy z-encoding is forced. - - - - - f5e2fde4 by Daniel Gröber at 2019-09-09T05:42:33-04:00 Update FastString docstrings 1) FastStrings are always UTF-8 encoded now. 2) Clarify what is meant by "hashed" 3) Add mention of lazy z-enc - - - - - 270fbe85 by Ryan Scott at 2019-09-09T05:43:12-04:00 Replace queryCygwinTerminal with Win32's isMinTTYHandle `SysTools.Terminal.queryCygwinTerminal` now exists in the `Win32` library under the name `isMinTTYHandle` since `Win32-2.5.0.0`. (GHC 8.4.4 ships with `Win32-2.6.1.0`, so this is well within GHC's support window.) We can therefore get replace `queryCygwinTerminal` with `isMinTTYHandle` and delete quite a bit of code from `SysTools.Terminal` in the process. Along the way I needed to replace some uses of `#if defined x` with `#if defined(x)` to please the CI linters. - - - - - 447864a9 by Sylvain Henry at 2019-09-10T00:04:50+02:00 Module hierarchy: StgToCmm (#13009) Add StgToCmm module hierarchy. Platform modules that are used in several other places (NCG, LLVM codegen, Cmm transformations) are put into GHC.Platform. - - - - - 60c26403 by Niklas Hambüchen at 2019-09-11T09:44:23-04:00 linker: Move -optl flags to end of linker invocation. Until now, giving `-optl` linker flags to `ghc` on the command line placed them in the wrong place in the `ld` command line: They were given before all the Haskell libararies, when they should appear after. Background: Most linkers like `ld.bfd` and `ld.gold`, but not the newer LLVM `lld`, work in a way where the order of `-l` flags given matters; earlier `-lmylib1` flags are supposed to create "holes" for linker symbols that are to be filled with later `lmylib2` flags that "fill the holes" for these symbols. As discovered in https://github.com/haskell/cabal/pull/5451#issuecomment-518001240, the `-optl` flags appeared before e.g. the -lHStext-1.2.3.1 -lHSbinary-0.8.6.0 -lHScontainers-0.6.0.1 flags that GHC added at the very end. Haskell libraries typically depend on C libraries, so `-lHS*` flags will create holes for the C libraries to fill in, but that only works when those libraries' `-l` flags are given **after** the `-lHS*` flags; until now they were given before, which was wrong. This meant that Cabal's `--ld-options` flag and `ld-options` `.cabal` file field were pretty ineffective, unless you used the `--ld-option=--start-group` hack as (https://github.com/haskell/cabal/pull/5451#issuecomment-406761676) that convinces the classical linkers to not be dependent on the order of linker flags given. This commit fixes the problem by simply flipping the order, putting `-optl` flags at the end, after Haskell libraries. The code change is effectively only `args1 ++ args` -> `args ++ args1` but the commit also renames the variables for improved clarity. Simple way to test it: ghc --make Main.hs -fforce-recomp -v -optl-s on a `Main.hs` like: import qualified Data.Set as Set main = print $ Set.fromList "hello" - - - - - 7032a913 by John Ericson at 2019-09-11T09:45:02-04:00 Remove COMPILING_GHC It is no longer used. I guess we are sharing fewer headers with the RTS than the comment claims. That's a relief! - - - - - 58569a5b by Peter Trommler at 2019-09-11T09:45:47-04:00 testsuite: check for RTS linker Fixes #16833 - - - - - df6fbe03 by Luke Lau at 2019-09-11T09:46:36-04:00 Bump Hadrian's QuickCheck dependency - - - - - d9e637df by John Ericson at 2019-09-11T09:47:26-04:00 Remove dead `ncgDebugIsOn` and `NCG_DEBUG` Haven't been used since 16206a6603e87e15d61c57456267c5f7ba68050e. - - - - - 7ef6fe8f by Ben Gamari at 2019-09-11T09:48:03-04:00 SetLevels: Fix potential panic in lvlBind 3b31a94d introduced a use of isUnliftedType which can panic in the case of levity-polymorphic types. Fix this by introducing mightBeUnliftedType which returns whether the type is *guaranteed* to be lifted. - - - - - c76cc0c6 by Ömer Sinan Ağacan at 2019-09-11T19:40:06-04:00 Refactor bad coercion checking in a few places We do bad coercion checking in a few places in the compiler, but they all checked it differently: - CoreToStg.coreToStgArgs: Disallowed lifted-to-unlifted, disallowed changing prim reps even when the sizes are the same. - StgCmmExpr.cgCase: Checked primRepSlot equality. This disallowed Int to Int64 coercions on 64-bit systems (and Int to Int32 on 32-bit) even though those are fine. - CoreLint: Only place where we do this right. Full rules are explained in Note [Bad unsafe coercion]. This patch implements the check explained in Note [Bad unsafe coercion] in CoreLint and uses it in CoreToStg.coreToStgArgs and StgCmmExpr.cgCase. This fixes #16952 and unblocks !1381 (which fixes #16893). This is the most conservative and correct change I came up with that fixes #16952. One remaining problem with coercion checking is that it's currently done in seemingly random places. What's special about CoreToStg.coreToStgArgs and StgCmmExpr.cgCase? My guess is that adding assertions to those places caught bugs before so we left assertions in those places. I think we should remove these assertions and do coercion checking in CoreLint and StgLint only (#17041). - - - - - 3a7d3923 by Tamar Christina at 2019-09-11T19:40:53-04:00 Windows: make openTempFile fully atomic. - - - - - 98b0d6ee by Pranay Sashank at 2019-09-12T04:52:33-04:00 Print the correct system memory in use with +RTS -s (#17158) Use `stats.max_mem_in_use_bytes` to print the memory usage instead of `stats.max_live_bytes` which prints maximum residency. Fixes (#17158). - - - - - a06629b4 by John Ericson at 2019-09-12T04:53:13-04:00 Do not throw away backpack instantiations for module lookup cache Currently, there is only one home package so this probably doesn't matter. But if we support multiple home packages, they could differ only in arguments (same indef component being applied). It looks like it used to be this way before 4e8a0607140b23561248a41aeaf837224aa6315b, but that commit doesn't seem to comment on this change in the particular. (It's main purpose is creating the InstalledUnitId and recategorizing the UnitId expressions accordingly.) Trying this as a separate commit for testing purposes. I leave it to others to decide whether this is a good change on its own. - - - - - 09fa5654 by John Ericson at 2019-09-12T04:53:51-04:00 Remove unused `#include`s from parser/cutils.c Looks like these have been unused since 7c665f9ce0980ee7c81a44c8f861686395637453. - - - - - 2b37a79d by Sebastian Graf at 2019-09-12T14:05:29-04:00 Bump Cabal submodule to 3.1 ------------------------- Metric Increase: haddock.Cabal T4029 ------------------------- - - - - - 86753475 by Ningning Xie at 2019-09-12T14:06:07-04:00 Fix StandaloneDeriving If I understand correctly, `deriving instance _ => Eq (Foo a)` is equivalent to `data Foo a deriving Eq`, rather than `data Foo a deriving Foo`. - - - - - a733002a by Ben Gamari at 2019-09-13T03:09:47-04:00 Update mailmap - - - - - 5b64aee2 by Simon Peyton Jones at 2019-09-13T03:10:26-04:00 Fix scoping of implicit parameters There was an outright bug in TcInteract.solveOneFromTheOther which meant that we did not always pick the innermost implicit parameter binding, causing #17104. The fix is easy, just a rearrangement of conditional tests - - - - - 47b12660 by Tamar Christina at 2019-09-13T03:11:06-04:00 Windows: Fix hsc2hs non-deterministic failures. - - - - - e3a7592b by Alp Mestanogullari at 2019-09-13T03:11:50-04:00 Add a test to make sure we don't regress on #17140 in the future - - - - - 6f3cd50e by Zubin Duggal at 2019-09-13T11:24:51-04:00 Explain how to update HieAst [skip ci] - - - - - 71428a43 by Zubin Duggal at 2019-09-13T11:24:51-04:00 Address review comments [skip CI] - - - - - ccb4e646 by John Ericson at 2019-09-13T11:25:29-04:00 Compiler should always get fingerprinting impl from base 07ee15915d5a0d6d1aeee137541eec6e9c153e65 started the transition, but the job was never finished. - - - - - c45c89d6 by Ben Gamari at 2019-09-13T11:26:05-04:00 gitlab: Add issue template for documentation issues Fixes #17180. - - - - - a0e220b7 by John Ericson at 2019-09-13T11:26:43-04:00 Remove empty NCG.h - - - - - 046ca133 by Andrew Martin at 2019-09-13T15:43:16-04:00 Add predicates for testing if IOError is ResourceVanished. This adds isResourceVanished, resourceVanishedErrorType, and isResourceVanishedErrorType to System.IO.Error, resolving #14730. - - - - - bd079345 by taylorfausak at 2019-09-14T06:25:27-04:00 Fix CONLIKE typo - - - - - cf7e78a3 by Ben Gamari at 2019-09-15T23:46:36-04:00 Rename GHC.StgToCmm.Con -> GHC.StgToCmm.DataCon Incredibly, Windows disallows the manipulation of any file matching Con(\..*)?. The `GHC.StgToCmm.Con` was introduced in the renamings in 447864a9, breaking the Windows build. Work around this by renaming it to `GHC.StgToCmm.DataCon` Fixes #17187. - - - - - 7208160d by Sylvain Henry at 2019-09-15T23:47:22-04:00 Fix Hadrian build with Stack (#17189) Broken by 2b37a79d61e9b3787873dc9f7458ef2bde4809b0 - - - - - b5ae3868 by Sylvain Henry at 2019-09-16T13:32:22-04:00 Allow validation with Hadrian built with Stack [skip ci] - - - - - 7915afc6 by Sebastian Graf at 2019-09-16T13:33:05-04:00 Encode shape information in `PmOracle` Previously, we had an elaborate mechanism for selecting the warnings to generate in the presence of different `COMPLETE` matching groups that, albeit finely-tuned, produced wrong results from an end user's perspective in some cases (#13363). The underlying issue is that at the point where the `ConVar` case has to commit to a particular `COMPLETE` group, there's not enough information to do so and the status quo was to just enumerate all possible complete sets nondeterministically. The `getResult` function would then pick the outcome according to metrics defined in accordance to the user's guide. But crucially, it lacked knowledge about the order in which affected clauses appear, leading to the surprising behavior in #13363. In !1010 we taught the term oracle to reason about literal values a variable can certainly not take on. This MR extends that idea to `ConLike`s and thereby fixes #13363: Instead of committing to a particular `COMPLETE` group in the `ConVar` case, we now split off the matching constructor incrementally and record the newly covered case as a refutable shape in the oracle. Whenever the set of refutable shapes covers any `COMPLETE` set, the oracle recognises vacuosity of the uncovered set. This patch goes a step further: Since at this point the information in value abstractions is merely a cut down representation of what the oracle knows, value abstractions degenerate to a single `Id`, the semantics of which is determined by the oracle state `Delta`. Value vectors become lists of `[Id]` given meaning to by a single `Delta`, value set abstractions (of which the uncovered set is an instance) correspond to a union of `Delta`s which instantiate the same `[Id]` (akin to models of formula). Fixes #11528 #13021, #13363, #13965, #14059, #14253, #14851, #15753, #17096, #17149 ------------------------- Metric Decrease: ManyAlternatives T11195 ------------------------- - - - - - ae4415b9 by Matthew Pickering at 2019-09-17T19:21:10-04:00 eventlog: Add biographical and retainer profiling traces This patch adds a new eventlog event which indicates the start of a biographical profiler sample. These are different to normal events as they also include the timestamp of when the census took place. This is because the LDV profiler only emits samples at the end of the run. Now all the different profiling modes emit consumable events to the eventlog. - - - - - 9c21b2fd by Richard Eisenberg at 2019-09-17T19:22:00-04:00 Fix #13571 by adding an extension flag check Test case: indexed-types/should_fail/T13571 - - - - - 8039b125 by Simon Peyton Jones at 2019-09-17T19:22:50-04:00 Comments only - - - - - 1c3af277 by Simon Peyton Jones at 2019-09-17T19:23:37-04:00 Improve error message for out-of-scope variables + VTA As #13834 and #17150 report, we get a TERRIBLE error message when you have an out of scope variable applied in a visible type application: (outOfScope @Int True) This very simple patch improves matters. See TcExpr Note [VTA for out-of-scope functions] - - - - - c77fc3b2 by John Ericson at 2019-09-17T19:24:20-04:00 Deduplicate `HaskellMachRegs.h` and `RtsMachRegs.h` headers Until 0472f0f6a92395d478e9644c0dbd12948518099f there was a meaningful host vs target distinction (though it wasn't used right, in genapply). After that, they did not differ in meaningful ways, so it's best to just only keep one. - - - - - c3eaaca6 by Simon Peyton Jones at 2019-09-19T09:03:19-04:00 Add a missing update of sc_hole_ty (#16312) In simplCast I totally failed to keep the sc_hole_ty field of ApplyToTy (see Note [The hole type in ApplyToTy]) up to date. When a cast goes by, of course the hole type changes. Amazingly this has not bitten us before, but #16312 finally triggered it. Fortunately the fix is simple. Fixes #16312. - - - - - de1723b2 by Ben Gamari at 2019-09-19T09:03:19-04:00 Simplify: Lazy pattern match - - - - - d9c6b86e by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Refactor kindGeneralize and friends This commit should have no change in behavior.(*) The observation was that Note [Recipe for checking a signature] says that every metavariable in a type-checked type must either (A) be generalized (B) be promoted (C) be zapped. Yet the code paths for doing these were all somewhat separate. This led to some steps being skipped. This commit shores this all up. The key innovation is TcHsType.kindGeneralizeSome, with appropriate commentary. This commit also sets the stage for #15809, by turning the WARNing about bad level-numbers in generalisation into an ASSERTion. The actual fix for #15809 will be in a separate commit. Other changes: * zonkPromoteType is now replaced by kindGeneralizeNone. This might have a small performance degradation, because zonkPromoteType zonked and promoted all at once. The new code path promotes first, and then zonks. * A call to kindGeneralizeNone was added in tcHsPartialSigType. I think this was a lurking bug, because it did not follow Note [Recipe for checking a signature]. I did not try to come up with an example showing the bug. This is the (*) above. Because of this change, there is an error message regression in partial-sigs/should_fail/T14040a. This problem isn't really a direct result of this refactoring, but is a symptom of something deeper. See #16775, which addresses the deeper problem. * I added a short-cut to quantifyTyVars, in case there's nothing to quantify. * There was a horribly-outdated Note that wasn't referred to. Gone now. * While poking around with T14040a, I discovered a small mistake in the Coercion.simplifyArgsWorker. Easy to fix, happily. * See new Note [Free vars in coercion hole] in TcMType. Previously, we were doing the wrong thing when looking at a coercion hole in the gather-candidates algorithm. Fixed now, with lengthy explanation. Metric Decrease: T14683 - - - - - f594a68a by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Use level numbers for generalisation This fixes #15809, and is covered in Note [Use level numbers for quantification] in TcMType. This patch removes the "global tyvars" from the environment, a nice little win. - - - - - c675d08f by Richard Eisenberg at 2019-09-19T09:04:03-04:00 Test #17077. - - - - - 912afaf4 by Ben Gamari at 2019-09-19T09:04:39-04:00 CoreUtils: Use mightBeUnliftedType in exprIsTopLevelBindable Also add reference from isUnliftedType to mightBeUnliftedType. - - - - - baf47661 by Sebastian Graf at 2019-09-19T09:05:20-04:00 Extract PmTypes module from PmExpr and PmOracle Apparently ghc-lib-parser's API blew up because the newly induced cyclic dependency between TcRnTypes and PmOracle pulled in the other half of GHC into the relevant strongly-connected component. This patch arranges it so that PmTypes exposes mostly data type definitions and type class instances to be used within PmOracle, without importing the any of the possibly offending modules DsMonad, TcSimplify and FamInst. - - - - - 2a8867cf by Sebastian Graf at 2019-09-19T09:05:58-04:00 Add a regression test for #11822 The particular test is already fixed, but the issue seems to have multiple different test cases lumped together. - - - - - 52173990 by Ben Gamari at 2019-09-19T09:06:36-04:00 testsuite: Add testcase for #17206 - - - - - b3e5c731 by Alp Mestanogullari at 2019-09-19T21:42:17-04:00 ErrUtils: split withTiming into withTiming and withTimingSilent 'withTiming' becomes a function that, when passed '-vN' (N >= 2) or '-ddump-timings', will print timing (and possibly allocations) related information. When additionally built with '-eventlog' and executed with '+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent' events to the eventlog. 'withTimingSilent' on the other hand will never print any timing information, under any circumstance, and will only emit 'traceEvent' events to the eventlog. As pointed out in !1672, 'traceMarker' is better suited for things that we might want to visualize in tools like eventlog2html, while 'traceEvent' is better suited for internal events that occur a lot more often and that we don't necessarily want to visualize. This addresses #17138 by using 'withTimingSilent' for all the codegen bits that are expressed as a bunch of small computations over streams of codegen ASTs. - - - - - 4853d962 by Ben Gamari at 2019-09-19T21:42:55-04:00 users guide: Fix link to let generalization blog post Fixes #17200. - - - - - 51192964 by Sylvain Henry at 2019-09-20T05:14:34-04:00 Module hierarchy: Hs (#13009) Add GHC.Hs module hierarchy replacing hsSyn. Metric Increase: haddock.compiler - - - - - 2f8ce45a by Ben Gamari at 2019-09-20T05:15:11-04:00 testsuite: Add test for #17202 - - - - - f257bf73 by Matthew Pickering at 2019-09-20T05:15:52-04:00 hadrian/ghci.sh: Enable building in parallel - - - - - 070f7b85 by Matthew Pickering at 2019-09-20T05:15:52-04:00 Remove trailing whitespace - - - - - 5390b553 by Matthew Pickering at 2019-09-20T05:15:52-04:00 Pass -j to ghc-in-ghci CI job - - - - - 1b7e1d31 by John Ericson at 2019-09-20T05:16:36-04:00 Remove pointless partiality in `Parser.ajs` - - - - - 17554248 by Simon Peyton Jones at 2019-09-20T10:50:21+01:00 Fix PmOracle.addVarCoreCt in-scope set PmOracle.addVarCoreCt was giving a bogus (empty) in-scope set to exprIsConApp_maybe, which resulted in a substitution-invariant failure (see MR !1647 discussion). This patch fixes it, by taking the free vars of the expression. - - - - - 0dad81ca by Simon Peyton Jones at 2019-09-20T10:50:21+01:00 Fix bogus type of case expression Issue #17056 revealed that we were sometimes building a case expression whose type field (in the Case constructor) was bogus. Consider a phantom type synonym type S a = Int and we want to form the case expression case x of K (a::*) -> (e :: S a) We must not make the type field of the Case constructor be (S a) because 'a' isn't in scope. We must instead expand the synonym. Changes in this patch: * Expand synonyms in the new function CoreUtils.mkSingleAltCase. * Use mkSingleAltCase in MkCore.wrapFloat, which was the proximate source of the bug (when called by exprIsConApp_maybe) * Use mkSingleAltCase elsewhere * Documentation CoreSyn new invariant (6) in Note [Case expression invariants] CoreSyn Note [Why does Case have a 'Type' field?] CoreUtils Note [Care with the type of a case expression] * I improved Core Lint's error reporting, which was pretty confusing in this case, because it didn't mention that the offending type was the return type of a case expression. * A little bit of cosmetic refactoring in CoreUtils - - - - - 1ea8c451 by Sebastian Graf at 2019-09-21T09:52:34-04:00 PredType for type constraints in the pattern match checker instead of EvVar Using EvVars for capturing type constraints implied side-effects in DsM when we just wanted to *construct* type constraints. But giving names to type constraints is only necessary when passing Givens to the type checker, of which the majority of the pattern match checker should be unaware. Thus, we simply generate `newtype TyCt = TyCt PredType`, which are nicely stateless. But at the same time this means we have to allocate EvVars when we want to query the type oracle! So we keep the type oracle state as `newtype TyState = TySt (Bag EvVar)`, which nicely makes a distinction between new, unchecked `TyCt`s and the inert set in `TyState`. - - - - - ded96fb3 by Ömer Sinan Ağacan at 2019-09-21T09:53:29-04:00 Document MIN_PAYLOAD_SIZE and mark-compact GC mark bits This updates the documentation of the MIN_PAYLOAD_SIZE constant and adds a new Note [Mark bits in mark-compact collector] explaning why the mark-compact collector uses two bits per objet and why we need MIN_PAYLOAD_SIZE. - - - - - a7867c79 by Sebastian Graf at 2019-09-21T14:56:58+01:00 Get rid of PmFake The pattern match oracle can now cope with the abundance of information that ViewPatterns, NPlusKPats, overloaded lists, etc. provide. No need to have PmFake anymore! Also got rid of a spurious call to `allCompleteMatches`, which we used to call *for every constructor* match. Naturally this blows up quadratically for programs like `ManyAlternatives`. ------------------------- Metric Decrease: ManyAlternatives Metric Increase: T11822 ------------------------- - - - - - fa66e3e5 by Alp Mestanogullari at 2019-09-21T23:31:08-04:00 Fix haddocks for marker events in Debug.Trace - - - - - da12da79 by Daniel Gröber at 2019-09-22T14:34:56+02:00 rts: retainer: Remove cStackSize debug counter This can only ever be one since 5f1d949ab9 ("Remove explicit recursion in retainer profiling"), so it's pointless. - - - - - 3ebaa4b5 by Daniel Gröber at 2019-09-22T15:17:53+02:00 rts: Remove bitrotten retainer debug code The `defined(DEBUG_RETAINER) == true` branch doesn't even compile anymore because 1) retainerSet was renamed to RetainerSet and 2) even if I fix that the context in Rts.h seems to have changed such that it's not in scope. If 3) I fix that 'flip' is still not in scope :) At that point I just gave up. - - - - - 63023dc2 by Daniel Gröber at 2019-09-22T15:18:09+02:00 rts: Fix outdated references to 'ldvTime' This got renamed to 'era' in dbef766ce7 ("[project @ 2001-11-26 16:54:21 by simonmar] Profiling cleanup"). - - - - - ead05f80 by Daniel Gröber at 2019-09-22T15:18:09+02:00 rts: retainer: Turn global traversal state into a struct Global state is ugly and hard to test. Since the profiling code isn't quite as performance critical as, say, GC we should prefer better code here. I would like to move the 'flip' bit into the struct too but that's complicated by the fact that the defines which use it directly are also called from ProfHeap where the traversalState is not easily available. Maybe in a future commit. - - - - - 94ecdb4f by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move info.next.parent to stackElement I don't see a point in having this live in 'info', just seems to make the code more complicated. - - - - - f79ac2ef by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Generalise per-stackElement data This essentially ammounts to s/retainer/stackData/, s/c_child_r/data/ and some temporary casting of c_child_r to stackData until refactoring of this module is completed by a subsequent commit. We also introduce a new union 'stackData' which will contain the actual extra data to be stored on the stack. The idea is to make the heap traversal logic of the retainer profiler ready for extraction into it's own module. So talking about "retainers" there doesn't really make sense anymore. Essentially the "retainers" we store in the stack are just data associated with the push()ed closures which we return when pop()ing it. - - - - - f083358b by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Fix comment typo s/keeps/keep/ - - - - - 2f2f6dd5 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Generalise profiling heap traversal flip bit handling This commit starts renaming some flip bit related functions for the generalised heap traversal code and adds provitions for sharing the per-closure profiling header field currently used exclusively for retainer profiling with other heap traversal profiling modes. - - - - - e40b3c23 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: GC: Remove redundant #include "RetainerProfiler.h" - - - - - b03db9da by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Pull retainer specific code into a callback This essentially turns the heap traversal code into a visitor. You add a bunch of roots to the work-stack and then the callback you give to traverseWorkStack() will be called with every reachable closure at least once. - - - - - 48e816f0 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: simplify pop() control flow Instead of breaking out of the switch-in-while construct using `return` this uses `goto out` which makes it possible to share a lot of the out-variable assignment code in all the cases. I also replaced the nasty `while(true)` business by the real loop condition: `while(*c == NULL)`. All `break` calls inside the switch aready have either a check for NULL or an assignment of `c` to NULL so this should not change any behaviour. Using `goto out` also allowed me to remove another minor wart: In the MVAR_*/WEAK cases the popOff() call used to happen before reading the stackElement. This looked like a use-after-free hazard to me as the stack is allocated in blocks and depletion of a block could mean it getting freed and possibly overwritten by zero or garbage, depending on the block allocator's behaviour. - - - - - b92ed68a by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Add note reference to SET_PROF_HDR for profiling 'flip' bit - - - - - f3bb7397 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerSet: Remove obsolete fist/second-approach choice In the old code when DEBUG_RETAINER was set, FIRST_APPROACH is implied. However ProfHeap.c now depends on printRetainerSetShort which is only available with SECOND_APPROACH. This is because with FIRST_APPROACH retainerProfile() will free all retainer sets before returning so by the time ProfHeap calls dumpCensus the retainer set pointers are segfaulty. Since all of this debugging code obviously hasn't been compiled in ages anyways I'm taking the liberty of just removing it. Remember guys: Dead code is a liability not an asset :) - - - - - ec1d76e2 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove obsolete debug code Commit dbef766ce7 ("Profiling cleanup.") made this debug code obsolete by removing the 'cost' function without a replacement. As best I can tell the retainer profiler used to do some heap census too and this debug code was mainly concerned with that. - - - - - b7e15d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Rename heap traversal functions for extraction This gets all remaining functions in-line with the new 'traverse' prefix and module name. - - - - - 64ec45a7 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Reduce DEBUG_RETAINER ifdef noise Keeping track of the maximum stack seems like a good idea in all configurations. The associated ASSERTs only materialize in debug mode but having the statistic is nice. To make the debug code less prone to bitrotting I introduce a function 'debug()' which doesn't actually print by default and is #define'd away only when the standard DEBUG define is off. - - - - - bd78b696 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Cleanup comments and strings for traversal extraction A lot of comments and strings are still talking about old names, fix that. - - - - - cb7220b3 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove outdated invariants on traversePushStack These invariants don't seem to make any sense in the current code. The text talks about c_child_r as if it were an StgClosure, for which RSET() would make sense, but it's a retainer aka 'CostCentreStack*'. - - - - - bb92660c by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Use global STATIC_INLINE macro STATIC_INLINE already does what the code wanted here, no need to duplicate the functionality here. - - - - - 2b76cf9e by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move heap traversal declarations to new header - - - - - 44d5cc0d by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Abstract maxStackSize for generic traversal - - - - - fd213d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Update obsolete docs for traverseMaybeInitClosureData - - - - - 39f2878c by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move actual 'flip' bit flip to generic traversal code - - - - - f9b4c4f2 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Remove traverse-stack chunk support There's simply no need anymore for this whole business. Instead of individually traversing roots in retainRoot() we just push them all onto the stack and traverse everything in one go. This feature was not really used anyways. There is an `ASSERT(isEmptyWorkStack(ts))` at the top of retainRoot() which means there really can't ever have been any chunks at the toplevel. The only place where this was probably used is in traversePushStack but only way back when we were still using explicit recursion on the C callstack. Since the code was changed to use an explicit traversal-stack these stack-chunks can never escape one call to traversePushStack anymore. See commit 5f1d949ab9 ("Remove explicit recursion in retainer profiling") - - - - - c7def600 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Move mut_list reset to generic traversal code - - - - - 9bf27060 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Make visit callback easier to implement Currently it is necessary for user code to expend at least one extra bit in the closure header just to know whether visit() should return true or false, to indicate if children should be traversed. The generic traversal code already has this information in the visited bit so simply pass it to the visit callback. - - - - - 96adf179 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: retainer: Improve Note [Profiling heap traversal visited bit] - - - - - 187192a6 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile.c: Re-enable and fix warnings Turns out some genius disabled warnings for RetainerProfile.c in the build system. That would have been good to know about five silent type mismatch crashes ago.. :) - - - - - eb29735e by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile.c: Minimize #includes A lot of these includes are presumably leftovers from when the retainer profiler still did it's own heap profiling. - - - - - 383f9089 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: Split heap traversal from retainer profiler This finally moves the newly generalised heap traversal code from the retainer profiler into it's own file. - - - - - 52c5ea71 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Make comment style consistent - - - - - 75355228 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Make pushStackElement argument const - - - - - a8137780 by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: TraverseHeap: Move stackElement.cp back into nextPos union The 'cp' field really is only used when type==posTypeFresh so it's more space efficient to have it in the nextPos union. - - - - - 7f10cc2d by Daniel Gröber at 2019-09-22T15:18:10+02:00 rts: RetainerProfile: Explain retainVisitClosure return values [ci skip] - - - - - 111f2761 by Daniel Gröber at 2019-09-22T15:33:41+02:00 rts: TraverseHeap: Add doc comment for getTraverseStackMaxSize - - - - - 68ddb43c by Ben Gamari at 2019-09-23T00:34:00-04:00 gitlab-ci: Fix URL of Windows cabal-install tarball - - - - - 0e478407 by Takenobu Tani at 2019-09-23T17:51:37-04:00 users-guide: Fix links and formats for GHC 8.10 This commit only fixes links and markdown syntax. [skip ci] - - - - - 74631bbc by Adam Sandberg Eriksson at 2019-09-23T17:52:32-04:00 base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568 Metric Increase: haddock.base T4029 - - - - - 4470a144 by Björn Gohla at 2019-09-23T17:53:23-04:00 add Hadrian rule to build user guide as Info book - - - - - dbbea5a8 by Björn Gohla at 2019-09-23T17:53:23-04:00 use the Make builder instead of raw cmd_ - - - - - b0e3b173 by Björn Gohla at 2019-09-23T17:53:23-04:00 detect makeinfo in configure(.ac) - - - - - 9fe4d2df by Björn Gohla at 2019-09-23T17:53:23-04:00 explicit dependence on makeinfo - - - - - b650c2b6 by Björn Gohla at 2019-09-23T17:53:23-04:00 alphabetical ordering - - - - - 27789294 by Björn Gohla at 2019-09-23T17:53:23-04:00 sort-paragraphs in runBuilderWith - - - - - d0c2f3a2 by Artem Pyanykh at 2019-09-23T17:54:04-04:00 [hadrian] Rebuild programs on dynamicGhcPrograms/ghcProfiled change Currently, if you change these ^ flavour parameters, rebuilding is not triggered, since `programContext` doesn't set up a dependency on those values. Exposing these values via an oracle does set the dependency and properly triggers a rebuild of binaries. Several attempts to factor out these actions ended up in cyclic dependency here or there. I'm not absolutely happy with this variant either, but at least it works. ==== Issue repro: In UserSettings.hs: ``` dbgDynamic = defaultFlavour { name = "dbg-dynamic" , dynamicGhcPrograms = pure True, ... } dbgStatic = defaultFlavour { name = "dbg-static" , dynamicGhcPrograms = pure False ... } ``` Then in console: ``` $ hadrian/build.sh -j --flavour=dbg-dynamic ... does the build $ hadrian/build.sh -j --flavour=dbg-static ... does nothing, considers binaries up to date ``` - - - - - 238b58e4 by Kari Pahula at 2019-09-23T17:54:42-04:00 Add -fkeep-going to make compiler continue despite errors (#15424) Add a new optional failure handling for upsweep which continues the compilation on other modules if any of them has errors. - - - - - 146f26cc by Sebastian Graf at 2019-09-24T01:06:40-04:00 Some leftovers from !1732. Comments only [skip ci] - - - - - b5f24fb4 by Takenobu Tani at 2019-09-24T01:07:19-04:00 Hadrian: Add -haddock option for GHCi's :doc command This commit adds -haddock option to Hadrian-based build system. To enable :doc command on GHCi, core libraries must be compiled with -haddock option. Especially, the `-haddock` option is essential for a release build. Assuming current GitLab CI condition (.gitlab-ci.yml), I add -haddock option to the default flavour only. This has already been done for Make-based build system. Please see #16415. - - - - - f97a7aac by Sebastian Graf at 2019-09-24T01:07:57-04:00 Fix some duplication in the parser D3673 experienced reduce/reduce conflicts when trying to use opt_instance for associated data families. That was probably because the author tried to use it for Haskell98-syntax without also applying it to GADT-syntax, which actually leads to a reduce/reduce conflict. Consider the following state: ``` data . T = T data . T where T :: T ``` The parser must decide at this point whether or not to reduce an empty `opt_instance`. But doing so would also commit to either Haskell98 or GADT syntax! Good thing we also accept an optional "instance" for GADT syntax, so the `opt_instance` is there in both productions and there's no reduce/reduce conflict anymore. Also no need to inline `opt_instance`, how it used to be. - - - - - b23f01fd by Ben Gamari at 2019-09-24T08:49:43-04:00 base: Add link to "A reflection on types" Fixes #17181. - - - - - 4bbe0dba by Ben Gamari at 2019-09-24T08:50:20-04:00 gitlab-ci: Bump ci-images This bumps the CI Docker images to ghc/ci-images at 990c5217d1d0e03aea415f951afbc3b1a89240c6. - - - - - 6bca867c by Ben Gamari at 2019-09-24T08:50:59-04:00 hadrian: Update source-repository - - - - - b2d47536 by Ben Gamari at 2019-09-24T08:51:45-04:00 testsuite: Mark threadstatus-9333 as fragile in profthreaded Due to #16555. - - - - - ed520678 by Andreas Klebinger at 2019-09-24T21:08:42-04:00 Fix bounds check in ocResolve_PEi386 for relocation values. The old test was wrong at least for gcc and the value -2287728808L. It also relied on implementation defined behaviour (right shift on a negative value), which might or might not be ok. Either way it's now a simple comparison which will always work. - - - - - 218c5dbf by Matthew Pickering at 2019-09-24T21:09:23-04:00 Add ghcide configuration files This commit adds three new files 1. A hie.yaml file to the project root which specifies to IDEs how to set up the correct environment for loading GHC. This currently specifies to call the `./hadrian/hie-bios` script. 2. A `hie.yaml` file for the hadrian subcomponent, which uses the `cabal` cradle type. 2. The `./hadrian/hie-bios` script which supplies the correct arguments for an IDE to start a session. With these two files it is possible to run ``` ghcide compiler/ ``` and successfully load all the modules for use in the IDE. or ``` ghcide --cwd hadrian/ src/ ``` to test loading all of Hadrian's modules. Closes #17194 - - - - - 2970dc7a by Kari Pahula at 2019-09-25T13:52:48-04:00 Add -Wderiving-defaults (#15839) Enabling both DeriveAnyClass and GeneralizedNewtypeDeriving can cause a warning when no explicit deriving strategy is in use. This change adds an enable/suppress flag for it. - - - - - 4540bbe2 by John Ericson at 2019-09-25T13:53:42-04:00 includes/CodeGen.Platform.hs don't include ghcautoconf.h It doesn't need it, and it shouldn't need it or else multi-target will break. - - - - - ebc65025 by Sebastian Graf at 2019-09-25T13:54:22-04:00 PmCheck: Only ever check constantly many models against a single pattern Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates the old `-fmax-pmcheck-iter` mechanism in favor of this new flag. >From the user's guide: Pattern match checking can be exponential in some cases. This limit makes sure we scale polynomially in the number of patterns, by forgetting refined information gained from a partially successful match. For example, when matching `x` against `Just 4`, we split each incoming matching model into two sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but `y` is not `4`. When the number of incoming models exceeds the limit, we continue checking the next clause with the original, unrefined model. This also retires the incredibly hard to understand "maximum number of refinements" mechanism, because the current mechanism is more general and should catch the same exponential cases like PrelRules at the same time. ------------------------- Metric Decrease: T11822 ------------------------- - - - - - d90d0bad by Ben Gamari at 2019-09-25T13:55:09-04:00 base: Move Ix typeclass to GHC.Ix The `Ix` class seems rather orthogonal to its original home in `GHC.Arr`. - - - - - 795986aa by Ryan Scott at 2019-09-25T13:56:07-04:00 Remove unneeded CPP now that GHC 8.6 is the minimum The minimum required GHC version for bootstrapping is 8.6, so we can get rid of some unneeded `#if `__GLASGOW_HASKELL__` CPP guards, as well as one `MIN_VERSION_ghc_prim(0,5,3)` guard (since GHC 8.6 bundles `ghc-prim-0.5.3`). - - - - - 0b5eede9 by Vladislav Zavialov at 2019-09-25T21:06:04+03:00 Standalone kind signatures (#16794) Implements GHC Proposal #54: .../ghc-proposals/blob/master/proposals/0054-kind-signatures.rst With this patch, a type constructor can now be given an explicit standalone kind signature: {-# LANGUAGE StandaloneKindSignatures #-} type Functor :: (Type -> Type) -> Constraint class Functor f where fmap :: (a -> b) -> f a -> f b This is a replacement for CUSKs (complete user-specified kind signatures), which are now scheduled for deprecation. User-facing changes ------------------- * A new extension flag has been added, -XStandaloneKindSignatures, which implies -XNoCUSKs. * There is a new syntactic construct, a standalone kind signature: type <name> :: <kind> Declarations of data types, classes, data families, type families, and type synonyms may be accompanied by a standalone kind signature. * A standalone kind signature enables polymorphic recursion in types, just like a function type signature enables polymorphic recursion in terms. This obviates the need for CUSKs. * TemplateHaskell AST has been extended with 'KiSigD' to represent standalone kind signatures. * GHCi :info command now prints the kind signature of type constructors: ghci> :info Functor type Functor :: (Type -> Type) -> Constraint ... Limitations ----------- * 'forall'-bound type variables of a standalone kind signature do not scope over the declaration body, even if the -XScopedTypeVariables is enabled. See #16635 and #16734. * Wildcards are not allowed in standalone kind signatures, as partial signatures do not allow for polymorphic recursion. * Associated types may not be given an explicit standalone kind signature. Instead, they are assumed to have a CUSK if the parent class has a standalone kind signature and regardless of the -XCUSKs flag. * Standalone kind signatures do not support multiple names at the moment: type T1, T2 :: Type -> Type -- rejected type T1 = Maybe type T2 = Either String See #16754. * Creative use of equality constraints in standalone kind signatures may lead to GHC panics: type C :: forall (a :: Type) -> a ~ Int => Constraint class C a where f :: C a => a -> Int See #16758. Implementation notes -------------------- * The heart of this patch is the 'kcDeclHeader' function, which is used to kind-check a declaration header against its standalone kind signature. It does so in two rounds: 1. check user-written binders 2. instantiate invisible binders a la 'checkExpectedKind' * 'kcTyClGroup' now partitions declarations into declarations with a standalone kind signature or a CUSK (kinded_decls) and declarations without either (kindless_decls): * 'kinded_decls' are kind-checked with 'checkInitialKinds' * 'kindless_decls' are kind-checked with 'getInitialKinds' * DerivInfo has been extended with a new field: di_scoped_tvs :: ![(Name,TyVar)] These variables must be added to the context in case the deriving clause references tcTyConScopedTyVars. See #16731. - - - - - 4f81fab0 by Ryan Scott at 2019-09-26T14:04:38-04:00 Make -fbyte-code prevent unboxed tuples/sums from implying object code (#16876) This resolves #16876 by making the explicit use of `-fbyte-code` prevent code that enables `UnboxedTuples` or `UnboxedSums` from automatically compiling to object code. This allows for a nice middle ground where most code that enables `UnboxedTuples`/-`Sums` will still benefit from automatically enabling `-fobject-code`, but allows power users who wish to avoid this behavior in certain corner cases (such as `lens`, whose use case is documented in #16876) to do so. Along the way, I did a little cleanup of the relevant code and documentation: * `enableCodeGenForUnboxedTuples` was only checking for the presence of `UnboxedTuples`, but `UnboxedSums` has the same complications. I fixed this and renamed the function to `enableCodeGenForUnboxedTuplesOrSums`. * I amended the users' guide with a discussion of these issues. - - - - - 289fc8da by Sebastian Graf at 2019-09-27T22:10:17-04:00 PmCheck: Elaborate what 'model' means in the user guide [skip ci] - - - - - 9c02a793 by Ron Mordechai at 2019-09-27T22:11:06-04:00 Allow users to disable Unicode with an env var Unicode renders funny on my terminal and I like to avoid it where possible. Most applications which print out non-ascii characters allow users to disable such prints with an environment variable (e.g. Homebrew). This diff disables Unicode usage when the environment variable `GHC_NO_UNICODE` is set. To test, set the env var and compile a bad program. Note that GHC does not print Unicode bullets but instead prints out asterisks: ``` $ GHC_NO_UNICODE= _build/stage1/bin/ghc ../Temp.hs [1 of 1] Compiling Temp ( ../Temp.hs, ../Temp.o ) ../Temp.hs:4:23: error: * Couldn't match type `Bool' with `a -> Bool' Expected type: Bool -> a -> Bool Actual type: Bool -> Bool * In the first argument of `foldl', namely `(&& (flip $ elem u))' In the expression: foldl (&& (flip $ elem u)) True v In an equation for `isPermut': isPermut u v = foldl (&& (flip $ elem u)) True v * Relevant bindings include v :: [a] (bound at ../Temp.hs:4:12) u :: [a] (bound at ../Temp.hs:4:10) isPermut :: [a] -> [a] -> Bool (bound at ../Temp.hs:4:1) | 4 | isPermut u v = foldl (&& (flip $ elem u)) True v | ^^^^^^^^^^^^^^^^^^ ``` (Broken code taken from Stack Overflow) - - - - - 144abba3 by Ben Gamari at 2019-09-27T22:11:53-04:00 configure: Don't depend upon alex in source dist build This fixes #16860 by verifying that the generated sources don't already exist before asserting that the `alex` executable was found. This replicates the logic already used for `happy` in the case of `alex`. - - - - - c6fb913c by John Ericson at 2019-09-27T22:12:35-04:00 Just get RTS libs from its package conf `rts.conf` already contains this exact information in its `extra-libraries` stanza. - - - - - f07862b4 by Ben Gamari at 2019-09-27T22:13:16-04:00 ghc-prim: Fix documentation of Type As pointed out in #17243, `Type` is not the only kind having values. - - - - - 0201d0bf by chris-martin at 2019-09-27T22:14:00-04:00 Clarify the purpose and status of the GHC.TypeLits module - - - - - 444e554f by chris-martin at 2019-09-27T22:14:00-04:00 Expand description of DataKinds to mention data constructors, and include mention of TypeError - - - - - 1582dafa by Sebastian Graf at 2019-09-27T22:14:44-04:00 PmCheck: Look at precendence to give type signatures to some wildcards Basically do what we currently only do for -XEmptyCase in other cases where adding the type signature won't distract from pattern matches in other positions. We use the precedence to guide us, equating "need to parenthesise" with "too much noise". - - - - - ad0c4390 by Shayne Fletcher at 2019-09-27T22:15:27-04:00 Add test for expected dependencies of 'Parser' - - - - - 0b1fa64d by Ben Gamari at 2019-09-27T22:16:04-04:00 testsuite: Mark cgrun071 as broken on i386 As described in #17247. - - - - - 24620182 by Daniel Gröber at 2019-09-27T22:17:04-04:00 Raise minimum GHC version to 8.6 commit 795986aaf33e ("Remove unneeded CPP now that GHC 8.6 is the minimum") broke the 8.4 build. - - - - - e0bbb961 by Ben Gamari at 2019-09-27T22:17:44-04:00 testsuite: Mark compact_gc as fragile in the ghci way As noted in #17253. - - - - - bb984ac6 by Ben Gamari at 2019-09-27T22:18:42-04:00 testsuite: Mark hs_try_putmvar003 as fragile in threaded1 Due to #16361. Note that I'm leaving out threaded2 since it's not clear whether the single crash in that way was due to other causes. - - - - - ad2a1f99 by Ben Gamari at 2019-09-27T22:19:26-04:00 testsuite: Mark T3389 as broken in profiled ways on i386 As noted in #17256. - - - - - 6f9fa0be by Ben Gamari at 2019-09-27T22:20:04-04:00 testsuite: Mark TH tests as fragile in LLVM built external-interpreter Due to #16087. This drops the previous explicit list of broken tests and rather encompasses the entire set of tests since they all appear to be broken. - - - - - c5d888d4 by Sebastian Graf at 2019-09-28T17:11:41-04:00 PmCheck: No ConLike instantiation in pmcheck `pmcheck` used to call `refineToAltCon` which would refine the knowledge we had about a variable by equating it to a `ConLike` application. Since we weren't particularly smart about this in the Check module, we simply freshened the constructors existential and term binders utimately through a call to `mkOneConFull`. But that instantiation is unnecessary for when we match against a concrete pattern! The pattern will already have fresh binders and field types. So we don't call `refineToAltCon` from `Check` anymore. Subsequently, we can simplify a couple of call sites and functions in `PmOracle`. Also implementing `computeCovered` becomes viable and we don't have to live with the hack that was `addVarPatVecCt` anymore. A side-effect of not indirectly calling `mkOneConFull` anymore is that we don't generate the proper strict argument field constraints anymore. Instead we now desugar ConPatOuts as if they had bangs on their strict fields. This implies that `PmVar` now carries a `HsImplBang` that we need to respect by a (somewhat ephemeral) non-void check. We fix #17234 in doing so. - - - - - ce64b397 by Sebastian Graf at 2019-09-28T17:12:26-04:00 `exprOkForSpeculation` for Note [IO hack in the demand analyser] In #14998 I realised that the notion of speculative execution *exactly matches* eager evaluation of expressions in a case alternative where the scrutinee is an IO action. Normally we have to `deferIO` any result from that single case alternative to prevent this speculative execution, so we had a special case in place in the demand analyser that would check if the scrutinee was a prim-op, in which case we assumed that it would be ok to do the eager evaluation. Now we just check if the scrutinee is `exprOkForSpeculation`, corresponding to the notion that we want to push evaluation of the scrutinee *after* eagerly evaluating stuff from the case alternative. This fixes #14988, because it resolves the last open Item 4 there. - - - - - f3cb8c7c by Ömer Sinan Ağacan at 2019-09-30T22:39:53-04:00 Refactor iface file generation: This commit refactors interface file generation to allow information from the later passed (NCG, STG) to be stored in interface files. We achieve this by splitting interface file generation into two parts: * Partial interfaces, built based on the result of the core pipeline * A fully instantiated interface, which also contains the final fingerprints and can optionally contain information produced by the backend. This change is required by !1304 and !1530. -dynamic-too handling is refactored too: previously when generating code we'd branch on -dynamic-too *before* code generation, but now we do it after. (Original code written by @AndreasK in !1530) Performance ~~~~~~~~~~~ Before this patch interface files where created and immediately flushed to disk which made space leaks impossible. With this change we instead use NFData to force all iface related data structures to avoid space leaks. In the process of refactoring it was discovered that the code in the ToIface Module allocated a lot of thunks which were immediately forced when writing/forcing the interface file. So we made this module more strict to avoid creating many of those thunks. Bottom line is that allocations go down by about ~0.1% compared to master. Residency is not meaningfully different after this patch. Runtime was not benchmarked. Co-Authored-By: Andreas Klebinger <klebinger.andreas at gmx.at> Co-Authored-By: Ömer Sinan Ağacan <omer at well-typed.com> - - - - - 6a1700aa by Simon Peyton Jones at 2019-09-30T22:40:30-04:00 Fix arguments for unbound binders in RULE application We were failing to correctly implement Note [Unbound RULE binders] in Rules.hs. In particular, when cooking up a fake Refl, were were failing to apply the substitition. This patch fixes that problem, and simultaneously tidies up the impedence mis-match between RuleSubst and TCvSubst. Thanks to Sebastian! - - - - - 97811ef5 by Takenobu Tani at 2019-09-30T22:41:35-04:00 Add help message for GHCi :instances command This commit updates GHCi's help message for GHC 8.10. - - - - - 6f8550a3 by Sebastian Graf at 2019-09-30T22:42:14-04:00 Move pattern match checker modules to GHC.HsToCore.PmCheck - - - - - b36dd49b by Takenobu Tani at 2019-09-30T22:42:53-04:00 testsuite: Add minimal test for :doc command Currently, there are no testcases for GHCi `:doc` command. Perhaps because it was experimental. And it could be changed in the future. But `:doc` command is already useful, so I add a minimal regression test to keep current behavior. See also 85309a3cda for implementation of `:doc` command. - - - - - bdba6ac2 by Vladislav Zavialov at 2019-09-30T22:43:31-04:00 Do not rely on CUSKs in 'base' Use standalone kind signatures instead of complete user-specified kinds in Data.Type.Equality and Data.Typeable - - - - - dbdf6a3d by Ben Gamari at 2019-09-30T22:44:07-04:00 testsuite: Mark T3389 as broken in hpc way on i386 See #17256. - - - - - 822481d5 by Ben Gamari at 2019-09-30T22:44:44-04:00 Bump process submodule Marks process003 as fragile, as noted in #17245. - - - - - 6548b7b0 by Sebastian Graf at 2019-10-01T09:22:10+00:00 Add a bunch of testcases for the pattern match checker Adds regression tests for tickets #17207, #17208, #17215, #17216, #17218, #17219, #17248 - - - - - 58013220 by Sebastian Graf at 2019-10-01T09:22:18+00:00 Add testcases inspired by Luke Maranget's pattern match series In his paper "Warnings for Pattern Matching", Luke Maranget describes three series in his appendix for which GHC's pattern match checker scaled very badly. We mostly avoid this now with !1752. This commit adds regression tests for each of the series. Fixes #17264. - - - - - 9c002177 by Ryan Scott at 2019-10-01T16:24:12-04:00 Refactor some cruft in TcDeriv * `mk_eqn_stock`, `mk_eqn_anyclass`, and `mk_eqn_no_mechanism` all took a continuation of type `DerivSpecMechanism -> DerivM EarlyDerivSpec` to represent its primary control flow. However, in practice this continuation was always instantiated with the `mk_originative_eqn` function, so there's not much point in making this be a continuation in the first place. This patch removes these continuations in favor of invoking `mk_originative_eqn` directly, which is simpler. * There were several parts of `TcDeriv` that took different code paths if compiling an `.hs-boot` file. But this is silly, because ever since 101a8c770b9d3abd57ff289bffea3d838cf25c80 we simply error eagerly whenever attempting to derive any instances in an `.hs-boot` file. This patch removes all of the unnecessary `.hs-boot` code paths, leaving only one (which errors out). * Remove various error continuation arguments from `mk_eqn_stock` and related functions. - - - - - 9a27a063 by David Eichmann at 2019-10-01T16:55:33-04:00 Hadrian: Libffi rule now `produces` dynamic library files. - - - - - 0956c194 by David Eichmann at 2019-10-01T16:55:33-04:00 Hadrian: do not cache GHC configure rule - - - - - 8924224e by Ömer Sinan Ağacan at 2019-10-01T16:55:37-04:00 Make small INLINE functions behave properly Simon writes: Currently we check for a type arg rather than isTyCoArg. This in turn makes INLINE things look bigger than they should be, and stops them being inlined into boring contexts when they perfectly well could be. E.g. f x = g <refl> x {-# INLINE g #-} ... (map (f x) xs) ... The context is boring, so don't inline unconditionally. But f's RHS is no bigger than its call, provided you realise that the coercion argument is ultimately cost-free. This happens in practice for $WHRefl. It's not a big deal: at most it means we have an extra function call overhead. But it's untidy, and actually worse than what happens without an INLINE pragma. Fixes #17182 This makes 0.0% change in nofib binary sizes. - - - - - 53b0c6e0 by Gabor Greif at 2019-10-03T08:15:50-04:00 Typo in comment [ci skip] - - - - - 60229e9e by Ryan Scott at 2019-10-03T12:17:10-04:00 Merge TcTypeableValidity into TcTypeable, document treatment of casts This patch: * Implements a refactoring (suggested in https://gitlab.haskell.org/ghc/ghc/merge_requests/1199#note_207345) that moves all functions from `TcTypeableValidity` back to `TcTypeable`, as the former module doesn't really need to live on its own. * Adds `Note [Typeable instances for casted types]` to `TcTypeable` explaining why the `Typeable` solver currently does not support types containing casts. Resolves #16835. - - - - - 3b9d4907 by Richard Eisenberg at 2019-10-03T12:17:13-04:00 Note [Don't flatten tuples from HsSyn] in MkCore Previously, we would sometimes flatten 1-tuples and sometimes not. This didn't cause damage because there is no way to generate HsSyn with 1-tuples. But, with the upcoming fix to #16881, there will be. Without this patch, obscure lint errors would have resulted. No test case, as there is not yet a way to tickle this. - - - - - 8a254d6b by Ömer Sinan Ağacan at 2019-10-03T12:17:19-04:00 Fix new compact block allocation in allocateForCompact allocateForCompact() is called when nursery of a compact region is full, to add new blocks to the compact. New blocks added to an existing region needs a StgCompactNFDataBlock header, not a StgCompactNFData. This fixes allocateForCompact() so that it now correctly allocates space for StgCompactNFDataBlock instead of StgCompactNFData as before. Fixes #17044. A regression test T17044 added. - - - - - 3c7b172b by James Brock at 2019-10-03T12:17:24-04:00 docs String, hyperlink to Data.List Add a reference to the documentation for Data.List in the description for String. On the generated Haddock for Data.String, http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-String.html there is curently no hyperlink to Data.List, which is where a reader will find most of the useful functions which can operate on Strings. I imagine this has confused beginners who came to this page looking for String operations. - - - - - 67bf734c by John Ericson at 2019-10-03T12:17:28-04:00 Add `module {-# SOURCE #-} Foo` syntax for hs-boot in bkp This is a good convenience for testing. - - - - - 6655ec73 by Richard Eisenberg at 2019-10-03T12:17:30-04:00 Improve documentation around empty tuples/lists This patch also changes the way we handle empty lists, simplifying them somewhat. See Note [Empty lists]. Previously, we had to special-case empty lists in the type-checker. Now no more! Finally, this patch improves some documentation around the ir_inst field used in the type-checker. This breaks a test case, but I really think the problem is #17251, not really related to this patch. Test case: typecheck/should_compile/T13680 - - - - - 9a4ff210 by John Ericson at 2019-10-03T12:17:31-04:00 Make Haddock submodule remote point to gitlab mirror This makes it match the others - - - - - cb364bc2 by Ben Gamari at 2019-10-03T12:17:32-04:00 testsuite: Mark print037 as fragile, not broken See #16205. - - - - - 259f4dff by Ben Gamari at 2019-10-03T12:17:32-04:00 Exclude rts.cabal from source distributions This modifies both the Hadrian and make build systems to avoid included the rts.cabal generated by autoconf in the source distribution. Fixes #17265. - - - - - e4c93896 by Ben Gamari at 2019-10-03T12:17:32-04:00 DynFlags: Only warn when split-sections is ignored Previously we would throw an error which seems a bit harsh. As reported in #17283. - - - - - ee6324ad by Tobias Guggenmos at 2019-10-03T12:17:33-04:00 Improve documentation for runtime debugging flags - - - - - 47386fe8 by Tobias Guggenmos at 2019-10-03T12:17:33-04:00 Add new debug flag -DZ Zeros heap memory after gc freed it. - - - - - d0924b15 by Stefan Schulze Frielinghaus at 2019-10-03T12:17:34-04:00 Extend argument of createIOThread to word size Function createIOThread expects its second argument to be of size word. The natural size of the second parameter is 32bits. Thus for some 64bit architectures, where a write of the lower half of a register does not clear the upper half, the value must be zero extended. - - - - - 1357d023 by Ben Gamari at 2019-10-03T12:17:34-04:00 rules/haddock: Ensure that RTS stats directory exists It may not exist if the source tarball was extracted yet not the testsuite tarball. - - - - - ec93d2a9 by Fumiaki Kinoshita at 2019-10-04T21:43:49-04:00 Add Monad instances to `(,,) a b` and `(,,,) a b c` - - - - - 05419e55 by John Ericson at 2019-10-04T21:44:29-04:00 Per stage headers, ghc_boot_platform.h -> stage 0 ghcplatform.h The generated headers are now generated per stage, which means we can skip hacks like `ghc_boot_platform.h` and just have that be the stage 0 header as proper. In general, stages are to be embraced: freely generate everything in each stage but then just build what you depend on, and everything is symmetrical and efficient. Trying to avoid stages because bootstrapping is a mind bender just creates tons of bespoke mini-mind-benders that add up to something far crazier. Hadrian was pretty close to this "stage-major" approach already, and so was fairly easy to fix. Make needed more work, however: it did know about stages so at least there was a scaffold, but few packages except for the compiler cared, and the compiler used its own counting system. That said, make and Hadrian now work more similarly, which is good for the transition to Hadrian. The merits of embracing stage aside, the change may be worthy for easing that transition alone. - - - - - 75a5dd8e by John Ericson at 2019-10-04T21:44:29-04:00 Remove {Build,Host}Platform_NAME from header They are only used in a file we construct directly, so just skip CPP. - - - - - b538476b by Daroc Alden at 2019-10-04T21:45:09-04:00 Deprecate -fwarn-hi-shadowing, because it was never implemented and is not used. This fixes #10913. - - - - - dd8f76b2 by John Ericson at 2019-10-04T21:45:48-04:00 Factor out a smaller part of Platform for host fallback - - - - - d15b44d6 by John Ericson at 2019-10-04T21:45:49-04:00 Pull out the settings file parsing code into it's own module. This has two benefits: 1. One less hunk of code dependent on DynFlags 2. Add a little bit of error granularity to distrinugish between missing data and bad data. This could someday be shared with ghc-pkg which aims to work even with a missing file. I also am about to to make --supported-extensions use this too. - - - - - eb892b28 by John Ericson at 2019-10-04T21:45:49-04:00 Add tryFindTopDir to look for the top dir without blowing up if it is not found. - - - - - 0dded5ec by John Ericson at 2019-10-04T21:45:49-04:00 Always enable the external interpreter You can always just not use or even build `iserv`. I don't think the maintenance cost of the CPP is worth...I can't even tell what the benefit is. - - - - - 0d31ccdd by Artem Pyanykh at 2019-10-04T21:46:28-04:00 [linker, macho] Don't map/allocate zero size sections and segments Zero size sections are common even during regular build on MacOS. For instance: ``` $ ar -xv libHSghc-prim-0.6.1.a longlong.o $ otool -l longlong.o longlong.o: Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags 0xfeedfacf 16777223 3 0x00 1 2 176 0x00002000 Load command 0 cmd LC_SEGMENT_64 cmdsize 152 segname vmaddr 0x0000000000000000 vmsize 0x0000000000000000 <-- segment size = 0 fileoff 208 filesize 0 maxprot 0x00000007 initprot 0x00000007 nsects 1 flags 0x0 Section sectname __text segname __TEXT addr 0x0000000000000000 size 0x0000000000000000 <-- section size = 0 offset 208 align 2^0 (1) reloff 0 nreloc 0 flags 0x80000000 reserved1 0 reserved2 0 cmd LC_BUILD_VERSION cmdsize 24 platform macos sdk 10.14 minos 10.14 ntools 0 ``` The issue of `mmap`ing 0 bytes was resolved in !1050, but the problem remained. These 0 size segments and sections were still allocated in object code, which lead to failed `ASSERT(size > 0)` in `addProddableBlock` further down the road. With this change zero size segments **and** sections are not mapped/allocated at all. Test plan: 1. Build statically linked GHC. 2. Run `ghc --interactive`. Observe that REPL loads successfully (which was not the case before). 3. Load several more compiled hs files into repl. No failures. - - - - - 93f02b62 by Roland Senn at 2019-10-04T21:47:07-04:00 New fix for #11647. Avoid side effects like #17171 If a main module doesn't contain a header, we omit the check whether the main module is exported. With this patch GHC, GHCi and runghc use the same code. - - - - - 8039b625 by Matthew Bauer at 2019-10-04T21:47:47-04:00 Add musl systems to llvm-targets This was done in Nixpkgs, but never upstreamed. Musl is pretty much the same as gnu, but with a different libc. I’ve used the same values for everything. - - - - - ee8118ca by John Ericson at 2019-10-05T00:11:58-04:00 Clean up `#include`s in the compiler - Remove unneeded ones - Use <..> for inter-package. Besides general clean up, helps distinguish between the RTS we link against vs the RTS we compile for. - - - - - 241921a0 by Ben Gamari at 2019-10-05T19:18:40-04:00 rts: Fix CNF dirtying logic Previously due to a silly implementation bug CNFs would never have their dirty flag set, resulting in their being added again and again to the `mut_list`. Fix this. Fixes #17297. - - - - - 825c108b by Ryan Scott at 2019-10-07T12:00:59-04:00 Only flatten up to type family arity in coreFlattenTyFamApp (#16995) Among other uses, `coreFlattenTyFamApp` is used by Core Lint as a part of its check to ensure that each type family axiom reduces according to the way it is defined in the source code. Unfortunately, the logic that `coreFlattenTyFamApp` uses to flatten type family applications disagreed with the logic in `TcFlatten`, which caused it to spuriously complain this program: ```hs type family Param :: Type -> Type type family LookupParam (a :: Type) :: Type where LookupParam (f Char) = Bool LookupParam x = Int foo :: LookupParam (Param ()) foo = 42 ``` This is because `coreFlattenTyFamApp` tries to flatten the `Param ()` in `LookupParam (Param ())` to `alpha` (where `alpha` is a flattening skolem), and GHC is unable to conclude that `alpha` is apart from `f Char`. This patch spruces up `coreFlattenTyFamApp` so that it instead flattens `Param ()` to `alpha ()`, which GHC _can_ know for sure is apart from `f Char`. See `Note [Flatten], wrinkle 3` in `FamInstEnv`. - - - - - b2577081 by Ben Gamari at 2019-10-07T12:01:46-04:00 Refactor, document, and optimize LLVM configuration loading As described in the new Note [LLVM Configuration] in SysTools, we now load llvm-targets and llvm-passes lazily to avoid the overhead of doing so when -fllvm isn't used (also known as "the common case"). Noticed in #17003. Metric Decrease: T12234 T12150 - - - - - 93c71ae6 by Ben Gamari at 2019-10-07T12:02:23-04:00 configure: Determine library versions of template-haskell, et al. These are needed by the user guide documentation. Fixes #17260. - - - - - b7890611 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Hadrian: Stop using in-tree Cabal - - - - - 0ceb98f6 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Switch to cabal-version=3.0 in ghc-heap.cabal - - - - - e3418e96 by Andrey Mokhov at 2019-10-07T12:03:13-04:00 Switch to cabal-version=3.0 in base.cabal and rts.cabal - - - - - 805653f6 by John Ericson at 2019-10-07T12:04:19-04:00 Get rid of wildcard patterns in prim Cmm emitting code This way, we can be sure we don't miss a case. - - - - - ab945819 by Ryan Scott at 2019-10-07T12:05:09-04:00 Refactor some cruft in TcGenGenerics * `foldBal` contains needless partiality that can easily be avoided. * `mkProd_E` and `mkProd_P` both contain unique supply arguments that are completely unused, which can be removed. - - - - - d0edba3a by John Ericson at 2019-10-07T12:05:47-04:00 Remove CONFIGURE_ARGS from configure.ac It looks like it's been unused since at least 34cc75e1a62638f2833815746ebce0a9114dc26b. - - - - - 9a6bfb0a by John Ericson at 2019-10-07T12:06:26-04:00 Keep OSTYPE local to configure.ac Unused outside it since b6be81b841e34ca45b3549c4c79e886a8761e59a. - - - - - 4df39fd0 by John Ericson at 2019-10-07T12:07:08-04:00 Get rid of GHC_PACKAGE_DB_FLAG We no longer support booting from older GHC since 527bcc41630918977c73584d99125ff164400695. - - - - - 31a29a7a by John Ericson at 2019-10-07T12:07:46-04:00 Remove GhcLibsWithUnix d679ca43e7477284d733b94ff542be5363be3353 meant to remove it but did not finish the job. - - - - - 77ca39e3 by Ben Gamari at 2019-10-08T05:11:03-04:00 gitlab-ci: Add missing TEST_ENV variables This should fix #16985. - - - - - 9a2798e1 by Ben Gamari at 2019-10-08T05:11:03-04:00 hadrian: Add `validate` and `slow validate` flavours - - - - - ab311696 by Ben Gamari at 2019-10-08T05:11:03-04:00 validate: Use Hadrian's validate flavour - - - - - 98179a77 by Ben Gamari at 2019-10-08T05:11:03-04:00 gitlab-ci: Use validate flavour in hadrian builds - - - - - 8af9eba8 by Ben Gamari at 2019-10-08T05:11:40-04:00 base: Document the fact that Typeable is automatically "derived" This fixes #17060. - - - - - 397c6ed5 by Sebastian Graf at 2019-10-08T05:12:15-04:00 PmCheck: Identify some semantically equivalent expressions By introducing a `CoreMap Id` to the term oracle, we can represent syntactically equivalent expressions by the same `Id`. Combine that with `CoreOpt.simpleCoreExpr` and it might even catch non-trivial semantic equalities. Unfortunately due to scoping issues, this will not solve #17208 for view patterns yet. - - - - - 8a2e8408 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Refer to language extension flags via :extension: Previously several were referred to via :ghc-flag:`-X...`. - - - - - 7cd54538 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Make reverse flags addressable via :ghc-flag: Previously one could not easily link to the :reverse: flag of a ghc-flag. - - - - - e9813afc by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document -XHaskell98 and -XHaskell2010 - - - - - eaeb28a1 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Fix various warnings - - - - - 180cf177 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document NondecreasingIndentation - - - - - 0a26f9e8 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Document -fworker-wrapper - - - - - ca4791db by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Rework pragma key generation Previously we had a hack to handle the case of multi-token SPECIALISE pragmas. Now we use a slightly more general rule of using a prefix of tokens containing only alphabetical characters. - - - - - 98c09422 by Ben Gamari at 2019-10-08T05:12:58-04:00 users-guide: Run sphinx in nit-picky mode This ensure that it blurts an error on missing references. - - - - - a95f7185 by Ben Gamari at 2019-10-08T05:12:58-04:00 doc: Write out documented flag list - - - - - 9402608e by Ben Gamari at 2019-10-08T05:12:58-04:00 gitlab-ci: Check coverage of GHC flags in users guide This ensures that all GHC flags are documented during the documentation build. Fixes #17315. - - - - - 9ac3bcbb by Andrew Martin at 2019-10-08T13:24:52-04:00 Document the UnliftedFFITypes extension. - - - - - 77f3ba23 by Andrew Martin at 2019-10-08T13:24:52-04:00 Rephrase a bunch of things in the unlifted ffi types documentation. Add a section on pinned byte arrays. - - - - - a70db7bf by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] link to foreign cmm call - - - - - 0d413259 by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] make the table better - - - - - 0c7a5bcd by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] can not -> may not - - - - - 6a5c249d by Andrew Martin at 2019-10-08T13:24:52-04:00 [skip ci] clarify what unsound means - - - - - bf02c264 by Ryan Scott at 2019-10-08T13:25:37-04:00 Mark newtype constructors as used in the Coercible solver (#10347) Currently, newtype constructors are not marked as used when they are accessed under the hood by uses of `coerce`, as described in #10347. This fixes #10347 by co-opting the `tcg_keep` field of `TcGblEnv` to track uses of newtype constructors in the `Coercible` solver. See `Note [Tracking unused binding and imports]` in `TcRnTypes`. Since #10347 is fixed, I was able to simplify the code in `TcDeriv` slightly, as the hack described in `Note [Newtype deriving and unused constructors]` is no longer necessary. - - - - - 9612e91c by Richard Eisenberg at 2019-10-08T13:26:20-04:00 Solve constraints from top-level groups sooner Previously, all constraints from all top-level groups (as separated by top-level splices) were lumped together and solved at the end. This could leak metavariables to TH, though, and that's bad. This patch solves each group's constraints before running the next group's splice. Naturally, we now report fewer errors in some cases. One nice benefit is that this also fixes #11680, but in a much simpler way than the original fix for that ticket. Admittedly, the error messages degrade just a bit from the fix from #11680 (previously, we informed users about variables that will be brought into scope below a top-level splice, and now we just report an out-of-scope error), but the amount of complexity required throughout GHC to get that error was just not worth it. This patch thus reverts much of f93c9517a2c6e158e4a5c5bc7a3d3f88cb4ed119. Fixes #16980 Test cases: th/T16980{,a} - - - - - c2d4011c by Vladislav Zavialov at 2019-10-08T13:27:12-04:00 Bump array and haddock submodules - - - - - f691f0c2 by Sebastian Graf at 2019-10-08T13:27:49-04:00 PmCheck: Look up parent data family TyCon when populating `PossibleMatches` The vanilla COMPLETE set is attached to the representation TyCon of a data family instance, whereas the user-defined COMPLETE sets are attached to the parent data family TyCon itself. Previously, we weren't trying particularly hard to get back to the representation TyCon to the parent data family TyCon, resulting in bugs like #17207. Now we should do much better. Fixes the original issue in #17207, but I found another related bug that isn't so easy to fix. - - - - - 0c0a15a8 by Ben Gamari at 2019-10-09T16:21:14-04:00 Rename STAGE macro to GHC_STAGE To avoid polluting the macro namespace - - - - - 63a5371d by Ben Gamari at 2019-10-09T16:21:14-04:00 Relayout generated header body - - - - - 817c1a94 by Ben Gamari at 2019-10-09T16:21:14-04:00 Define GHC_STAGE in headers instead of command-line - - - - - 5f2c49d8 by Ben Gamari at 2019-10-09T16:21:14-04:00 Remove GHC_STAGE guards from MachDeps This allows the stage1 compiler (which needs to run on the build platform and produce code for the host) to depend upon properties of the target. This is wrong. However, it's no more wrong than it was previously and @Erichson2314 is working on fixing this so I'm going to remove the guard so we can finally bootstrap HEAD with ghc-8.8 (see issue #17146). - - - - - 35cc5eff by Ben Gamari at 2019-10-09T16:21:15-04:00 Test - - - - - d584e3f0 by Ryan Scott at 2019-10-09T16:21:50-04:00 Use addUsedDataCons more judiciously in TcDeriv (#17324) If you derive an instance like this: ```hs deriving <...> instance Foo C ``` And the data constructors for `C` aren't in scope, then `doDerivInstErrorChecks1` throws an error. Moreover, it will _only_ throw an error if `<...>` is either `stock` or `newtype`. This is because the code that the `anyclass` or `via` strategies would generate would not require the use of the data constructors for `C`. However, `doDerivInstErrorChecks1` has another purpose. If you write this: ```hs import M (C(MkC1, ..., MkCn)) deriving <...> instance Foo C ``` Then `doDerivInstErrorChecks1` will call `addUsedDataCons` on `MkC1` through `MkCn` to ensure that `-Wunused-imports` does not complain about them. However, `doDerivInstErrorChecks1` was doing this for _every_ deriving strategy, which mean that if `<...>` were `anyclass` or `via`, then the warning about `MkC1` through `MkCn` being unused would be suppressed! The fix is simple enough: only call `addUsedDataCons` when the strategy is `stock` or `newtype`, just like the other code paths in `doDerivInstErrorChecks1`. Fixes #17324. - - - - - 30f5ac07 by Sebastian Graf at 2019-10-11T22:10:12-04:00 Much simpler language for PmCheck Simon realised that the simple language composed of let bindings, bang patterns and flat constructor patterns is enough to capture the semantics of the source pattern language that are important for pattern-match checking. Well, given that the Oracle is smart enough to connect the dots in this less informationally dense form, which it is now. So we transform `translatePat` to return a list of `PmGrd`s relative to an incoming match variable. `pmCheck` then trivially translates each of the `PmGrd`s into constraints that the oracle understands. Since we pass in the match variable, we incidentally fix #15884 (coverage checks for view patterns) through an interaction with !1746. - - - - - 166e1c2a by Stefan Schulze Frielinghaus at 2019-10-11T22:10:51-04:00 Hadrian: Take care of assembler source files Fixes #17286. - - - - - c2290596 by John Ericson at 2019-10-12T06:32:18-04:00 Simplify Configure in a few ways - No need to distinguish between gcc-llvm and clang. First of all, gcc-llvm is quite old and surely unmaintained by now. Second of all, none of the code actually care about that distinction! Now, it does make sense to consider C multiple frontends for LLVMs in the form of clang vs clang-cl (same clang, yes, but tweaked interface). But this is better handled in terms of "gccish vs mvscish" and "is LLVM", yielding 4 combinations. Therefore, I don't think it is useful saving the existing code for that. - Get the remaining CC_LLVM_BACKEND, and also TABLES_NEXT_TO_CODE in mk/config.h the normal way, rather than hacking it post-hoc. No point keeping these special cases around for now reason. - Get rid of hand-rolled `die` function and just use `AC_MSG_ERROR`. - Abstract check + flag override for unregisterised and tables next to code. Oh, and as part of the above I also renamed/combined some variables where it felt appropriate. - GccIsClang -> CcLlvmBackend. This is for `AC_SUBST`, like the other Camal case ones. It was never about gcc-llvm, or Apple's renamed clang, to be clear. - llvm_CC_FLAVOR -> CC_LLVM_BACKEND. This is for `AC_DEFINE`, like the other all-caps snake case ones. llvm_CC_FLAVOR was just silly indirection *and* an odd name to boot. - - - - - f1ce3535 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00 Escape stats file command (#13676) - - - - - cd1a8808 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00 Skip T13767 on Darwin The CI job fails with: +++ rts/T13676.run/T13676.run.stderr.normalised 2019-10-09 12:27:56.000000000 -0700 @@ -0,0 +1,4 @@ +dyld: Library not loaded: @rpath/libHShaskeline-0.7.5.0-ghc8.9.0.20191009.dylib + Referenced from: /Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc + Reason: image not found +*** Exception: readCreateProcess: '/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc' '-B/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib' '-e' ''/''$'/'' == '/''/x0024'/''' +RTS '-tT13676.t' (exit -6): failed Unable to reproduce locally. - - - - - 0a338264 by Ryan Scott at 2019-10-12T06:33:42-04:00 Use newDFunName for both manual and derived instances (#17339) Issue #17339 was caused by using a slightly different version of `newDFunName` for derived instances that, confusingly enough, did not take all arguments to the class into account when generating the `DFun` name. I cannot think of any good reason for doing this, so this patch uses `newDFunName` uniformly for both derived instances and manually written instances alike. Fixes #17339. - - - - - c50e4c92 by Simon Peyton Jones at 2019-10-12T13:35:24-04:00 Fix validity checking for inferred types GHC is suposed to uphold the principle that an /inferred/ type for a let-binding should obey the rules for that module. E.g. we should only accept an inferred higher rank type if we have RankNTypes on. But we were failing to check this: TcValidity.checkValidType allowed arbitrary rank for inferred types. This patch fixes the bug. It might in principle cause some breakage, but if so that's good: the user should add RankNTypes and/or a manual signature. (And almost every package has explicit user signatures for all top-level things anyway.) Let's see. Fixes #17213. Metric Decrease: T10370 - - - - - 226d86d2 by Simon Peyton Jones at 2019-10-12T13:36:02-04:00 Do not add a 'solved dict' for quantified constraints GHC has a wonderful-but-delicate mechanism for building recursive dictionaries by adding a goal to the "solved dictionaries" before solving the sub-goals. See Note [Solved dictionaries] in TcSMonad Ticket #17267 showed that if you use this mechanism for local /quantified/ constraints you can get a loop -- or even unsafe coerce. This patch fixes the bug. Specifically * Make TcSMonad.addSolvedDict be conditional on using a /top level/ instance, not a quantified one. * Moreover, we /also/ don't want to add a solved dict for equalities (a~b). * Add lots more comments to Note [Solved dictionaries] to explain the above cryptic stuff. * Extend InstanceWhat to identify those strange built-in equality instances. A couple of other things along the way * Delete the unused Type.isIPPred_maybe. * Stop making addSolvedDict conditional on not being an impolicit parameter. This comes from way back. But it's irrelevant now because IP dicts are never solved via an instance. - - - - - 5ab1a28d by nineonine at 2019-10-13T06:31:40-04:00 Template Haskell: make unary tuples legal (#16881) - - - - - c1bd07cd by Andreas Klebinger at 2019-10-13T06:32:19-04:00 Fix #17334 where NCG did not properly update the CFG. Statements can change the basic block in which instructions are placed during instruction selection. We have to keep track of this switch of the current basic block as we need this information in order to properly update the CFG. This commit implements this change and fixes #17334. We do so by having stmtToInstr return the new block id if a statement changed the basic block. - - - - - 1eda9f28 by Takenobu Tani at 2019-10-13T19:06:02-04:00 users-guide: Add GHCi's ::<builtin-command> form This commit explicitly adds description about double colon command of GHCi. [skip ci] - - - - - 27145351 by Takenobu Tani at 2019-10-13T19:06:40-04:00 Add GHCi help message for :def! and :: commands - - - - - 78463fc5 by Ryan Scott at 2019-10-14T08:38:36-04:00 Add docs/users_guide/.log to .gitignore When the users guide fails to build (as in #17346), a `docs/users_guide/.log` file will be generated with contents that look something like this: ``` WARNING: unknown config value 'latex_paper_size' in override, ignoring /home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?option? /home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?port? Encoding error: 'ascii' codec can't encode character u'\u27e8' in position 132: ordinal not in range(128) The full traceback has been saved in /tmp/sphinx-err-rDF2LX.log, if you want to report the issue to the developers. ``` This definitely should not be checked in to version control, so let's add this to `.gitignore`. - - - - - 4aba72d6 by Ryan Scott at 2019-10-14T08:39:12-04:00 Mention changes from #16980, #17213 in 8.10.1 release notes The fixes for these issues both have user-facing consequences, so it would be good to mention them in the release notes for GHC 8.10.1. While I'm in town, also mention `UnboxedSums` in the release notes entry related to `-fobject-code`. - - - - - 0ca044fd by Ben Gamari at 2019-10-14T08:39:48-04:00 gitlab-ci: Move hadrian-ghc-in-ghci job first This is a very cheap job and can catch a number of "easy" failure modes (e.g. missing imports in the compiler). Let's run it first. - - - - - a2d3594c by Ryan Scott at 2019-10-15T01:35:34-04:00 Refactor some cruft in TcDerivInfer.inferConstraints The latest installment in my quest to clean up the code in `TcDeriv*`. This time, my sights are set on `TcDerivInfer.inferConstraints`, which infers the context for derived instances. This function is a wee bit awkward at the moment: * It's not terribly obvious from a quick glance, but `inferConstraints` is only ever invoked when using the `stock` or `anyclass` deriving strategies, as the code for inferring the context for `newtype`- or `via`-derived instances is located separately in `mk_coerce_based_eqn`. But there's no good reason for things to be this way, so I moved this code from `mk_coerce_based_eqn` to `inferConstraints` so that everything related to inferring instance contexts is located in one place. * In this process, I discovered that the Haddocks for the auxiliary function `inferConstraintsDataConArgs` are completely wrong. It claims that it handles both `stock` and `newtype` deriving, but this is completely wrong, as discussed above—it only handles `stock`. To rectify this, I renamed this function to `inferConstraintsStock` to reflect its actual purpose and created a new `inferConstraintsCoerceBased` function to specifically handle `newtype` (and `via`) deriving. Doing this revealed some opportunities for further simplification: * Removing the context-inference–related code from `mk_coerce_based_eqn` made me realize that the overall structure of the function is basically identical to `mk_originative_eqn`. In fact, I was easily able to combine the two functions into a single `mk_eqn_from_mechanism` function. As part of this merger, I now invoke `atf_coerce_based_error_checks` from `doDerivInstErrorChecks1`. * I discovered that GHC defined this function: ```hs typeToTypeKind = liftedTypeKind `mkVisFunTy` liftedTypeKind ``` No fewer than four times in different modules. I consolidated all of these definitions in a single location in `TysWiredIn`. - - - - - 426b0ddc by Ryan Scott at 2019-10-15T01:36:14-04:00 Don't skip validity checks for built-in classes (#17355) Issue #17355 occurred because the control flow for `TcValidity.check_valid_inst_head` was structured in such a way that whenever it checked a special, built-in class (like `Generic` or `HasField`), it would skip the most important check of all: `checkValidTypePats`, which rejects nonsense like this: ```hs instance Generic (forall a. a) ``` This fixes the issue by carving out `checkValidTypePats` from `check_valid_inst_head` so that `checkValidTypePats` is always invoked. `check_valid_inst_head` has also been renamed to `check_special_inst_head` to reflect its new purpose of _only_ checking for instances headed by special classes. Fixes #17355. - - - - - a55b8a65 by Alp Mestanogullari at 2019-10-15T18:41:18-04:00 iface: export a few more functions from BinIface - - - - - 9c11f817 by Ben Gamari at 2019-10-15T18:41:54-04:00 hadrian: Add support for bindist compressors other than Xz Fixes #17351. - - - - - 535a88e1 by klebinger.andreas at gmx.at at 2019-10-16T07:04:21-04:00 Add loop level analysis to the NCG backend. For backends maintaining the CFG during codegen we can now find loops and their nesting level. This is based on the Cmm CFG and dominator analysis. As a result we can estimate edge frequencies a lot better for methods, resulting in far better code layout. Speedup on nofib: ~1.5% Increase in compile times: ~1.9% To make this feasible this commit adds: * Dominator analysis based on the Lengauer-Tarjan Algorithm. * An algorithm estimating global edge frequences from branch probabilities - In CFG.hs A few static branch prediction heuristics: * Expect to take the backedge in loops. * Expect to take the branch NOT exiting a loop. * Expect integer vs constant comparisons to be false. We also treat heap/stack checks special for branch prediction to avoid them being treated as loops. - - - - - cc2bda50 by adithyaov at 2019-10-16T07:05:01-04:00 Compiling with -S and -fno-code no longer panics (fixes #17143) - - - - - 19641957 by Takenobu Tani at 2019-10-16T07:05:41-04:00 testsuite: Add test for #8305 This is a test for the current algorithm of GHCi command name resolution. I add this test in preparation for updating GHCi command name resolution. For the current algorithm, see https://downloads.haskell.org/ghc/latest/docs/html/users_guide/ghci.html#the-ghci-files - - - - - 6ede3554 by Sebastian Graf at 2019-10-16T07:06:20-04:00 Infer rho-types instead of sigma-types in guard BindStmts and TransStmts In #17343 we saw that we didn't handle the pattern guard `!_ <- undefined` correctly: The `undefined` was never evaluated. Indeed, elaboration failed to insert the invisible type aruments to `undefined`. So `undefined` was trivially a normal-form and in turn never entered. The problem is that we used to infer a sigma-type for the RHS of the guard, the leading qualifiers of which will never be useful in a pattern match situation. Hence we infer a rho-type now. Fixes #17343. - - - - - 798037a1 by John Ericson at 2019-10-16T07:06:58-04:00 Delete ghctags cabal file It came back to life in 381c3ae31b68019177f1cd20cb4da2f9d3b7d6c6 by mistake. - - - - - 51fad9e6 by Richard Eisenberg at 2019-10-16T15:58:58-04:00 Break up TcRnTypes, among other modules. This introduces three new modules: - basicTypes/Predicate.hs describes predicates, moving this logic out of Type. Predicates don't really exist in Core, and so don't belong in Type. - typecheck/TcOrigin.hs describes the origin of constraints and types. It was easy to remove from other modules and can often be imported instead of other, scarier modules. - typecheck/Constraint.hs describes constraints as used in the solver. It is taken from TcRnTypes. No work other than module splitting is in this patch. This is the first step toward homogeneous equality, which will rely more strongly on predicates. And homogeneous equality is the next step toward a dependently typed core language. - - - - - 11d4fc50 by Ben Gamari at 2019-10-16T15:59:52-04:00 hadrian: Introduce enableDebugInfo flavour transformer Also refactor things a bit to eliminate repetition. - - - - - deb96399 by Ryan Scott at 2019-10-16T16:00:29-04:00 Make Coverage.TM a newtype - - - - - 42ebc3f6 by Brian Wignall at 2019-10-16T16:01:06-04:00 Add hyperlinks to PDF/HTML documentation; closes #17342 - - - - - b15a7fb8 by Ben Gamari at 2019-10-17T01:03:11-04:00 testsuite: Ensure that makefile tests get run Previously `makefile_test` and `run_command` tests could easily end up in a situation where they wouldn't be run if the user used the `only_ways` modifier. The reason is to build the set of a ways to run the test in we first start with a candidate set determined by the test type (e.g. `makefile_test`, `compile_run`, etc.) and then filter that set with the constraints given by the test's modifiers. `makefile_test` and `run_command` tests' candidate sets were simply `{normal}`, and consequently most uses of `only_ways` would result in the test being never run. To avoid this we rather use all ways as the candidate sets for these test types. This may result in a few more testcases than we would like (given that some `run_command` tests are insensitive to way) but this can be fixed by adding modifiers and we would much rather run too many tests than too few. This fixes #16042 and a number of other tests afflicted by the same issue. However, there were a few cases that required special attention: * `T14028` is currently failing and is therefore marked as broken due to #17300 * `T-signals-child` is fragile in the `threaded1` and `threaded2` ways (tracked in #17307) - - - - - 4efdda90 by Richard Eisenberg at 2019-10-17T01:03:51-04:00 Tiny fixes to comments around flattening. - - - - - c4c9904b by Ben Gamari at 2019-10-17T01:04:26-04:00 testsuite: Assert that testsuite ways are known This ensures that all testsuite way names given to `omit_ways`, `only_ways`, etc. are known ways. - - - - - 697be2b6 by Ömer Sinan Ağacan at 2019-10-18T15:26:53-04:00 rts/GC: Add an obvious assertion during block initialization Namely ensure that block descriptors are initialized with valid generation numbers. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 61d2ed42 by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Add Note explaining applicability of selector optimisation depth limit This was slightly non-obvious so a note seems deserved. - - - - - 11395037 by Ben Gamari at 2019-10-18T15:26:53-04:00 rts/Capability: A few documentation comments - - - - - 206f782a by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Give stack flags proper macros This were previously quite unclear and will change a bit under the non-moving collector so let's clear this up now. - - - - - 81d4675e by Ben Gamari at 2019-10-18T15:26:53-04:00 rts/GC: Refactor gcCAFs - - - - - 4d674c4e by Ben Gamari at 2019-10-18T15:26:53-04:00 rts: Fix macro parenthesisation - - - - - bfcafd39 by Ben Gamari at 2019-10-18T15:27:42-04:00 rts/Schedule: Allow synchronization without holding a capability The concurrent mark-and-sweep will be performed by a GHC task which will not hold a capability. This is necessary to avoid a concurrent mark from interfering with minor generation collections. However, the major collector must synchronize with the mutators at the end of marking to flush their update remembered sets. This patch extends the `requestSync` mechanism used to synchronize garbage collectors to allow synchronization without holding a capability. This change is fairly straightforward as the capability was previously only required for two reasons: 1. to ensure that we don't try to re-acquire a capability that we the sync requestor already holds. 2. to provide a way to suspend and later resume the sync request if there is already a sync pending. When synchronizing without holding a capability we needn't worry about consideration (1) at all. (2) is slightly trickier and may happen, for instance, when a capability requests a minor collection and shortly thereafter the non-moving mark thread requests a post-mark synchronization. In this case we need to ensure that the non-moving mark thread suspends his request until after the minor GC has concluded to avoid dead-locking. For this we introduce a condition variable, `sync_finished_cond`, which a non-capability-bearing requestor will wait on and which is signalled after a synchronization or GC has finished. - - - - - 921e4e36 by Ömer Sinan Ağacan at 2019-10-18T15:27:56-04:00 rts/BlockAlloc: Allow aligned allocation requests This implements support for block group allocations which are aligned to an integral number of blocks. This will be used by the nonmoving garbage collector, which uses the block allocator to allocate the segments which back its heap. These segments are a fixed number of blocks in size, with each segment being aligned to the segment size boundary. This allows us to easily find the segment metadata stored at the beginning of the segment. - - - - - 4b431f33 by Tamar Christina at 2019-10-20T16:21:10+01:00 Windows: Update tarballs to GCC 9.2 and remove MAX_PATH limit. - - - - - 8057ac96 by Ben Gamari at 2019-10-20T21:15:14-04:00 Merge branches 'wip/gc/sync-without-capability' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation - - - - - 32500f64 by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size These will be needed when we implement sweeping in the nonmoving collector. - - - - - 4be5152a by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Disable aggregate-return warnings from gcc This warning is a bit of a relic; there is little reason to avoid aggregate return values in 2019. - - - - - 04471c4f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts/Scav: Expose scavenging functions To keep the non-moving collector nicely separated from the moving collector its scavenging phase will live in another file, `NonMovingScav.c`. However, it will need to use these functions so let's expose them. - - - - - 6ff29c06 by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Introduce flag to enable the nonmoving old generation This flag will enable the use of a non-moving oldest generation. - - - - - b3ef2d1a by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Introduce debug flag for non-moving GC - - - - - 68e0647f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00 rts: Non-concurrent mark and sweep This implements the core heap structure and a serial mark/sweep collector which can be used to manage the oldest-generation heap. This is the first step towards a concurrent mark-and-sweep collector aimed at low-latency applications. The full design of the collector implemented here is described in detail in a technical note B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell Compiler" (2018) The basic heap structure used in this design is heavily inspired by K. Ueno & A. Ohori. "A fully concurrent garbage collector for functional programs on multicore processors." /ACM SIGPLAN Notices/ Vol. 51. No. 9 (presented by ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). The mark queue is a fairly straightforward chunked-array structure. The representation is a bit more verbose than a typical mark queue to accomodate a combination of two features: * a mark FIFO, which improves the locality of marking, reducing one of the major overheads seen in mark/sweep allocators (see [1] for details) * the selector optimization and indirection shortcutting, which requires that we track where we found each reference to an object in case we need to update the reference at a later point (e.g. when we find that it is an indirection). See Note [Origin references in the nonmoving collector] (in `NonMovingMark.h`) for details. Beyond this the mark/sweep is fairly run-of-the-mill. [1] R. Garner, S.M. Blackburn, D. Frampton. "Effective Prefetch for Mark-Sweep Garbage Collection." ISMM 2007. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - c7e73d12 by Ben Gamari at 2019-10-20T21:15:37-04:00 testsuite: Add nonmoving WAY This simply runs the compile_and_run tests with `-xn`, enabling the nonmoving oldest generation. - - - - - f8f77a07 by Ben Gamari at 2019-10-20T21:15:37-04:00 rts: Mark binder as const - - - - - bd8e3ff4 by Ben Gamari at 2019-10-20T21:15:52-04:00 rts: Implement concurrent collection in the nonmoving collector This extends the non-moving collector to allow concurrent collection. The full design of the collector implemented here is described in detail in a technical note B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell Compiler" (2018) This extension involves the introduction of a capability-local remembered set, known as the /update remembered set/, which tracks objects which may no longer be visible to the collector due to mutation. To maintain this remembered set we introduce a write barrier on mutations which is enabled while a concurrent mark is underway. The update remembered set representation is similar to that of the nonmoving mark queue, being a chunked array of `MarkEntry`s. Each `Capability` maintains a single accumulator chunk, which it flushed when it (a) is filled, or (b) when the nonmoving collector enters its post-mark synchronization phase. While the write barrier touches a significant amount of code it is conceptually straightforward: the mutator must ensure that the referee of any pointer it overwrites is added to the update remembered set. However, there are a few details: * In the case of objects with a dirty flag (e.g. `MVar`s) we can exploit the fact that only the *first* mutation requires a write barrier. * Weak references, as usual, complicate things. In particular, we must ensure that the referee of a weak object is marked if dereferenced by the mutator. For this we (unfortunately) must introduce a read barrier, as described in Note [Concurrent read barrier on deRefWeak#] (in `NonMovingMark.c`). * Stable names are also a bit tricky as described in Note [Sweeping stable names in the concurrent collector] (`NonMovingSweep.c`). We take quite some pains to ensure that the high thread count often seen in parallel Haskell applications doesn't affect pause times. To this end we allow thread stacks to be marked either by the thread itself (when it is executed or stack-underflows) or the concurrent mark thread (if the thread owning the stack is never scheduled). There is a non-trivial handshake to ensure that this happens without racing which is described in Note [StgStack dirtiness flags and concurrent marking]. Co-Authored-by: Ömer Sinan Ağacan <omer at well-typed.com> - - - - - dd1b4fdd by Ben Gamari at 2019-10-20T21:15:52-04:00 Nonmoving: Disable memory inventory with concurrent collection - - - - - 4a44ab33 by Ben Gamari at 2019-10-20T21:15:52-04:00 rts: Shrink size of STACK's dirty and marking fields - - - - - 10373416 by Ben Gamari at 2019-10-20T21:15:52-04:00 Don't cleanup until we've stopped the collector This requires that we break nonmovingExit into two pieces since we need to first stop the collector to relinquish any capabilities, then we need to shutdown the scheduler, then we need to free the nonmoving allocators. - - - - - 26c3827f by Ben Gamari at 2019-10-21T11:43:54-04:00 Nonmoving: Ensure write barrier vanishes in non-threaded RTS - - - - - 17e5a032 by Ben Gamari at 2019-10-21T11:43:54-04:00 ThreadPaused: Add barrer on updated thunk - - - - - 8ea316da by David Eichmann at 2019-10-22T02:07:48-04:00 CI: Always dump performance metrics. - - - - - aa31ceaf by Matthew Bauer at 2019-10-22T02:39:01-04:00 Replace freebsd-gnueabihf with freebsd FreeBSD does not support GNU libc, so it makes no sense to use this triple. Most likely previous builds were just using the FreeBSD libc instead of gnueabihf. To fix this, we should just use armv6-unknown-freebsd and armv7-unknown-freebsd triples. Note that both of these are actually "soft-float", not "hard-float". FreeBSD has never officially released hard-float arm32: https://wiki.freebsd.org/ARMTier1 - - - - - fd8b666a by Stefan Schulze Frielinghaus at 2019-10-22T02:39:03-04:00 Implement s390x LLVM backend. This patch adds support for the s390x architecture for the LLVM code generator. The patch includes a register mapping of STG registers onto s390x machine registers which enables a registerised build. - - - - - 2d2cc76f by Tilman Blumhagen at 2019-10-22T02:39:04-04:00 Documentation for (&&) and (&&) states that they are lazy in their second argument (fixes #17354) - - - - - 06d51c4e by Ben Gamari at 2019-10-22T12:13:36-04:00 Fix unregisterised build This required some fiddling around with the location of forward declarations since the C sources generated by GHC's C backend only includes Stg.h. - - - - - 912e440e by Ben Gamari at 2019-10-22T12:17:00-04:00 rts: Tracing support for nonmoving collection events This introduces a few events to mark key points in the nonmoving garbage collection cycle. These include: * `EVENT_CONC_MARK_BEGIN`, denoting the beginning of a round of marking. This may happen more than once in a single major collection since we the major collector iterates until it hits a fixed point. * `EVENT_CONC_MARK_END`, denoting the end of a round of marking. * `EVENT_CONC_SYNC_BEGIN`, denoting the beginning of the post-mark synchronization phase * `EVENT_CONC_UPD_REM_SET_FLUSH`, indicating that a capability has flushed its update remembered set. * `EVENT_CONC_SYNC_END`, denoting that all mutators have flushed their update remembered sets. * `EVENT_CONC_SWEEP_BEGIN`, denoting the beginning of the sweep portion of the major collection. * `EVENT_CONC_SWEEP_END`, denoting the end of the sweep portion of the major collection. - - - - - 9f42cd81 by Ben Gamari at 2019-10-22T12:17:00-04:00 rts: Introduce non-moving heap census This introduces a simple census of the non-moving heap (not to be confused with the heap census used by the heap profiler). This collects basic heap usage information (number of allocated and free blocks) which is useful when characterising fragmentation of the nonmoving heap. - - - - - 711837cc by Ben Gamari at 2019-10-22T12:17:00-04:00 rts/Eventlog: More descriptive error message - - - - - 0d31819e by Ben Gamari at 2019-10-22T12:17:00-04:00 Allow census without live word count Otherwise the census is unsafe when mutators are running due to concurrent mutation. - - - - - 6f173181 by Ben Gamari at 2019-10-22T12:17:00-04:00 NonmovingCensus: Emit samples to eventlog - - - - - 13dd78dd by Ben Gamari at 2019-10-22T12:18:33-04:00 Nonmoving: Allow aging and refactor static objects logic This commit does two things: * Allow aging of objects during the preparatory minor GC * Refactor handling of static objects to avoid the use of a hashtable - - - - - 7b79e8b4 by Ben Gamari at 2019-10-22T12:18:33-04:00 Disable aging when doing deadlock detection GC - - - - - 8fffe12b by Ben Gamari at 2019-10-22T12:18:33-04:00 More comments for aging - - - - - 039d2906 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Eliminate integer division in nonmovingBlockCount Perf showed that the this single div was capturing up to 10% of samples in nonmovingMark. However, the overwhelming majority of cases is looking at small block sizes. These cases we can easily compute explicitly, allowing the compiler to turn the division into a significantly more efficient division-by-constant. While the increase in source code looks scary, this all optimises down to very nice looking assembler. At this point the only remaining hotspots in nonmovingBlockCount are due to memory access. - - - - - d15ac82d by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Allocate mark queues in larger block groups - - - - - 26d2d331 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMovingMark: Optimize representation of mark queue This shortens MarkQueueEntry by 30% (one word) - - - - - e5eda61e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Optimize bitmap search during allocation Use memchr instead of a open-coded loop. This is nearly twice as fast in a synthetic benchmark. - - - - - dacf4cae by Ben Gamari at 2019-10-22T12:18:39-04:00 rts: Add prefetch macros - - - - - 786c52d2 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Prefetch when clearing bitmaps Ensure that the bitmap of the segmentt that we will clear next is in cache by the time we reach it. - - - - - 0387df5b by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Inline nonmovingClearAllBitmaps - - - - - e893877e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Fuse sweep preparation into mark prep - - - - - e6f6823f by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Pre-fetch during mark This improved overall runtime on nofib's constraints test by nearly 10%. - - - - - 56c5ebdc by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Prefetch segment header - - - - - 19bfe460 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Optimise allocator cache behavior Previously we would look at the segment header to determine the block size despite the fact that we already had the block size at hand. - - - - - 53a1a27e by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMovingMark: Eliminate redundant check_in_nonmoving_heaps - - - - - b967e470 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Don't do major GC if one is already running Previously we would perform a preparatory moving collection, resulting in many things being added to the mark queue. When we finished with this we would realize in nonmovingCollect that there was already a collection running, in which case we would simply not run the nonmoving collector. However, it was very easy to end up in a "treadmilling" situation: all subsequent GC following the first failed major GC would be scheduled as major GCs. Consequently we would continuously feed the concurrent collector with more mark queue entries and it would never finish. This patch aborts the major collection far earlier, meaning that we avoid adding nonmoving objects to the mark queue and allowing the concurrent collector to finish. - - - - - 3bc172a4 by Ben Gamari at 2019-10-22T12:18:39-04:00 NonMoving: Clean mut_list - - - - - 8e79e2a9 by Ben Gamari at 2019-10-22T12:18:39-04:00 Unconditionally flush update remembered set during minor GC Flush the update remembered set. The goal here is to flush periodically to ensure that we don't end up with a thread who marks their stack on their local update remembered set and doesn't flush until the nonmoving sync period as this would result in a large fraction of the heap being marked during the sync pause. - - - - - b281e80b by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Add nonmoving_thr way - - - - - 07987957 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Add nonmoving_thr_ghc way This uses the nonmoving collector when compiling the testcases. - - - - - 01fd0242 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T15892 in nonmoving ways The nonmoving GC doesn't support `+RTS -G1`, which this test insists on. - - - - - 097f4fd0 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Nonmoving collector doesn't support -G1 - - - - - 4b91dd25 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Ensure that threaded tests are run in nonmoving_thr - - - - - 78ce35b9 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: bug1010 requires -c, which isn't supported by nonmoving - - - - - 6e97cc47 by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Skip T15892 in nonmoving_thr_ghc - - - - - 5ce853c8 by Ben Gamari at 2019-10-22T12:18:44-04:00 ghc-heap: Skip heap_all test with debugged RTS The debugged RTS initializes the heap with 0xaa, which breaks the (admittedly rather fragile) assumption that uninitialized fields are set to 0x00: ``` Wrong exit code for heap_all(nonmoving)(expected 0 , actual 1 ) Stderr ( heap_all ): heap_all: user error (assertClosuresEq: Closures do not match Expected: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 0, code = Nothing}, ptrArgs = [], dataArgs = [0]} Actual: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 1032832, code = Nothing}, ptrArgs = [], dataArgs = [12297829382473034410]} CallStack (from HasCallStack): assertClosuresEq, called at heap_all.hs:230:9 in main:Main ) ``` - - - - - 6abefce7 by Ben Gamari at 2019-10-22T12:18:44-04:00 Skip ghc_heap_all test in nonmoving ways - - - - - 99baff8c by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T9630 in nonmoving ways The nonmoving collector doesn't support -G1 - - - - - 25ae8f7d by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Don't run T7160 in nonmoving_thr ways The nonmoving way finalizes things in a different order. - - - - - 8cab149b by Ben Gamari at 2019-10-22T12:18:44-04:00 testsuite: Mark length001 as failing under nonmoving ways This is consistent with the other unoptimized ways. - - - - - 5b130b3d by Ben Gamari at 2019-10-22T12:18:46-04:00 Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything - - - - - 246ce2af by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement indirection shortcutting This allows indirection chains residing in the non-moving heap to be shorted-out. - - - - - 875861ef by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement selector optimisation - - - - - c72e84c6 by Ben Gamari at 2019-10-22T12:20:15-04:00 NonMovingMark: Handle INDs left by shortcutting - - - - - 0f8fd3c6 by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00 NonMoving: Implement -xns to disable selector optimization - - - - - c936a245 by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor This will allow us to easily move the block size elsewhere. - - - - - 6dcef5ee by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Move block size to block descriptor - - - - - dd8d1b49 by Ben Gamari at 2019-10-22T12:20:37-04:00 NonMoving: Move next_free_snap to block descriptor - - - - - 116e4646 by Ben Gamari at 2019-10-22T12:20:46-04:00 NonMoving: Add summarizing Note - - - - - 22eee2bc by Ben Gamari at 2019-10-22T12:20:48-04:00 Merge branches 'wip/gc/segment-header-to-bdescr' and 'wip/gc/docs' into wip/gc/everything2 - - - - - 3a862703 by Ömer Sinan Ağacan at 2019-10-22T18:56:32-04:00 rts: COMPACT_NFDATA support for the nonmoving collector This largely follows the model used for large objects, with appropriate adjustments made to account for references in the sharing deduplication hashtable. - - - - - 7c35d39b by Ben Gamari at 2019-10-22T18:56:32-04:00 rts: Mark nonmoving GC paths in moving collector as unlikely The expectation here is that the nonmoving GC is latency-centric, whereas the moving GC emphasizes throughput. Therefore we give the latter the benefit of better static branch prediction. - - - - - 91109404 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Trace GC preparation steps - - - - - a69b28f4 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Don't do two passes over large and compact object lists Previously we would first move the new objects to their appropriate non-moving GC list, then do another pass over that list to clear their mark bits. This is needlessly expensive. First clear the mark bits of the existing objects, then add the newly evacuated objects and, at the same time, clear their mark bits. This cuts the preparatory GC time in half for the Pusher benchmark with a large queue size. - - - - - 984745b0 by Ben Gamari at 2019-10-22T18:57:27-04:00 nonmoving: Upper-bound time we hold SM_MUTEX for during sweep - - - - - 96c5411a by David Feuer at 2019-10-23T05:58:37-04:00 Use an IORef for QSemN Replace the outer `MVar` in `QSemN` with an `IORef`. This should probably be lighter, and it removes the need for `uninterruptibleMask`. Previously Differential Revision https://phabricator.haskell.org/D4896 - - - - - faa30dcb by Andreas Klebinger at 2019-10-23T05:58:43-04:00 Warn about missing profiled libs when using the Interpreter. When GHC itself, or it's interpreter is profiled we need to load profiled libraries as well. This requirement is not always obvious, especially when TH implicilty uses the interpreter. When the libs were not found we fall back to assuming the are in a DLL. This is usually not the case so now we warn users when we do so. This makes it more obvious what is happening and gives users a way to fix the issue. This fixes #17121. - - - - - 1cd3fa29 by Richard Eisenberg at 2019-10-23T05:58:46-04:00 Implement a coverage checker for injectivity This fixes #16512. There are lots of parts of this patch: * The main payload is in FamInst. See Note [Coverage condition for injective type families] there for the overview. But it doesn't fix the bug. * We now bump the reduction depth every time we discharge a CFunEqCan. See Note [Flatten when discharging CFunEqCan] in TcInteract. * Exploration of this revealed a new, easy to maintain invariant for CTyEqCans. See Note [Almost function-free] in TcRnTypes. * We also realized that type inference for injectivity was a bit incomplete. This means we exchanged lookupFlattenTyVar for rewriteTyVar. See Note [rewriteTyVar] in TcFlatten. The new function is monadic while the previous one was pure, necessitating some faff in TcInteract. Nothing too bad. * zonkCt did not maintain invariants on CTyEqCan. It's not worth the bother doing so, so we just transmute CTyEqCans to CNonCanonicals. * The pure unifier was finding the fixpoint of the returned substitution, even when doing one-way matching (in tcUnifyTysWithTFs). Fixed now. Test cases: typecheck/should_fail/T16512{a,b} - - - - - 900cf195 by Alp Mestanogullari at 2019-10-23T05:58:48-04:00 compiler: introduce DynFlags plugins They have type '[CommandLineOpts] -> Maybe (DynFlags -> IO DynFlags)'. All plugins that supply a non-Nothing 'dynflagsPlugin' will see their updates applied to the current DynFlags right after the plugins are loaded. One use case for this is to superseede !1580 for registering hooks from a plugin. Frontend/parser plugins were considered to achieve this but they respectively conflict with how this plugin is going to be used and don't allow overriding/modifying the DynFlags, which is how hooks have to be registered. This commit comes with a test, 'test-hook-plugin', that registers a "fake" meta hook that replaces TH expressions with the 0 integer literal. - - - - - a19c7d17 by Ryan Scott at 2019-10-23T05:58:49-04:00 Reify oversaturated data family instances correctly (#17296) `TcSplice` was not properly handling oversaturated data family instances, such as the example in #17296, as it dropped arguments due to carelessly zipping data family instance arguments with `tyConTyVars`. For data families, the number of `tyConTyVars` can sometimes be less than the number of arguments it can accept in a data family instance due to the fact that data family instances can be oversaturated. To account for this, `TcSplice.mkIsPolyTvs` has now been renamed to `tyConArgsPolyKinded` and now factors in `tyConResKind` in addition to `tyConTyVars`. I've also added `Note [Reified instances and explicit kind signatures]` which explains the various subtleties in play here. Fixes #17296. - - - - - 9b2a5008 by Ben Gamari at 2019-10-23T05:58:50-04:00 testsuite: Don't run T7653 in ghci and profiled ways Currently this routinely fails in the i386 job. See #7653. - - - - - b521e8b6 by Ömer Sinan Ağacan at 2019-10-23T05:58:57-04:00 Refactor Compact.c: - Remove forward declarations - Introduce UNTAG_PTR and GET_PTR_TAG for dealing with pointer tags without having to cast arguments to StgClosure* - Remove dead code - Use W_ instead of StgWord - Use P_ instead of StgPtr - - - - - 17987a4b by Matthew Pickering at 2019-10-23T05:58:58-04:00 eventlog: Dump cost centre stack on each sample With this change it is possible to reconstruct the timing portion of a `.prof` file after the fact. By logging the stacks at each time point a more precise executation trace of the program can be observed rather than all identical cost centres being identified in the report. There are two new events: 1. `EVENT_PROF_BEGIN` - emitted at the start of profiling to communicate the tick interval 2. `EVENT_PROF_SAMPLE_COST_CENTRE` - emitted on each tick to communicate the current call stack. Fixes #17322 - - - - - 4798f3b9 by Takenobu Tani at 2019-10-23T05:59:00-04:00 Allow command name resolution for GHCi commands with option `!` #17345 This commit allows command name resolution for GHCi commands with option `!` as follows: ghci> :k! Int Int :: * = Int This commit changes implementation as follows: Before: * Prefix match with full string including the option `!` (e.g. `k!`) After (this patch): * Prefix match without option suffix `!` (e.g. `k`) * in addition, suffix match with option `!` See also #8305 and #8113 - - - - - aa778152 by Andreas Klebinger at 2019-10-23T05:59:01-04:00 Fix bug in the x86 backend involving the CFG. This is part two of fixing #17334. There are two parts to this commit: - A bugfix for computing loop levels - A bugfix of basic block invariants in the NCG. ----------------------------------------------------------- In the first bug we ended up with a CFG of the sort: [A -> B -> C] This was represented via maps as fromList [(A,B),(B,C)] and later transformed into a adjacency array. However the transformation did not include block C in the array (since we only looked at the keys of the map). This was still fine until we tried to look up successors for C and tried to read outside of the array bounds when accessing C. In order to prevent this in the future I refactored to code to include all nodes as keys in the map representation. And make this a invariant which is checked in a few places. Overall I expect this to make the code more robust as now any failed lookup will represent an error, versus failed lookups sometimes being expected and sometimes not. In terms of performance this makes some things cheaper (getting a list of all nodes) and others more expensive (adding a new edge). Overall this adds up to no noteable performance difference. ----------------------------------------------------------- Part 2: When the NCG generated a new basic block, it did not always insert a NEWBLOCK meta instruction in the stream which caused a quite subtle bug. During instruction selection a statement `s` in a block B with control of the sort: B -> C will sometimes result in control flow of the sort: ┌ < ┐ v ^ B -> B1 ┴ -> C as is the case for some atomic operations. Now to keep the CFG in sync when introducing B1 we clearly want to insert it between B and C. However there is a catch when we have to deal with self loops. We might start with code and a CFG of these forms: loop: stmt1 ┌ < ┐ .... v ^ stmtX loop ┘ stmtY .... goto loop: Now we introduce B1: ┌ ─ ─ ─ ─ ─┐ loop: │ ┌ < ┐ │ instrs v │ │ ^ .... loop ┴ B1 ┴ ┘ instrsFromX stmtY goto loop: This is simple, all outgoing edges from loop now simply start from B1 instead and the code generator knows which new edges it introduced for the self loop of B1. Disaster strikes if the statement Y follows the same pattern. If we apply the same rule that all outgoing edges change then we end up with: loop ─> B1 ─> B2 ┬─┐ │ │ └─<┤ │ │ └───<───┘ │ └───────<────────┘ This is problematic. The edge B1->B1 is modified as expected. However the modification is wrong! The assembly in this case looked like this: _loop: <instrs> _B1: ... cmpxchgq ... jne _B1 <instrs> <end _B1> _B2: ... cmpxchgq ... jne _B2 <instrs> jmp loop There is no edge _B2 -> _B1 here. It's still a self loop onto _B1. The problem here is that really B1 should be two basic blocks. Otherwise we have control flow in the *middle* of a basic block. A contradiction! So to account for this we add yet another basic block marker: _B: <instrs> _B1: ... cmpxchgq ... jne _B1 jmp _B1' _B1': <instrs> <end _B1> _B2: ... Now when inserting B2 we will only look at the outgoing edges of B1' and everything will work out nicely. You might also wonder why we don't insert jumps at the end of _B1'. There is no way another block ends up jumping to the labels _B1 or _B2 since they are essentially invisible to other blocks. View them as control flow labels local to the basic block if you'd like. Not doing this ultimately caused (part 2 of) #17334. - - - - - 1f40e68a by Ryan Yates at 2019-10-23T05:59:03-04:00 Full abort on validate failure merging `orElse`. Previously partial roll back of a branch of an `orElse` was attempted if validation failure was observed. Validation here, however, does not account for what part of the transaction observed inconsistent state. This commit fixes this by fully aborting and restarting the transaction. - - - - - 9c1f0f7c by Ben Gamari at 2019-10-23T05:59:03-04:00 Bump stm submodule - - - - - 6beea836 by Andreas Klebinger at 2019-10-23T05:59:04-04:00 Make dynflag argument for withTiming pure. 19 times out of 20 we already have dynflags in scope. We could just always use `return dflags`. But this is in fact not free. When looking at some STG code I noticed that we always allocate a closure for this expression in the heap. Clearly a waste in these cases. For the other cases we can either just modify the callsite to get dynflags or use the _D variants of withTiming I added which will use getDynFlags under the hood. - - - - - 8dd480cc by Matthew Pickering at 2019-10-23T05:59:06-04:00 Performance tests: Reduce acceptance threshold for bytes allocated tests The "new" performance testing infrastructure resets the baseline after every test so it's easy to miss gradual performance regressions over time. We should at least make these numbers smaller to catch patches which affect performance earlier. - - - - - 4af20bbc by Ben Gamari at 2019-10-23T05:59:06-04:00 users-guide: Fix :since: for -Wunused-packages Fixes #17382. - - - - - 21663693 by Ben Gamari at 2019-10-23T05:59:07-04:00 Drop duplicate -optl's from GHC invocations Previously the make build system would pass things like `-optl-optl-Wl,-x -optl-optl-Wl,noexecstack` to GHC. This would naturally result in mass confusion as GHC would pass `-optl-Wl,-x` to GCC. GCC would in turn interpret this as `-o ptl-Wl,-x`, setting the output pass of the invocation. The problem that `-optl` was added to the command-line in two places in the build system. Fix this. Fixes #17385. - - - - - bb0dc5a5 by Andreas Klebinger at 2019-10-23T05:59:07-04:00 Hadrian: Invoke ghc0 via bash when running tests to fix #17362. cmd uses RawCommand which uses Windows semantics to find the executable which sometimes seems to fail for unclear reasons. If we invoke ghc via bash then bash will find the ghc executable and the issue goes away. - - - - - 266435a7 by Ömer Sinan Ağacan at 2019-10-23T05:59:09-04:00 Add new flag for unarised STG dumps Previously -ddump-stg would dump pre and post-unarise STGs. Now we have a new flag for post-unarise STG and -ddump-stg only dumps coreToStg output. STG dump flags after this commit: - -ddump-stg: Dumps CoreToStg output - -ddump-stg-unarised: Unarise output - -ddump-stg-final: STG right before code gen (includes CSE and lambda lifting) - - - - - 8abddac8 by Ben Gamari at 2019-10-23T05:59:10-04:00 base: Add @since on GHC.IO.Handle.Lock.hUnlock Unfortunately this was introduced in base-4.11.0 (GHC 8.4.1) whereas the other locking primitives were added in base-4.10.0 (GHC 8.2.1). - - - - - 7f72b540 by Ben Gamari at 2019-10-23T14:56:46-04:00 Merge non-moving garbage collector This introduces a concurrent mark & sweep garbage collector to manage the old generation. The concurrent nature of this collector typically results in significantly reduced maximum and mean pause times in applications with large working sets. Due to the large and intricate nature of the change I have opted to preserve the fully-buildable history, including merge commits, which is described in the "Branch overview" section below. Collector design ================ The full design of the collector implemented here is described in detail in a technical note > B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell > Compiler" (2018) This document can be requested from @bgamari. The basic heap structure used in this design is heavily inspired by > K. Ueno & A. Ohori. "A fully concurrent garbage collector for > functional programs on multicore processors." /ACM SIGPLAN Notices/ > Vol. 51. No. 9 (presented at ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). Implementation structure ======================== The majority of the collector is implemented in a handful of files: * `rts/Nonmoving.c` is the heart of the beast. It implements the entry-point to the nonmoving collector (`nonmoving_collect`), as well as the allocator (`nonmoving_allocate`) and a number of utilities for manipulating the heap. * `rts/NonmovingMark.c` implements the mark queue functionality, update remembered set, and mark loop. * `rts/NonmovingSweep.c` implements the sweep loop. * `rts/NonmovingScav.c` implements the logic necessary to scavenge the nonmoving heap. Branch overview =============== ``` * wip/gc/opt-pause: | A variety of small optimisations to further reduce pause times. | * wip/gc/compact-nfdata: | Introduce support for compact regions into the non-moving |\ collector | \ | \ | | * wip/gc/segment-header-to-bdescr: | | | Another optimization that we are considering, pushing | | | some segment metadata into the segment descriptor for | | | the sake of locality during mark | | | | * | wip/gc/shortcutting: | | | Support for indirection shortcutting and the selector optimization | | | in the non-moving heap. | | | * | | wip/gc/docs: | |/ Work on implementation documentation. | / |/ * wip/gc/everything: | A roll-up of everything below. |\ | \ | |\ | | \ | | * wip/gc/optimize: | | | A variety of optimizations, primarily to the mark loop. | | | Some of these are microoptimizations but a few are quite | | | significant. In particular, the prefetch patches have | | | produced a nontrivial improvement in mark performance. | | | | | * wip/gc/aging: | | | Enable support for aging in major collections. | | | | * | wip/gc/test: | | | Fix up the testsuite to more or less pass. | | | * | | wip/gc/instrumentation: | | | A variety of runtime instrumentation including statistics | | / support, the nonmoving census, and eventlog support. | |/ | / |/ * wip/gc/nonmoving-concurrent: | The concurrent write barriers. | * wip/gc/nonmoving-nonconcurrent: | The nonmoving collector without the write barriers necessary | for concurrent collection. | * wip/gc/preparation: | A merge of the various preparatory patches that aren't directly | implementing the GC. | | * GHC HEAD . . . ``` - - - - - 83655b06 by Ben Gamari at 2019-10-24T08:45:41-04:00 hadrian: Warn user if hadrian build fails due to lack of threaded RTS See #16873. - - - - - 6824f29a by Ryan Scott at 2019-10-24T08:46:19-04:00 Parenthesize GADT return types in pprIfaceConDecl (#17384) We were using `pprIfaceAppArgs` instead of `pprParendIfaceAppArgs` in `pprIfaceConDecl`. Oops. Fixes #17384. - - - - - 9de3f8b1 by Ryan Scott at 2019-10-24T18:38:32-04:00 Make isTcLevPoly more conservative with newtypes (#17360) `isTcLevPoly` gives an approximate answer for when a type constructor is levity polymorphic when fully applied, where `True` means "possibly levity polymorphic" and `False` means "definitely not levity polymorphic". `isTcLevPoly` returned `False` for newtypes, which is incorrect in the presence of `UnliftedNewtypes`, leading to #17360. This patch tweaks `isTcLevPoly` to return `True` for newtypes instead. Fixes #17360. - - - - - 243c72eb by Ryan Scott at 2019-10-24T18:39:08-04:00 Mark promoted InfixT names as IsPromoted (#17394) We applied a similar fix for `ConT` in #15572 but forgot to apply the fix to `InfixT` as well. This patch fixes #17394 by doing just that. - - - - - 87175e78 by James Foster at 2019-10-25T09:01:08-04:00 Make Hadrian use -dynamic-too in the basic case This commit makes Hadrian use the `-dynamic-too` flag when the current Flavour's libraryWays contains both vanilla and dynamic, cutting down the amount of repeated work caused by separate compilation of dynamic and static files. It does this for the basic case where '.o' and '.dyn_o' files are built with one command, but does not generalise to cases like '.prof_o' and '.prof_dyn_o'. - - - - - ecd89062 by Alp Mestanogullari at 2019-10-25T09:01:47-04:00 hadrian/ci: run testsuite against a freshly produced and installed bindist - - - - - 2a16b555 by Ben Gamari at 2019-10-25T09:02:26-04:00 testsuite: Mark T13786 as fragile in unreg build Due to #17018. - - - - - 08298926 by Ben Gamari at 2019-10-25T09:02:26-04:00 testsuite: Use fragile modifier in TH_foreignInterruptible It looks like this use of `skip` snuck through my previous refactoring. - - - - - 4c7d45d1 by Brian Wignall at 2019-10-25T09:03:04-04:00 Make documentation for byteSwap16 consistent with byteSwap32 (impl is same, with s/16/32) - - - - - 02822d84 by Ben Gamari at 2019-10-25T09:03:40-04:00 aclocal: A bit of reformatting - - - - - 519f5162 by Ben Gamari at 2019-10-25T09:03:40-04:00 configure: Drop GccLT46 GCC 4.6 was released 7 years ago. I think we can finally assume that it's available. This is a simplification prompted by #15742. - - - - - acedfc8b by Ben Gamari at 2019-10-25T09:04:16-04:00 gitlab-ci: Run check-uniques during lint job - - - - - 8916e64e by Andrew Martin at 2019-10-26T05:19:38-04:00 Implement shrinkSmallMutableArray# and resizeSmallMutableArray#. This is a part of GHC Proposal #25: "Offer more array resizing primitives". Resources related to the proposal: - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121 - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it. This commit also tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications. Additionally, the non-negativity assertion on the existing shrinkMutableByteArray# primop has been removed since this predicate is trivially always true. - - - - - 1be9c35c by Roland Senn at 2019-10-26T05:20:14-04:00 Fix #14690 - :steplocal panics after break-on-error `:steplocal` enables only breakpoints in the current top-level binding. When a normal breakpoint is hit, then the module name and the break id from the `BRK_FUN` byte code allow us to access the corresponding entry in a ModBreak table. From this entry we then get the SrcSpan (see compiler/main/InteractiveEval.hs:bindLocalsAtBreakpoint). With this source-span we can then determine the current top-level binding, needed for the steplocal command. However, if we break at an exception or at an error, we don't have an BRK_FUN byte-code, so we don't have any source information. The function `bindLocalsAtBreakpoint` creates an `UnhelpfulSpan`, which doesn't allow us to determine the current top-level binding. To avoid a `panic`, we have to check for `UnhelpfulSpan` in the function `ghc/GHCi/UI.hs:stepLocalCmd`. Hence a :steplocal command after a break-on-exception or a break-on-error is not possible. - - - - - 4820af10 by Adam Sandberg Eriksson at 2019-10-26T19:53:01-04:00 hadrian: point link to ghc gitlab [skip ci] - - - - - 609c7ee6 by Ben Gamari at 2019-10-26T19:53:36-04:00 gitlab-ci: Produce ARMv7 binary distributions - - - - - 8ac49411 by Ben Gamari at 2019-10-26T19:53:36-04:00 testsuite: Skip regalloc_unit_tests unless have_ncg This is a unit test for the native code generator's register allocator; naturally. the NCG is required. - - - - - 60575596 by Ben Gamari at 2019-10-26T19:53:36-04:00 Enable PDF documentation - - - - - 417f59d4 by Ben Gamari at 2019-10-26T19:53:36-04:00 rts: Fix ARM linker includes * Prefer #pragma once over guard macros * Drop redundant #includes * Fix order to ensure that necessary macros are defined when we condition on them - - - - - 4054f0e5 by Ömer Sinan Ağacan at 2019-10-26T19:54:16-04:00 Remove redundant -fno-cse options These were probably added with some GLOBAL_VARs, but those GLOBAL_VARs are now gone. - - - - - c62817f2 by Luke Lau at 2019-10-27T11:35:40-04:00 Fix RankNTypes :ghc-flag: in users guide This fixes a hadrian `build docs` failure - - - - - fc3a5205 by Luke Lau at 2019-10-27T11:35:40-04:00 Remove unused import - - - - - d2520bef by Luke Lau at 2019-10-27T11:35:40-04:00 Fix path to ghc-flags in users guide Hadrian rules It should point to the _build directory, not the source - - - - - 896d470a by Luke Lau at 2019-10-27T11:35:40-04:00 Add back documentation for deprecated -Whi-shadowing This was removed in b538476be3706264620c072e6e436debf9e0d3e4, but without it the compare-flags.py script fails. This adds it back and marks it as deprecated, with a notice that it is slated for removal. - - - - - 7d80f8b5 by Luke Lau at 2019-10-27T11:35:40-04:00 Remove documented flags from expected-undocumented-flags.txt - - - - - fa0d4809 by Ryan Scott at 2019-10-27T11:36:17-04:00 Parenthesize nullary constraint tuples using sigPrec (#17403) We were using `appPrec`, not `sigPrec`, as the precedence when determining whether or not to parenthesize `() :: Constraint`, which lead to the parentheses being omitted in function contexts like `(() :: Constraint) => String`. Easily fixed. Fixes #17403. - - - - - 90d06fd0 by Ben Gamari at 2019-10-27T17:27:17-04:00 hadrian: Silence output from Support SMP check Previously we would allow the output from the check of SMP support introduced by 83655b06e6d3e93b2d15bb0fa250fbb113d7fe68 leak to stdout. Silence this. See #16873. - - - - - 6635a3f6 by Josef Svenningsson at 2019-10-28T09:20:34-04:00 Fix #15344: use fail when desugaring applicative-do Applicative-do has a bug where it fails to use the monadic fail method when desugaring patternmatches which can fail. See #15344. This patch fixes that problem. It required more rewiring than I had expected. Applicative-do happens mostly in the renamer; that's where decisions about scheduling are made. This schedule is then carried through the typechecker and into the desugarer which performs the actual translation. Fixing this bug required sending information about the fail method from the renamer, through the type checker and into the desugarer. Previously, the desugarer didn't have enough information to actually desugar pattern matches correctly. As a side effect, we also fix #16628, where GHC wouldn't catch missing MonadFail instances with -XApplicativeDo. - - - - - cd9b9459 by Ryan Scott at 2019-10-28T09:21:13-04:00 Refactor TcDeriv to validity-check less in anyclass/via deriving (#13154) Due to the way `DerivEnv` is currently structured, there is an invariant that every derived instance must consist of a class applied to a non-empty list of argument types, where the last argument *must* be an application of a type constructor to some arguments. This works for many cases, but there are also some design patterns in standalone `anyclass`/`via` deriving that are made impossible due to enforcing this invariant, as documented in #13154. This fixes #13154 by refactoring `TcDeriv` and friends to perform fewer validity checks when using the `anyclass` or `via` strategies. The highlights are as followed: * Five fields of `DerivEnv` have been factored out into a new `DerivInstTys` data type. These fields only make sense for instances that satisfy the invariant mentioned above, so `DerivInstTys` is now only used in `stock` and `newtype` deriving, but not in other deriving strategies. * There is now a `Note [DerivEnv and DerivSpecMechanism]` describing the bullet point above in more detail, as well as explaining the exact requirements that each deriving strategy imposes. * I've refactored `mkEqnHelp`'s call graph to be slightly less complicated. Instead of the previous `mkDataTypeEqn`/`mkNewTypeEqn` dichotomy, there is now a single entrypoint `mk_eqn`. * Various bits of code were tweaked so as not to use fields that are specific to `DerivInstTys` so that they may be used by all deriving strategies, since not all deriving strategies use `DerivInstTys`. - - - - - e0e04856 by Alan Zimmerman at 2019-10-28T09:21:58-04:00 Attach API Annotations for {-# SOURCE #-} import pragma Attach the API annotations for the start and end locations of the {-# SOURCE #-} pragma in an ImportDecl. Closes #17388 - - - - - e951f219 by Sebastian Graf at 2019-10-28T09:22:35-04:00 Use FlexibleInstances for `Outputable (* p)` instead of match-all instances with equality constraints In #17304, Richard and Simon dicovered that using `-XFlexibleInstances` for `Outputable` instances of AST data types means users can provide orphan `Outputable` instances for passes other than `GhcPass`. Type inference doesn't currently to suffer, and Richard gave an example in #17304 that shows how rare a case would be where the slightly worse type inference would matter. So I went ahead with the refactoring, attempting to fix #17304. - - - - - ad1fe274 by Simon Peyton Jones at 2019-10-28T09:23:14-04:00 Better arity for join points A join point was getting too large an arity, leading to #17294. I've tightened up the invariant: see CoreSyn, Note [Invariants on join points], invariant 2b - - - - - fb4f245c by Takenobu Tani at 2019-10-29T03:45:02-04:00 users-guide: Fix :since: for -xn flag [skip ci] - - - - - 35abbfee by Takenobu Tani at 2019-10-29T03:45:41-04:00 users-guide: Add some new features and fix warnings for GHC 8.10 This updates the following: * Add description for ImportQualifiedPost extension * Add description for ghci command name resolution * Fix markdown warnings [skip ci] - - - - - 57dc1565 by Sylvain Henry at 2019-10-29T03:46:22-04:00 Use `not#` primitive to implement Word's complement - - - - - 28e52732 by Ben Gamari at 2019-10-29T03:46:59-04:00 linters: Add mode to lint given set of files This makes testing much easier. - - - - - db43b3b3 by Ben Gamari at 2019-10-29T03:46:59-04:00 linters: Add linter to catch unquoted use of $(TEST_HC) This is a common bug that creeps into Makefiles (e.g. see T12674). - - - - - ebee0d6b by Ben Gamari at 2019-10-29T03:46:59-04:00 testsuite: Fix quoting of $(TEST_HC) in T12674 I have no idea how this went unnoticed until now. - - - - - 3bd3456f by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Refactor HscRecomp constructors: Make it evident in the constructors that the final interface is only available when HscStatus is not HscRecomp. (When HscStatus == HscRecomp we need to finish the compilation to get the final interface) `Maybe ModIface` return value of hscIncrementalCompile and the partial `expectIface` function are removed. - - - - - bbdd54aa by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Return ModIface in compilation pipeline, remove IORef hack for generating ModIfaces The compilation phases now optionally return ModIface (for phases that generate an interface, currently only HscOut when (re)compiling a file). The value is then used by compileOne' to return the generated interface with HomeModInfo (which is then used by the batch mode compiler when building rest of the tree). hscIncrementalMode also returns a DynFlags with plugin info, to be used in the rest of the pipeline. Unfortunately this introduces a (perhaps less bad) hack in place of the previous IORef: we now record the DynFlags used to generate the partial infterface in HscRecomp and use the same DynFlags when generating the full interface. I spent almost three days trying to understand what's changing in DynFlags that causes a backpack test to fail, but I couldn't figure it out. There's a FIXME added next to the field so hopefully someone who understands this better than I do will fix it leter. - - - - - a56433a9 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 Remove unused DynFlags arg of lookupIfaceByModule - - - - - dcd40c71 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 HscMain: Move a comment closer to the relevant site - - - - - 593f6543 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00 MkIface: Remove redundant parameter and outdated comments from addFingerprints - - - - - f868e1fe by Ben Gamari at 2019-10-29T03:48:20-04:00 gitlab-ci: Use Hadrian for unregisterised job - - - - - 7b2ecbc0 by Ben Gamari at 2019-10-29T03:48:20-04:00 gitlab-ci: Factor out Linux Hadrian validation logic - - - - - 8e5de15d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Define USE_LIBFFI_FOR_ADJUSTORS when necessary - - - - - 6a090270 by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Define NOSMP when building rts unregisterised It seems that NOSMP was previously only defined when compiling the compiler, not the RTS. Fix this. In addition do some spring-cleaning and make the logic match that of the Make build system. - - - - - b741d19d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Shuffle around RTS build flags Some of these flags wanted to be passed to .cmm builds as well as C builds. - - - - - d7cedd9d by Ben Gamari at 2019-10-29T03:48:20-04:00 hadrian: Drop -Werror=unused-but-set-variable from GHC flags Previously `hadrian` would pass `-optc-Werror=unused-but-set-variable` to all GHC invocations. This was a difference from the make build system and cause the unregisterised build to fail as the C that GHC produces contains many unused functions. Drop it from the GHC flags. Note, however, that the flag is still present in `Settings.Builders.Common.cWarnings` and therefore will still be applied during compilation of C sources. - - - - - 7d3a15c7 by Ben Gamari at 2019-10-29T03:48:55-04:00 base: Fix open-file locking The OFD locking path introduced in 3b784d440d4b01b4c549df7c9a3ed2058edfc780 due to #13945 appears to have never actually worked but we never noticed due to an oversight in the autoconf check. Fix it. Thanks to Oleg Grenrus for noticing this. - - - - - 78b70e63 by Ben Gamari at 2019-10-29T03:48:55-04:00 base: Split up file locking implementation This makes the CPP significantly easier to follow. - - - - - 63977398 by Ben Gamari at 2019-10-29T03:49:31-04:00 Don't substitute GccVersion variable Not only is it now unused but we generally can't assume that we are compiling with GCC, so it really shouldn't be used. - - - - - 72f7ac9a by Ben Gamari at 2019-10-29T03:50:06-04:00 Revert "Replace freebsd-gnueabihf with freebsd" This reverts commit aa31ceaf7568802590f73a740ffbc8b800096342 as suggested in #17392. - - - - - 3c0372d6 by Ben Gamari at 2019-10-29T20:31:36-04:00 distrib: Fix binary distribution installation This had silently regressed due to 81860281 and the variable renaming performed in b55ee979, as noted in #17374. - - - - - a7f423ee by Ben Gamari at 2019-10-29T20:31:36-04:00 gitlab-ci: Use pxz to compress binary distributions - - - - - db602643 by Ben Gamari at 2019-10-29T20:31:36-04:00 Don't include settings file in binary distribution The configuration in the installation environment (as determined by `autoconf`) may differ from the build environment and therefore we need to be sure to rebuild the settings file. Fixes #17374. - - - - - 260e2379 by Ben Gamari at 2019-10-29T20:31:36-04:00 gitlab-ci: Fix binary distribution testing - - - - - 01ef3e1f by Ömer Sinan Ağacan at 2019-10-29T20:32:18-04:00 Interpreter: initialize arity fields of AP_NOUPDs AP_NOUPD entry code doesn't use the arity field, but not initializing this field confuses printers/debuggers, and also makes testing harder as the field's value changes randomly. - - - - - 93ff9197 by Ben Gamari at 2019-10-30T07:36:49-04:00 rts: More aarch64 header fixes - - - - - 3e7569bc by Vladislav Zavialov at 2019-10-30T07:36:50-04:00 Whitespace forward compatibility for proposal #229 GHC Proposal #229 changes the lexical rules of Haskell, which may require slight whitespace adjustments in certain cases. This patch changes formatting in a few places in GHC and its testsuite in a way that enables it to compile under the proposed rules. - - - - - 4898df1c by Ben Gamari at 2019-10-30T18:15:52-04:00 gitlab-ci: Fix the ARMv7 triple Previously we were configuring the ARMv7 builds with a host/target triple of arm-linux-gnueabihf, which caused us to target ARMv6 and consequently rely on the old CP15 memory barrier implementation. This barrier has to be emulated on ARMv8 machines which is glacially slow. Hopefully this should fix the ARMv7 builds which currently consistently time out. - - - - - 337e9b5a by Ömer Sinan Ağacan at 2019-10-31T19:01:54-04:00 Remove redundant 0s in ghc-heap pointer strings Before: 0x0000004200c86888 After: 0x42000224f8 This is more concise and consistent with the RTS's printer (which uses %p formatter, and at least on Linux gcc prints the short form) and gdb's pointer formatter. - - - - - 97b6f7a3 by Ben Gamari at 2019-10-31T19:02:32-04:00 base: Clamp IO operation size to 2GB on Darwin As reported in #17414, Darwin throws EINVAL in response to large writes. - - - - - a9743eb7 by Ben Gamari at 2019-10-31T19:02:32-04:00 testsuite: Add test for #17414 - - - - - 73d6e508 by Ben Gamari at 2019-10-31T19:03:10-04:00 base: Various haddock fixes Just a few things I found while looking at #17383. - - - - - dc487642 by taylorfausak at 2019-11-01T04:54:47-04:00 Implement `round` for `Ratio` that doesn't explode with `Natural`s - - - - - 3932fb97 by taylorfausak at 2019-11-01T04:54:47-04:00 Fix rounding around 0 - - - - - baf47ff8 by taylorfausak at 2019-11-01T04:54:47-04:00 Add tests for rounding ratios - - - - - 214d8122 by taylorfausak at 2019-11-01T04:54:47-04:00 Fix running of ratio test case - - - - - 70b62c97 by Ben Gamari at 2019-11-01T04:55:24-04:00 mmap: Factor out protection flags - - - - - c6759080 by Ben Gamari at 2019-11-01T04:55:24-04:00 rts: Make m32 allocator per-ObjectCode MacOS Catalina is finally going to force our hand in forbidden writable exeutable mappings. Unfortunately, this is quite incompatible with the current global m32 allocator, which mixes symbols from various objects in a single page. The problem here is that some of these symbols may not yet be resolved (e.g. had relocations performed) as this happens lazily (and therefore we can't yet make the section read-only and therefore executable). The easiest way around this is to simply create one m32 allocator per ObjectCode. This may slightly increase fragmentation for short-running programs but I suspect will actually improve fragmentation for programs doing lots of loading/unloading since we can always free all of the pages allocated to an object when it is unloaded (although this ability will only be implemented in a later patch). - - - - - 35c99e72 by Simon Peyton Jones at 2019-11-01T04:56:02-04:00 Makes Lint less chatty: I found in #17415 that Lint was printing out truly gigantic warnings, unmanageably huge, with repeated copies of the same thing. This patch makes Lint less chatty, especially for warnings: * For **warnings**, I don't print details of the location, unless you add `-dppr-debug`. * For **errors**, I still print all the info. They are fatal and stop exection, whereas warnings appear repeatedly. * I've made much less use of `AnExpr` in `LintLocInfo`; the expression can be gigantic. - - - - - d2471964 by Simon Peyton Jones at 2019-11-01T04:56:38-04:00 Add another test for #17267 This one came in a comment from James Payor - - - - - 1e2e82aa by Simon Peyton Jones at 2019-11-01T04:57:15-04:00 Fix a bad error in tcMatchTy This patch fixes #17395, a very subtle and hard-to-trigger bug in tcMatchTy. It's all explained in Note [Matching in the presence of casts (2)] I have not added a regression test because it is very hard to trigger it, until we have the upcoming mkAppTyM patch, after which lacking this patch means you can't even compile the libraries. - - - - - 51067194 by Ben Gamari at 2019-11-01T15:48:37-04:00 base: Ensure that failIO isn't SOURCE imported failIO has useful information in its demand signature (specifically that it bottoms) which is hidden if it is SOURCE imported, as noted in #16588. Rejigger things such that we don't SOURCE import it. Metric Increase: T13701 - - - - - c751082c by Ben Gamari at 2019-11-01T15:48:37-04:00 testsuite: Make ExplicitForAllRules1 more robust Previously the test relied on `id` not inlining. Fix this. - - - - - dab12c87 by Ben Gamari at 2019-11-01T15:48:37-04:00 Describe optimisation of demand analysis of noinline As described in #16588. - - - - - c9236384 by Adam Sandberg Eriksson at 2019-11-01T15:49:16-04:00 template-haskell: require at least 1 GADT constructor name (#17379) - - - - - a4ce26e0 by Ben Gamari at 2019-11-01T15:49:53-04:00 hadrian: Make runtest invocation consistency with Make Use True/False instead of 0/1. This shouldn't be a functional change but we should be consistent. - - - - - cabafe34 by Ben Gamari at 2019-11-01T15:50:29-04:00 testsuite: Add test for #17423 - - - - - 4a6d3d68 by Simon Peyton Jones at 2019-11-01T23:11:37-04:00 Make CSE delay inlining less CSE delays inlining a little bit, to avoid losing vital specialisations; see Note [Delay inlining after CSE] in CSE. But it was being over-enthusiastic. This patch makes the delay only apply to Ids with specialisation rules, which avoids unnecessary delay (#17409). - - - - - 01006bc7 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00 doc: Fix backticks - - - - - 9980fb58 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00 Add +RTS --disable-delayed-os-memory-return. Fixes #17411. Sets `MiscFlags.disableDelayedOsMemoryReturn`. See the added `Note [MADV_FREE and MADV_DONTNEED]` for details. - - - - - 182b1199 by Sebastian Graf at 2019-11-02T20:16:33-04:00 Separate `LPat` from `Pat` on the type-level Since the Trees That Grow effort started, we had `type LPat = Pat`. This is so that `SrcLoc`s would only be annotated in GHC's AST, which is the reason why all GHC passes use the extension constructor `XPat` to attach source locations. See #15495 for the design discussion behind that. But now suddenly there are `XPat`s everywhere! There are several functions which dont't cope with `XPat`s by either crashing (`hsPatType`) or simply returning incorrect results (`collectEvVarsPat`). This issue was raised in #17330. I also came up with a rather clean and type-safe solution to the problem: We define ```haskell type family XRec p (f :: * -> *) = r | r -> p f type instance XRec (GhcPass p) f = Located (f (GhcPass p)) type instance XRec TH f = f p type LPat p = XRec p Pat ``` This is a rather modular embedding of the old "ping-pong" style, while we only pay for the `Located` wrapper within GHC. No ping-ponging in a potential Template Haskell AST, for example. Yet, we miss no case where we should've handled a `SrcLoc`: `hsPatType` and `collectEvVarsPat` are not callable at an `LPat`. Also, this gets rid of one indirection in `Located` variants: Previously, we'd have to go through `XPat` and `Located` to get from `LPat` to the wrapped `Pat`. Now it's just `Located` again. Thus we fix #17330. - - - - - 3c916162 by Richard Eisenberg at 2019-11-02T20:17:13-04:00 Update Note references -- comments only Follow-on from !2041. - - - - - 3b65655c by Ben Gamari at 2019-11-04T03:40:31-05:00 SysTools: Only apply Windows-specific workaround on Windows Issue #1110 was apparently due to a bug in Vista which prevented GCC from finding its binaries unless we explicitly added it to PATH. However, this workaround was incorrectly applied on non-Windows platforms as well, resulting in ill-formed PATHs (#17266). Fixes #17266. - - - - - 5d4f16ee by Leif Metcalf at 2019-11-04T03:41:09-05:00 Rephrase note on full-laziness - - - - - 120f2e53 by Ben Gamari at 2019-11-04T03:41:44-05:00 rts/linker: Ensure that code isn't writable For many years the linker would simply map all of its memory with PROT_READ|PROT_WRITE|PROT_EXEC. However operating systems have been becoming increasingly reluctant to accept this practice (e.g. #17353 and #12657) and for good reason: writable code is ripe for exploitation. Consequently mmapForLinker now maps its memory with PROT_READ|PROT_WRITE. After the linker has finished filling/relocating the mapping it must then call mmapForLinkerMarkExecutable on the sections of the mapping which contain executable code. Moreover, to make all of this possible it was necessary to redesign the m32 allocator. First, we gave (in an earlier commit) each ObjectCode its own m32_allocator. This was necessary since code loading and symbol resolution/relocation are currently interleaved, meaning that it is not possible to enforce W^X when symbols from different objects reside in the same page. We then redesigned the m32 allocator to take advantage of the fact that all of the pages allocated with the allocator die at the same time (namely, when the owning ObjectCode is unloaded). This makes a number of things simpler (e.g. no more page reference counting; the interface provided by the allocator for freeing is simpler). See Note [M32 Allocator] for details. - - - - - 7c28087a by Takenobu Tani at 2019-11-05T02:45:31-05:00 users-guide: Improve documentaion of CPP extension Currently, the description of CPP extension is given in the section of command-line options. Therefore, it is a little difficult to understand that it is a language extension. This commit explicitly adds a description for it. [skip ci] - - - - - d57059f7 by Ben Gamari at 2019-11-05T02:46:10-05:00 rts: Add missing const in HEAP_ALLOCED_GC This was previously unnoticed as this code-path is hit on very few platforms (e.g. OpenBSD). - - - - - 487ede42 by Peter Trommler at 2019-11-05T02:46:48-05:00 testsuite: skip test requiring RTS linker on PowerPC The RTS linker is not available on 64-bit PowerPC. Instead of marking tests that require the RTS linker as broken on PowerPC 64-bit skip the respective tests on all platforms where the RTS linker or a statically linked external interpreter is not available. Fixes #11259 - - - - - 1593debf by Sebastian Graf at 2019-11-05T11:38:30-05:00 Check EmptyCase by simply adding a non-void constraint We can handle non-void constraints since !1733, so we can now express the strictness of `-XEmptyCase` just by adding a non-void constraint to the initial Uncovered set. For `case x of {}` we thus check that the Uncovered set `{ x | x /~ ⊥ }` is non-empty. This is conceptually simpler than the plan outlined in #17376, because it talks to the oracle directly. In order for this patch to pass the testsuite, I had to fix handling of newtypes in the pattern-match checker (#17248). Since we use a different code path (well, the main code path) for `-XEmptyCase` now, we apparently also handle #13717 correctly. There's also some dead code that we can get rid off now. `provideEvidence` has been updated to provide output more in line with the old logic, which used `inhabitationCandidates` under the hood. A consequence of the shift away from the `UncoveredPatterns` type is that we don't report reduced type families for empty case matches, because the pretty printer is pure and only knows the match variable's type. Fixes #13717, #17248, #17386 - - - - - e6ffe148 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00 TidyPgm: replace an explicit loop with mapAccumL - - - - - b7460492 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00 CoreTidy: hide tidyRule - - - - - f9978f53 by Stefan Schulze Frielinghaus at 2019-11-05T11:39:51-05:00 Hadrian: enable interpreter for s390x - - - - - 3ce18700 by Ben Gamari at 2019-11-06T08:05:57-05:00 rts: Drop redundant flags for libffi These are now handled in the cabal file's include-dirs field. - - - - - ce9e2a1a by Ben Gamari at 2019-11-06T08:05:57-05:00 configure: Add --with-libdw-{includes,libraries} flags Fixing #17255. - - - - - 97f9674b by Takenobu Tani at 2019-11-06T08:06:37-05:00 configure: Add checking python3-sphinx This checks the configuration about python3-sphinx. We need python3-sphinx instead of python2-sphinx to build documentation. The approach is as follows: * Check python3 version with custom `conf.py` invoked from sphinx-build` executable * Place custom `conf.py` into new `utils/check-sphinx` directory If sphinx is for python2 not python3, it's treated as config ERROR instead of WARN. See also #17346 and #17356. - - - - - b4fb2328 by Dan Brooks at 2019-11-06T08:07:15-05:00 Adding examples to Semigroup/monoid - - - - - 708c60aa by Ryan Scott at 2019-11-07T08:39:36-05:00 Clean up TH's treatment of unary tuples (or, #16881 part two) !1906 left some loose ends in regards to Template Haskell's treatment of unary tuples. This patch ends to tie up those loose ends: * In addition to having `TupleT 1` produce unary tuples, `TupE [exp]` and `TupP [pat]` also now produce unary tuples. * I have added various special cases in GHC's pretty-printers to ensure that explicit 1-tuples are printed using the `Unit` type. See `testsuite/tests/th/T17380`. * The GHC 8.10.1 release notes entry has been tidied up a little. Fixes #16881. Fixes #17371. Fixes #17380. - - - - - a424229d by Stefan Schulze Frielinghaus at 2019-11-07T08:40:13-05:00 For s390x issue a warning if LLVM 9 or older is used For s390x the GHC calling convention is only supported since LLVM version 10. Issue a warning in case an older version of LLVM is used. - - - - - 55bc3787 by Ben Gamari at 2019-11-07T08:40:50-05:00 FlagChecker: Add ticky flags to hashed flags These affect output and therefore should be part of the flag hash. - - - - - fa0b1b4b by Stefan Schulze Frielinghaus at 2019-11-07T08:41:33-05:00 Bump libffi-tarballs submodule - - - - - a9566632 by Takenobu Tani at 2019-11-07T08:42:15-05:00 configure: Modify ERROR to WARN for sphinx's python check If sphinx's python version check failed, many people prefer to build without documents instead of stopping on the error. So this commit fixes the following: * Modify AC_MSG_ERROR to AC_MSG_WARN * Add clearing of SPHINXBUILD variable when check fails See also !2016. - - - - - d0ef8312 by Alp Mestanogullari at 2019-11-07T21:24:59-05:00 hadrian: fix support for the recording of perf test results Before this patch, Hadrian didn't care about the TEST_ENV and METRICS_FILE environment variables, that the performance testing infrastructure uses to record perf tests results from CI jobs. It now looks them up right before running the testsuite driver, and passes suitable --test-env/--metrics-file arguments when these environment variables are set. - - - - - 601e554c by Ben Gamari at 2019-11-07T21:25:36-05:00 Bump the process submodule This should fix the #17108 and #17249 with the fix from https://github.com/haskell/process/pull/159. - - - - - 6b7d7e1c by Ben Gamari at 2019-11-07T21:25:36-05:00 Bump hsc2hs submodule - - - - - b1c158c9 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Fix m32 allocator build on Windows An inconsistency in the name of m32_allocator_flush caused the build to fail with a missing prototype error. - - - - - ae431cf4 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Ensure that Rts.h is always included first In general this is the convention that we use in the RTS. On Windows things actually fail if we break it. For instance, you see things like: includes\stg\Types.h:26:9: error: warning: #warning "Mismatch between __USE_MINGW_ANSI_STDIO definitions. If using Rts.h make sure it is the first header included." [-Wcpp] - - - - - 0d141d28 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts: Remove undesireable inline specifier I have no idea why I marked this as inline originally but clearly it shouldn't be inlined. - - - - - 870376f9 by Ben Gamari at 2019-11-07T21:25:36-05:00 base: Add missing imports in Windows locking implementation - - - - - 23994738 by Ben Gamari at 2019-11-07T21:25:36-05:00 rts/NonMoving: Fix various Windows build issues The Windows build seems to be stricter about not providing threading primitives in the non-threaded RTS. - - - - - a3ce52fd by Ben Gamari at 2019-11-07T21:25:36-05:00 users_guide: Set flags list file encoding Otherwise this fails on Windows. - - - - - 9db2e905 by Stefan Schulze Frielinghaus at 2019-11-08T05:36:54-05:00 Testsuite: Introduce req_rts_linker Some tests depend on the RTS linker. Introduce a modifier to skip such tests, in case the RTS linker is not available. - - - - - a4631335 by Szymon Nowicki-Korgol at 2019-11-08T05:37:34-05:00 Set correct length of DWARF .debug_aranges section (fixes #17428) - - - - - 3db2ab30 by Ben Gamari at 2019-11-08T05:38:11-05:00 hadrian: Add enableTickyGhc helper This took a bit of trial-and-error to get working so it seems worth having in the tree. - - - - - 5c87ebd7 by Ben Gamari at 2019-11-08T12:09:22-05:00 SetLevels: Don't set context level when floating cases When floating a single-alternative case we previously would set the context level to the level where we were floating the case. However, this is wrong as we are only moving the case and its binders. This resulted in #16978, where the disrepancy caused us to unnecessarily abstract over some free variables of the case body, resulting in shadowing and consequently Core Lint failures. (cherry picked from commit a2a0e6f3bb2d02a9347dec4c7c4f6d4480bc2421) - - - - - 43623b09 by Ben Gamari at 2019-11-08T12:10:01-05:00 testsuite: Run tests in nonmoving_thr in speed==slow - - - - - 6e4656cc by Ben Gamari at 2019-11-08T12:10:01-05:00 rts/nonmoving: Catch failure of createOSThread - - - - - 2e4fc04b by Ben Gamari at 2019-11-08T12:10:01-05:00 Bump unix submodule Marks executeFile001 as broken in all concurrent ways. - - - - - 8a10f9fb by Ben Gamari at 2019-11-09T18:03:01-05:00 template-haskell: Document assembler foreign file support See #16180. - - - - - 5ad3cb53 by Ben Gamari at 2019-11-09T18:03:01-05:00 template-haskell: Fix TBAs in changelog - - - - - 4a75a832 by Ben Gamari at 2019-11-09T18:03:01-05:00 base: Fix TBA in changelog - - - - - d7de0d81 by Ryan Scott at 2019-11-09T18:03:02-05:00 template-haskell: Fix italics in changelog [ci-skip] - - - - - 0fb246c3 by Ben Gamari at 2019-11-09T18:03:37-05:00 testsuite: Fix Windows cleanup path This was a regression introduced with the Path refactoring. - - - - - 925fbdbb by Ben Gamari at 2019-11-09T18:03:37-05:00 testsuite: Skip T16916 on Windows The event manager is not supported on Windows. - - - - - 7c2ce0a0 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Skip T14931 on Windows This test uses -dynamic-too, which is not supported on Windows. - - - - - 7c63edb4 by Ben Gamari at 2019-11-09T18:03:38-05:00 gitlab-ci: Don't allow Windows make job to fail While linking is still slow (#16084) all of the correctness issues which were preventing us from being able to enforce testsuite-green on Windows are now resolved. - - - - - a50ecda6 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Fix header #include order on Windows <Rts.h> must always come first. - - - - - dcb23ec9 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T13676 as broken on Darwin and Windows Due to #17447. - - - - - 411ba7ba by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T11627b as fragile It was previously marked as broken due to #12236 however it passes for me locally while failing on CI. - - - - - c1f1f3f9 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T16219 as unbroken This was previously broken due to #16386 yet it passes for me locally. - - - - - 1f871e70 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Remove redundant cleaning logic from T16511 The GHCi script for T16511 had some `rm` commands to clean up output from previous runs. This should be harmless since stderr was redirected to /dev/null; however, it seems that this redirection doesn't work on Windows (perhaps because GHCi uses `cmd` to execute the command-line; I'm not sure). I tried to fix it but was unable to find a sensible solution. Regardless, the cleaning logic is quite redundant now that we run each test in a hermetic environment. Let's just remove it. - - - - - 4d523cb1 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T17414 as fragile on Windows This consistently times out on Windows as described in #17453. I have tried increasing the timeout multiplier to two yet it stills fails. Disabling until we have time to investigate. - - - - - f73fbd2d by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Ignore stderr in PartialDownsweep As described in #17449, PartialDownsweep is currently fragile due to its dependence on the error messages produced by the C preprocessor. To eliminate this dependence we simply ignore stderr output, instead relying on the fact that the test will exit with a non-zero exit code on failure. Fixes #17449. - - - - - a9b14790 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Fix putStrLn in saks028 Bizarrely, `saks028` previously failed reliably, but only on Windows (#17450). The test would exit with a zero exit code but simply didn't emit the expected text to stderr. I believe this was due to the fact that the test used `putStrLn`, resulting in the output ending up on stdout. This worked on other platforms since (apparently) we redirect stdout to stderr when evaluating splices. However, on Windows it seems that the redirected output wasn't flushed as it was on other platforms. Anyways, it seems like the right thing to do here is to be explicit about our desire for the output to end up on stderr. Closes #17450. - - - - - b62ca659 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Drop T7995 This test is quite sensitive to the build configuration as it requires that ghc have unfoldings, which isn't true in the quick build flavours. I considered various options to make the test more robust but none of them seemed particularly appealing. Moreover, Simon PJ was a bit skeptical of the value of the test to begin with and I strongly suspect that any regression in #7995 would be accompanied by failures in our other compiler performance tests. Closes #17399. - - - - - 011f3121 by Ben Gamari at 2019-11-09T18:03:38-05:00 testsuite: Mark T16219 as fragile on Windows As noted in #17452, this test produces very long file paths which exceed the Windows MAX_PATH limitation. Mark the test as fragile for not until we can come up with a better solution. - - - - - 1f98e47d by Simon Peyton Jones at 2019-11-09T18:04:14-05:00 Use the right type in :force A missing prime meant that we were considering the wrong type in the GHCi debugger, when doing :force on multiple arguments (issue #17431). The fix is trivial. - - - - - 1f911de4 by Brian Wignall at 2019-11-09T18:04:57-05:00 Add IsList instance for ZipList (closes #17433) - - - - - e3672f40 by Brian Wignall at 2019-11-09T18:04:57-05:00 Incorporate MR review suggestions; add change in changelog - - - - - 3957bdf2 by Brian Wignall at 2019-11-09T18:04:57-05:00 Fix incorrect plurals - - - - - 6f4c1250 by Alina Banerjee at 2019-11-10T01:06:12-05:00 Improve SPECIALIZE pragma error messages (Fixes #12126) - - - - - fa25c8c4 by Richard Eisenberg at 2019-11-10T01:06:48-05:00 Update release notes about #16512 / #17405. - - - - - 55ca1085 by Richard Eisenberg at 2019-11-10T01:06:48-05:00 Fix #17405 by not checking imported equations Previously, we checked all imported type family equations for injectivity. This is very silly. Now, we check only for conflicts. Before I could even imagine doing the fix, I needed to untangle several functions that were (in my opinion) overly complicated. It's still not quite as perfect as I'd like, but it's good enough for now. Test case: typecheck/should_compile/T17405 - - - - - a9467f4f by Ben Gamari at 2019-11-10T21:06:33-05:00 testsuite: Mark tests fragile in threaded2 as fragile in all concurrent ways - - - - - 3e07ea8d by Ben Gamari at 2019-11-10T21:10:30-05:00 testsuite: Use small allocation area when measuring residency As suggested in #17387; this helps reduce the variance in our residency sampling. Metric Increase: T10370 T3586 lazy-bs-alloc Metric Decrease 'compile_time/peak_megabytes_allocated': T1969 Metric Decrease 'runtime/bytes allocated': space_leak_001 Metric Increase 'compile_time/bytes allocated': T1969 Metric Increase 'runtime/peak_megabytes_allocated': space_leak_001 Metric Decrease: T3064 T9675 - - - - - 049d9ae0 by Ben Gamari at 2019-11-10T21:10:30-05:00 testsuite: Don't check_stats at runtime if not requested Previously we would call check_stats to check the runtime metrics even if the test definition hadn't requested it. This would result in an error since the .stats file doesn't exist. - - - - - 64433428 by Alp Mestanogullari at 2019-11-11T08:49:01-05:00 hadrian: export METRICS_FILE to make it accessible to perf notes script This addresses #17456 and also fixes the --metrics-file argument that Hadrian passes to the testsuite driver. - - - - - 06640394 by Ben Gamari at 2019-11-11T08:50:45-05:00 testsuite: Disable T4334 in nonmoving_thr way - - - - - f8ec32d7 by Alp Mestanogullari at 2019-11-11T11:36:44-05:00 ci: push perf test metrics even when the testsuite doesn't pass The corresponding commit might introduce a regression on a perf test, in which case we certainly want to record it. The testsuite might also fail because of a test unrelated to performance, in which case we want to record that the perf test results were good. Either way, we likely want to record them under all circumstances but we don't without this patch. Metric Decrease: T3586 Metric Increase: lazy-bs-alloc - - - - - 643d42fc by Alp Mestanogullari at 2019-11-12T18:40:19-05:00 testsuite: don't collect compiler stats in collect_runtime_residency We instead want to collect the runtime stats (with collect_stats, instead of collect_compiler_stats). This should fix a number of perf tests failures we have been seeing, where we suddenly started measuring metrics we didn't intend to measure, which tend to fall outside of the acceptance window. Metric Decrease: lazy-bs-alloc T3586 Metric Increase: space_leak_001 T4801 T5835 T12791 - - - - - 535d0edc by Ömer Sinan Ağacan at 2019-11-13T07:06:12-05:00 Document CmmTopInfo type [ci skip] - - - - - 2d4f9ad8 by Ben Gamari at 2019-11-13T07:06:49-05:00 Ensure that coreView/tcView are able to inline Previously an import cycle between Type and TyCoRep meant that several functions in TyCoRep ended up SOURCE import coreView. This is quite unfortunate as coreView is intended to be fused into a larger pattern match and not incur an extra call. Fix this with a bit of restructuring: * Move the functions in `TyCoRep` which depend upon things in `Type` into `Type` * Fold contents of `Kind` into `Type` and turn `Kind` into a simple wrapper re-exporting kind-ish things from `Type` * Clean up the redundant imports that popped up as a result Closes #17441. Metric Decrease: T4334 - - - - - b795637f by Alp Mestanogullari at 2019-11-13T07:07:28-05:00 hadrian: fix Windows CI script By only using 'export' from within bash commands. - - - - - 6885e22c by Ben Gamari at 2019-11-13T07:08:03-05:00 testsuite: Add test for #17458 As noted in #17458, QuantifiedConstraints and UndecideableInstances could previously be used to write programs which can loop at runtime. This was fixed in !1870. - - - - - b4b19d89 by Ben Gamari at 2019-11-13T07:08:03-05:00 users guide: Fix broken link - - - - - 9a939a6c by Ryan Scott at 2019-11-13T07:08:40-05:00 Print name prefixly in the Outputable instance for StandaloneKindSig Issue #17461 was occurring because the `Outputable` instance for standalone kind signatures was simply calling `ppr` on the name in the kind signature, which does not add parentheses to infix names. The solution is simple: use `pprPrefixOcc` instead. Fixes #17461. - - - - - a06cfb59 by Ömer Sinan Ağacan at 2019-11-13T07:09:18-05:00 Only pass mod_location with HscRecomp instead of the entire ModSummary HscRecomp users only need the ModLocation of the module being compiled, so only pass that to users instead of the entire ModSummary Metric Decrease: T4801 - - - - - dd49b3f0 by Ben Gamari at 2019-11-13T17:01:21-05:00 Bump Haskeline and add exceptions as boot library Haskeline now depends upon exceptions. See #16752. - - - - - b06b1858 by Ben Gamari at 2019-11-14T11:30:20-05:00 base: Bump version to 4.14.0.0 Metric Increase: T4801 - - - - - 6ab80439 by Ben Gamari at 2019-11-14T23:05:30-05:00 gitlab-ci: Allow Windows to fail again - - - - - 46afc380 by Ben Gamari at 2019-11-15T09:45:36-05:00 gitlab-ci: Install process to global pkgdb before starting build This is an attempt to mitigate #17480 by ensuring that a functional version of the process library is available before attempting the build. - - - - - 8c5cb806 by Ben Gamari at 2019-11-15T10:45:55-05:00 Bump supported LLVM version to 9.0 - - - - - 8e5851f0 by Ben Gamari at 2019-11-15T10:45:55-05:00 llvm-targets: Update with Clang 9 - - - - - f3ffec27 by Ben Gamari at 2019-11-15T11:54:26-05:00 testsuite: Increase acceptance window of T4801 This statistic is rather unstable. Hopefully fixes #17475. - - - - - c2991f16 by Ben Gamari at 2019-11-15T11:56:10-05:00 users-guide: Drop 8.6.1 release notes - - - - - e8da1354 by Ben Gamari at 2019-11-17T06:48:16-05:00 gitlab-ci: Fix submodule linter We ran it against the .git directory despite the fact that the linter wants to be run against the repository. - - - - - 13290f91 by Ben Gamari at 2019-11-17T06:48:16-05:00 Bump version to 8.10.0 Bumps haddock submodule. - - - - - fa98f823 by Ben Gamari at 2019-11-17T06:48:16-05:00 testsuite: Don't collect residency for T4801 I previously increased the size of the acceptance window from 2% to 5% but this still isn't enough. Regardless, measuring bytes allocated should be sufficient to catch any regressions. - - - - - 002b2842 by Ivan Kasatenko at 2019-11-17T06:49:22-05:00 Make test 16916 more stable across runs - - - - - ca89dd3b by Ben Gamari at 2019-11-17T06:58:17-05:00 users-guide: Address #17329 Adopts the language suggested by @JakobBruenker. - - - - - 2f5ed225 by Ben Gamari at 2019-11-17T07:16:32-05:00 exceptions: Bump submodule back to master The previous commit hasn't made it to master yet. - - - - - 34515e7c by nineonine at 2019-11-17T13:33:22-08:00 Fix random typos [skip ci] - - - - - 4a37a29b by Mario Blažević at 2019-11-17T17:26:24-05:00 Fixed issue #17435, missing Data instances - - - - - 97f1bcae by Andreas Klebinger at 2019-11-17T17:26:24-05:00 Turn some comments into GHC.Hs.Utils into haddocks - - - - - cf7f8e5b by Ben Gamari at 2019-11-17T17:26:26-05:00 testsuite: Skip T17414 on Linux It is typical for $TMP to be a small tmpfson Linux. This test will fail in such cases since we must create a file larger than the filesystem. See #17459. - - - - - 88013b78 by nineonine at 2019-11-19T11:53:16-05:00 Optimize MonadUnique instances based on IO (#16843) Metric Decrease: T14683 - - - - - a8adb5b4 by Ben Gamari at 2019-11-19T11:53:55-05:00 desugar: Drop stale Note [Matching seqId] The need for this note vanished in eae703aa60f41fd232be5478e196b661839ec3de. - - - - - 08d595c0 by Ben Gamari at 2019-11-19T11:53:55-05:00 Give seq a more precise type and remove magic `GHC.Prim.seq` previously had the rather plain type: seq :: forall a b. a -> b -> b However, it also had a special typing rule to applications where `b` is not of kind `Type`. Issue #17440 noted that levity polymorphism allows us to rather give it the more precise type: seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b This allows us to remove the special typing rule that we previously required to allow applications on unlifted arguments. T9404 contains a non-Type application of `seq` which should verify that this works as expected. Closes #17440. - - - - - ec8a463d by Viktor Dukhovni at 2019-11-19T11:54:45-05:00 Enable USE_PTHREAD_FOR_ITIMER also on FreeBSD If using a pthread instead of a timer signal is more reliable, and has no known drawbacks, then FreeBSD is also capable of supporting this mode of operation (tested on FreeBSD 12 with GHC 8.8.1, but no reason why it would not also work on FreeBSD 11 or GHC 8.6). Proposed by Kevin Zhang in: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241849 - - - - - cd40e12a by Ömer Sinan Ağacan at 2019-11-19T11:55:36-05:00 Packages.hs: use O(n*log(n)) ordNub instead of O(n*n) nub As reported in #8173 in some environments package lists can get quite long, so we use more efficient ordNub instead of nub on package lists. - - - - - 2b27cc16 by Ben Gamari at 2019-11-19T11:56:21-05:00 Properly account for libdw paths in make build system Should finally fix #17255. - - - - - 0418c38d by Ben Gamari at 2019-11-19T11:56:58-05:00 rts: Add missing include of SymbolExtras.h This broke the Windows build. - - - - - c819c0e4 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Use correct info table pointer accessor Previously we used INFO_PTR_TO_STRUCT instead of THUNK_INFO_PTR_TO_STRUCT when looking at a thunk. These two happen to be equivalent on 64-bit architectures due to alignment considerations however they are different on 32-bit platforms. This lead to #17487. To fix this we also employ a small optimization: there is only one thunk of type WHITEHOLE (namely stg_WHITEHOLE_info). Consequently, we can just use a plain pointer comparison instead of testing against info->type. - - - - - deed8e31 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Fix incorrect masking in mark queue type test We were using TAG_BITS instead of TAG_MASK. This happened to work on 64-bit platforms where TAG_BITS==3 since we only use tag values 0 and 3. However, this broken on 32-bit platforms where TAG_BITS==2. - - - - - 097f8072 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Rework mark queue representation The previous representation needlessly limited the array length to 16-bits on 32-bit platforms. - - - - - eb7b233a by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Fix handling on large object marking on 32-bit Previously we would reset the pointer pointing to the object to be marked to the beginning of the block when marking a large object. This did no harm on 64-bit but on 32-bit it broke, e.g. `arr020`, since we align pinned ByteArray allocations such that the payload is 8 byte-aligned. This means that the object might not begin at the beginning of the block., - - - - - a7571a74 by Ben Gamari at 2019-11-19T11:57:36-05:00 testsuite: Increase width of stack003 test Previously the returned tuple seemed to fit in registers on amd64. This meant that non-moving collector bug would cause the test to fail on i386 yet not amd64. - - - - - 098d5017 by Ben Gamari at 2019-11-19T11:57:36-05:00 nonmoving: Drop redundant write barrier on stack underflow Previously we would push stack-carried return values to the new stack on a stack overflow. While the precise reasoning for this barrier is unfortunately lost to history, in hindsight I suspect it was prompted by a missing barrier elsewhere (that has been since fixed). Moreover, there the redundant barrier is actively harmful: the stack may contain non-pointer values; blindly pushing these to the mark queue will result in a crash. This is precisely what happened in the `stack003` test. However, because of a (now fixed) deficiency in the test this crash did not trigger on amd64. - - - - - e57b7cc6 by Roland Zumkeller at 2019-11-19T20:39:19-05:00 Changing Thread IDs from 32 bits to 64 bits. - - - - - d1f3c637 by Roland Zumkeller at 2019-11-19T20:39:19-05:00 Use pointer equality in Eq/Ord for ThreadId Changes (==) to use only pointer equality. This is safe because two threads are the same iff they have the same id. Changes `compare` to check pointer equality first and fall back on ids only in case of inequality. See discussion in #16761. - - - - - ef8a08e0 by Alexey Kuleshevich at 2019-11-19T20:39:20-05:00 hpc: Fix encoding issues. Add test for and fix #17073 * Make sure files are being read/written in UTF-8. Set encoding while writing HTML output. Also set encoding while writing and reading .tix files although we don't yet have a ticket complaining that this poses problems. * Set encoding in html header to utf8 * Upgrade to new version of 'hpc' library and reuse `readFileUtf8` and `writeFileUtf8` functions * Update git submodule for `hpc` * Bump up `hpc` executable version Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - b79e46d6 by Vladislav Zavialov at 2019-11-19T20:39:20-05:00 Strip parentheses in expressions contexts in error messages This makes error messages a tad less noisy. - - - - - 13bbde77 by Ben Gamari at 2019-11-21T13:56:56-05:00 Bump hsc2hs submodule Including Phyx's backport of the process changes fixing #17480. - - - - - d4d10501 by Ben Gamari at 2019-11-23T09:42:38-05:00 Bump hsc2hs submodule again This fixes the Darwin build. - - - - - 889d475b by nineonine at 2019-11-23T18:53:29-05:00 Fix typo in Note reference [skip ci] - - - - - 8a33abfc by Ryan Scott at 2019-11-23T18:54:05-05:00 Target the IsList instance for ZipList at base-4.14.0.0 (#17489) This moves the changelog entry about the instance from `base-4.15.0.0` to `base-4.14.0.0`. This accomplishes part (1) from #17489. [ci skip] - - - - - e43e6ece by Ben Gamari at 2019-11-23T18:54:41-05:00 rts: Expose interface for configuring EventLogWriters This exposes a set of interfaces from the GHC API for configuring EventLogWriters. These can be used by consumers like [ghc-eventlog-socket](https://github.com/bgamari/ghc-eventlog-socket). - - - - - de6bbdf2 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00 Take care to not eta-reduce jumps in CorePrep CorePrep already had a check to prevent it from eta-reducing Ids that respond true to hasNoBinding (foreign calls, constructors for unboxed sums and products, and Ids with compulsory unfoldings). It did not, however, consider join points as ids that 'must be saturated'. Checking whether the Id responds True to 'isJoinId' should prevent CorePrep from turning saturated jumps like the following (from #17429) into undersaturated ones: (\ eta_XP -> join { mapped_s1vo _ = lvl_s1vs } in jump mapped_s1vo eta_XP) - - - - - 4a1e7e47 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00 Make CorePrep.tryEtaReducePrep and CoreUtils.tryEtaReduce line up Simon PJ says he prefers this fix to #17429 over banning eta-reduction for jumps entirely. Sure enough, this also works. Test case: simplCore/should_compile/T17429.hs - - - - - 15f1dc33 by Ryan Scott at 2019-11-23T18:56:00-05:00 Prevent -optc arguments from being duplicated in reverse order (#17471) This reverts a part of commit 7bc5d6c6578ab9d60a83b81c7cc14819afef32ba that causes all arguments to `-optc` (and `-optcxx`) to be passed twice to the C/C++ compiler, once in reverse order and then again in the correct order. While passing duplicate arguments is usually harmless it can cause breakage in this pattern, which is employed by Hackage libraries in the wild: ``` ghc Foo.hs foo.c -optc-D -optcFOO ``` As `FOO -D -D FOO` will cause compilers to error. Fixes #17471. - - - - - e85c9b22 by Ben Gamari at 2019-11-23T18:56:36-05:00 Bump ghc version to 8.11 - - - - - 0e6c2045 by Ben Gamari at 2019-11-23T18:57:12-05:00 rts: Consolidate spinlock implementation Previously we had two distinct implementations: one with spinlock profiling and another without. This seems like needless duplication. - - - - - cb11fcb5 by Ben Gamari at 2019-11-23T18:57:49-05:00 Packages: Don't use expectJust Throw a slightly more informative error on failure. Motivated by the errors seen in !2160. - - - - - 5747ebe9 by Sebastian Graf at 2019-11-23T18:58:25-05:00 Stricten functions ins GHC.Natural This brings `Natural` on par with `Integer` and fixes #17499. Also does some manual CSE for 0 and 1 literals. - - - - - c14b723f by Ömer Sinan Ağacan at 2019-11-23T18:59:06-05:00 Bump exceptions submodule Adds a few files generated by GHC's configure script to .gitignore - - - - - 7b4c7b75 by Brian Wignall at 2019-11-23T19:04:52-05:00 Fix typos - - - - - 6008206a by Viktor Dukhovni at 2019-11-24T14:33:18-05:00 On FreeBSD 12 sys/sysctl.h requires sys/types.h Else build fails with: In file included from ExecutablePath.hsc:42: /usr/include/sys/sysctl.h:1062:25: error: unknown type name 'u_int'; did you mean 'int'? int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); ^~~~~ int compiling libraries/base/dist-install/build/System/Environment/ExecutablePath_hsc_make.c failed (exit code 1) Perhaps also also other FreeBSD releases, but additional include will no harm even if not needed. - - - - - b694b566 by Ben Gamari at 2019-11-24T14:33:54-05:00 configure: Fix HAVE_C11_ATOMICS macro Previously we were using AC_DEFINE instead of AC_DEFINE_UNQUOTED, resulted in the variable not being interpolated. Fixes #17505. - - - - - 8b8dc366 by Krzysztof Gogolewski at 2019-11-25T14:37:38+01:00 Remove prefix arrow support for GADTs (#17211) This reverts the change in #9096. The specialcasing done for prefix (->) is brittle and does not support VTA, type families, type synonyms etc. - - - - - 5a08f7d4 by Sebastian Graf at 2019-11-27T00:14:59-05:00 Make warnings for TH splices opt-in In #17270 we have the pattern-match checker emit incorrect warnings. The reason for that behavior is ultimately an inconsistency in whether we treat TH splices as written by the user (`FromSource :: Origin`) or as generated code (`Generated`). This was first reported in #14838. The current solution is to TH splices as `Generated` by default and only treat them as `FromSource` when the user requests so (-fenable-th-splice-warnings). There are multiple reasons for opt-in rather than opt-out: * It's not clear that the user that compiles a splice is the author of the code that produces the warning. Think of the situation where she just splices in code from a third-party library that produces incomplete pattern matches. In this scenario, the user isn't even able to fix that warning. * Gathering information for producing the warnings (pattern-match check warnings in particular) is costly. There's no point in doing so if the user is not interested in those warnings. Fixes #17270, but not #14838, because the proper solution needs a GHC proposal extending the TH AST syntax. - - - - - 8168b42a by Vladislav Zavialov at 2019-11-27T11:32:18+03:00 Whitespace-sensitive bang patterns (#1087, #17162) This patch implements a part of GHC Proposal #229 that covers five operators: * the bang operator (!) * the tilde operator (~) * the at operator (@) * the dollar operator ($) * the double dollar operator ($$) Based on surrounding whitespace, these operators are disambiguated into bang patterns, lazy patterns, strictness annotations, type applications, splices, and typed splices. This patch doesn't cover the (-) operator or the -Woperator-whitespace warning, which are left as future work. - - - - - 9e5477c4 by Ryan Scott at 2019-11-27T20:01:50-05:00 Fix @since annotations for isResourceVanishedError and friends (#17488) - - - - - e122ba33 by Sergei Trofimovich at 2019-11-27T20:02:29-05:00 .gitmodules: tweak 'exception' URL to avoid redirection warnings Avoid initial close warning of form: ``` Cloning into 'exceptions'... warning: redirecting to https://gitlab.haskell.org/ghc/packages/exceptions.git/ ``` Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 5f84b52a by Philipp Krüger at 2019-11-28T02:54:05-05:00 Reduce boolean blindness in OccInfo(OneOcc) #17482 * Transformed the type aliases `InterestingCxt`, `InsideLam` and `OneBranch` into data types. * Added Semigroup and Monoid instances for use in orOccInfo in OccurAnal.hs * Simplified some usage sites by using pattern matching instead of boolean algebra. Metric Increase: T12150 This increase was on a Mac-build of exactly 1%. This commit does *not* re-intruduce the asymptotic memory usage described in T12150. - - - - - 3748ba3a by Brian Wignall at 2019-11-28T02:54:52-05:00 Fix typos, using Wikipedia list of common typos - - - - - 6c59cc71 by Stefan Schulze Frielinghaus at 2019-11-28T02:55:33-05:00 Fix endian handling of LLVM backend Get rid of CPP macro WORDS_BIGENDIAN which is not defined anymore, and replace it by DynFlag. This fixes partially #17337. - - - - - 6985e0fc by Vladislav Zavialov at 2019-11-28T15:47:53+03:00 Factor out HsSCC/HsCoreAnn/HsTickPragma into HsPragE This is a refactoring with no user-visible changes (except for GHC API users). Consider the HsExpr constructors that correspond to user-written pragmas: HsSCC representing {-# SCC ... #-} HsCoreAnn representing {-# CORE ... #-} HsTickPragma representing {-# GENERATED ... #-} We can factor them out into a separate datatype, HsPragE. It makes the code a bit tidier, especially in the parser. Before this patch: hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))), ((SourceText,SourceText),(SourceText,SourceText)) ) } After this patch: prag_hpc :: { Located ([AddAnn], HsPragE GhcPs) } - - - - - 7f695a20 by Ömer Sinan Ağacan at 2019-11-29T08:25:28-05:00 Pass ModDetails with (partial) ModIface in HscStatus (Partial) ModIface and ModDetails are generated at the same time, but they're passed differently: ModIface is passed in HscStatus consturctors while ModDetails is returned in a tuple. This refactors ModDetails passing so that it's passed around with ModIface in HscStatus constructors. This makes the code more consistent and hopefully easier to understand: ModIface and ModDetails are really very closely related. It makes sense to treat them the same way. - - - - - e921c90f by Ömer Sinan Ağacan at 2019-11-29T08:26:07-05:00 Improve few Foreign.Marshal.Utils docs In copyBytes and moveBytes mention which argument is source and which is destination. Also fixes some of the crazy indentation in the module and cleans trailing whitespace. - - - - - 316f2431 by Sebastian Graf at 2019-11-30T02:57:58-05:00 Hadrian docs: Rename the second "validate" entry to "slow-validate" [ci skip] That would be in line with the implementation. - - - - - 5aba5d32 by Vladislav Zavialov at 2019-11-30T02:58:34-05:00 Remove HasSrcSpan (#17494) Metric Decrease: haddock.compiler - - - - - d1de5c22 by Sylvain Henry at 2019-11-30T02:59:13-05:00 Use Hadrian by default in validate script (#17527) - - - - - 3a96a0b6 by Sebastian Graf at 2019-11-30T02:59:55-05:00 Simpler Semigroup instance for InsideLam and InterestingCtxt This mirrors the definition of `(&&)` and `(||)` now, relieving the Simplifier of a marginal amount of pressure. - - - - - f8cfe81a by Roland Senn at 2019-11-30T20:33:49+01:00 Improve tests for #17171 While backporting MR !1806 to 8.8.2 (!1885) I learnt the following: * Tests with `expect_fail` do not compare `*.stderr` output files. So a test using `expect_fail` will not detect future regressions on the `stderr` output. * To compare the `*.stderr` output files, I have to use the `exit_code(n)` function. * When a release is made, tests with `makefile_test` are converted to use `run_command`. * For the test `T17171a` the return code is `1` when running `makefile_test`, however it's `2` when running `run_command`. Therefore I decided: * To improve my tests for #17171 * To change test T17171a from `expect_fail` to `exit_code(2)` * To change both tests from `makefile_test` to `run_command` - - - - - 2b113fc9 by Vladislav Zavialov at 2019-12-01T08:17:05-05:00 Update DisambECP-related comments - - - - - beed7c3e by Ben Gamari at 2019-12-02T03:41:37-05:00 testsuite: Fix location of typing_stubs module This should fix the build on Debian 8. - - - - - 53251413 by Ben Gamari at 2019-12-02T03:42:14-05:00 testsuite: Don't override LD_LIBRARY_PATH, only prepend NixOS development environments often require that LD_LIBRARY_PATH be set in order to find system libraries. T1407 was overriding LD_LIBRARY_PATH, dropping these directories. Now it merely prepends, its directory. - - - - - 65400314 by Krzysztof Gogolewski at 2019-12-02T03:42:57-05:00 Convert warnings into assertions Since the invariants always hold in the testsuite, we can convert them to asserts. - - - - - 18baed64 by Alan Zimmerman at 2019-12-02T03:43:37-05:00 API Annotations: Unicode '->' on HsForallTy The code fragment type family Proxy2' ∷ ∀ k → k → Type where Proxy2' = Proxy' Generates AnnRarrow instead of AnnRarrowU for the first →. Fixes #17519 - - - - - 717f3236 by Brian Wignall at 2019-12-02T03:44:16-05:00 Fix more typos - - - - - bde48f8e by Ben Gamari at 2019-12-02T11:55:34-05:00 More Haddock syntax in GHC.Hs.Utils As suggested by RyanGlScott in !2163. - - - - - 038bedbc by Ben Gamari at 2019-12-02T11:56:18-05:00 Simplify: Fix pretty-printing of strictness A colleague recently hit the panic in Simplify.addEvals and I noticed that the message is quite unreadable due to incorrect pretty-printing. Fix this. - - - - - c500f652 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Fix changelog linting logic - - - - - 8ead967d by Ben Gamari at 2019-12-02T11:56:54-05:00 win32-init: Drop workaround for #17480 The `process` changes have now been merged into `hsc2hs`. (cherry picked from commit fa029f53132ad59f847ed012d3b835452cf16615) - - - - - d402209a by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Disable Sphinx build on Debian 8 The docutils version available appears to be too old to support the `table` directive's `:widths:` options. (cherry picked from commit 75764487a96a7a026948b5af5022781872d12baa) - - - - - f1f68824 by Ben Gamari at 2019-12-02T11:56:54-05:00 base: Fix <unistd.h> #include Previously we were including <sys/unistd.h> which is available on glibc but not musl. (cherry picked from commit e44b695ca7cb5f3f99eecfba05c9672c6a22205e) - - - - - 37eb94b3 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Bump Docker images Installs pxz on Centos7 (cherry picked from commit 86960e691f7a600be247c32a7cf795bf9abf7cc4) - - - - - aec98a79 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: pxz is unavailable on CentOS 7 Fall back to xz - - - - - 6708b8e5 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Set LANG on CentOS 7 It otherwise seems to default to ascii - - - - - 470ef0e7 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Consolidate release build configuration - - - - - 38338757 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Add Debian 10 builds - - - - - 012f13b5 by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Fix Windows bindist collection Apparently variable interpolation in the `artifacts.paths` key of `gitlab-ci.yml` doesn't work on Windows as it does on WIndows. (cherry picked from commit 100cc756faa4468ed6950116bae30609c1c3468b) - - - - - a0f09e23 by Ben Gamari at 2019-12-02T11:56:54-05:00 testsuite: Simplify Python <3.5 fallback for TextIO (cherry picked from commit d092d8598694c23bc07cdcc504dff52fa5f33be1) - - - - - 2b2370ec by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Add release-x86_64-linux-deb9 job (cherry picked from commit cbedb3c4a90649f474cb716842ba53afc5a642ca) - - - - - b1c206fd by Ben Gamari at 2019-12-02T11:56:54-05:00 gitlab-ci: Always build source tarball (cherry picked from commit 67b5de88ef923971f1980335137e3c7193213abd) - - - - - 4cbd5b47 by Sergei Trofimovich at 2019-12-02T11:57:33-05:00 configure.ac: make cross-compiler detection stricter Be more precise at detecting cross-compilation case. Before the change configuration $ ./configure --host=x86_64-pc-linux-gnu --target=x86_64-gentoo-linux-musl was not considered a cross-target. Even though libcs are different (`glibc` vs. `musl`). Without this patch build fails as: ``` "inplace/bin/ghc-cabal" check libraries/integer-gmp "inplace/bin/ghc-cabal" configure libraries/integer-gmp dist-install \ --with-ghc="/home/slyfox/dev/git/ghc/inplace/bin/ghc-stage1" \ --with-ghc-pkg="/home/slyfox/dev/git/ghc/inplace/bin/ghc-pkg" \ --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci \ --enable-library-profiling --enable-shared --with-hscolour="/usr/bin/HsColour" \ --configure-option=CFLAGS="-Wall \ -Werror=unused-but-set-variable -Wno-error=inline \ -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp" \ --configure-option=LDFLAGS=" " --configure-option=CPPFLAGS=" \ " --gcc-options="-Wall -Werror=unused-but-set-variable -Wno-error=inline -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp \ " --with-gcc="x86_64-gentoo-linux-musl-gcc" --with-ld="x86_64-gentoo-linux-musl-ld.gold" --with-ar="x86_64-gentoo-linux-musl-ar" \ --with-alex="/usr/bin/alex" --with-happy="/usr/bin/happy" Configuring integer-gmp-1.0.2.0... configure: WARNING: unrecognized options: --with-compiler checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for gcc... /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/home/slyfox/dev/git/ghc/libraries/integer-gmp/dist-install/build': configure: error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details make[1]: *** [libraries/integer-gmp/ghc.mk:5: libraries/integer-gmp/dist-install/package-data.mk] Error 1 make: *** [Makefile:126: all] Error 2 ``` Note: here `ghc-stage1` is assumed to target `musl` target but is passed `glibc` toolchain. It happens because initial ./configure phase did not detect host/target as different. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 5f7cb423 by Sylvain Henry at 2019-12-02T23:59:29-05:00 Add `timesInt2#` primop - - - - - fbbe18a2 by Sylvain Henry at 2019-12-02T23:59:29-05:00 Use the new timesInt2# primop in integer-gmp (#9431) - - - - - 5a4b8d0c by Athas at 2019-12-03T00:00:09-05:00 Document RTS behaviour upon encountering '--'. - - - - - 705a16df by Ben Gamari at 2019-12-03T07:11:33-05:00 Make BCO# lifted In #17424 Simon PJ noted that there is a potentially unsafe occurrence of unsafeCoerce#, coercing from an unlifted to lifted type. However, nowhere in the compiler do we assume that a BCO# is not a thunk. Moreover, in the case of a CAF the result returned by `createBCO` *will* be a thunk (as noted in [Updatable CAF BCOs]). Consequently it seems better to rather make BCO# a lifted type and rename it to BCO. - - - - - 35afe4f3 by Sylvain Henry at 2019-12-03T07:12:13-05:00 Use Int# primops in `Bits Int{8,16,32,64}` instances - - - - - 7a51b587 by Sylvain Henry at 2019-12-03T07:12:13-05:00 Add constant folding rule (#16402) narrowN (x .&. m) m .&. (2^N-1) = 2^N-1 ==> narrowN x e.g. narrow16 (x .&. 0x12FFFF) ==> narrow16 x - - - - - 10caee7f by Ben Gamari at 2019-12-03T21:04:50-05:00 users-guide: Add 8.12.1 release notes - - - - - 25019d18 by Ben Gamari at 2019-12-03T21:04:50-05:00 Drop Uniquable constraint for AnnTarget This relied on deriveUnique, which was far too subtle to be safely applied. Thankfully the instance doesn't appear to be used so let's just drop it. - - - - - 78b67ad0 by Ben Gamari at 2019-12-03T21:04:50-05:00 Simplify uniqAway This does two things: * Eliminate all uses of Unique.deriveUnique, which was quite easy to mis-use and extremely subtle. * Rename the previous "derived unique" notion to "local unique". This is possible because the only places where `uniqAway` can be safely used are those where local uniqueness (with respect to some InScopeSet) is sufficient. * Rework the implementation of VarEnv.uniqAway, as discussed in #17462. This should make the operation significantly more efficient than its previous iterative implementation.. Metric Decrease: T9872c T12227 T9233 T14683 T5030 T12545 hie002 Metric Increase: T9961 - - - - - f03a41d4 by Ben Gamari at 2019-12-03T21:05:27-05:00 Elf: Fix link info note generation Previously we would use the `.int` assembler directive to generate 32-bit words in the note section. However, `.int` is note guaranteed to produce 4-bytes; in fact, on some platforms (e.g. AArch64) it produces 8-bytes. Use the `.4bytes` directive to avoid this. Moreover, we used the `.align` directive, which is quite platform dependent. On AArch64 it appears to not even be idempotent (despite what the documentation claims). `.balign` is consequentially preferred as it offers consistent behavior across platforms. - - - - - 84585e5e by Vladislav Zavialov at 2019-12-05T16:07:44-05:00 Meaning-preserving SCC annotations (#15730) This patch implements GHC Proposal #176: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0176-scc-parsing.rst Before the change: 1 / 2 / 2 = 0.25 1 / {-# SCC "name" #-} 2 / 2 = 1.0 After the change: 1 / 2 / 2 = 0.25 1 / {-# SCC "name" #-} 2 / 2 = parse error - - - - - e49e5470 by Vladislav Zavialov at 2019-12-05T16:07:44-05:00 Improve error messages for SCC pragmas - - - - - a2b535d9 by Ben Gamari at 2019-12-05T16:07:45-05:00 users guide: Try to silence underfull \hbox warnings We use two tricks, as suggested here [1]: * Use microtype to try to reduce the incidence of underfull boxes * Bump up \hbadness to eliminate the warnings - - - - - 4e47217f by Bodigrim at 2019-12-05T16:07:47-05:00 Make sameNat and sameSymbol proxy-polymorphic - - - - - 8324f0b7 by Bodigrim at 2019-12-05T16:07:47-05:00 Test proxy-polymorphic sameNat and sameSymbol - - - - - 69001f54 by Ben Gamari at 2019-12-05T16:07:48-05:00 nonmoving: Clear segment bitmaps during sweep Previously we would clear the bitmaps of segments which we are going to sweep during the preparatory pause. However, this is unnecessary: the existence of the mark epoch ensures that the sweep will correctly identify non-reachable objects, even if we do not clear the bitmap. We now defer clearing the bitmap to sweep, which happens concurrently with mutation. - - - - - 58a9c429 by Ben Gamari at 2019-12-05T16:07:48-05:00 testsuite: Disable divByZero on non-NCG targets The LLVM backend does not guarantee any particular semantics for division by zero, making this test unreliable across platforms. - - - - - 8280bd8a by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Factor out terminal coloring - - - - - 92a52aaa by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Make performance metric summary more readable Along with some refactoring. - - - - - c4ca29c7 by Ben Gamari at 2019-12-05T16:07:49-05:00 testsuite: Use colors more consistently - - - - - 3354c68e by Vladislav Zavialov at 2019-12-05T16:07:49-05:00 Pretty-printing of the * kind Before this patch, GHC always printed the * kind unparenthesized. This led to two issues: 1. Sometimes GHC printed invalid or incorrect code. For example, GHC would print: type F @* x = x when it meant to print: type F @(*) x = x In the former case, instead of a kind application we were getting a type operator (@*). 2. Sometimes GHC printed kinds that were correct but hard to read. Should Either * Int be read as Either (*) Int or as (*) Either Int ? This depends on whether -XStarIsType is enabled, but it would be easier if we didn't have to check for the flag when reading the code. We can solve both problems by assigning (*) a different precedence. Note that Haskell98 kinds are not affected: ((* -> *) -> *) -> * does NOT become (((*) -> (*)) -> (*)) -> (*) The parentheses are added when (*) is used in a function argument position: F * * * becomes F (*) (*) (*) F A * B becomes F A (*) B Proxy * becomes Proxy (*) a * -> * becomes a (*) -> * - - - - - 70dd0e4b by Vladislav Zavialov at 2019-12-05T16:07:49-05:00 Parenthesize the * kind in TH.Ppr - - - - - a7a4efbf by Ben Gamari at 2019-12-05T16:07:49-05:00 rts/NonMovingSweep: Fix locking of new mutable list allocation Previously we used allocBlockOnNode_sync in nonmovingSweepMutLists despite the fact that we aren't in the GC and therefore the allocation spinlock isn't in use. This meant that sweep would end up spinning until the next minor GC, when the SM lock was moved away from the SM_MUTEX to the spinlock. This isn't a correctness issue but it sure isn't good for performance. Found thanks for Ward. Fixes #17539. - - - - - f171b358 by Matthias Braun at 2019-12-05T16:07:51-05:00 Fix typo in documentation of Base.hs. - - - - - 9897e8c8 by Gabor Greif at 2019-12-06T21:20:38-05:00 Implement pointer tagging for big families (#14373) Formerly we punted on these and evaluated constructors always got a tag of 1. We now cascade switches because we have to check the tag first and when it is MAX_PTR_TAG then get the precise tag from the info table and switch on that. The only technically tricky part is that the default case needs (logical) duplication. To do this we emit an extra label for it and branch to that from the second switch. This avoids duplicated codegen. Here's a simple example of the new code gen: data D = D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 On a 64-bit system previously all constructors would be tagged 1. With the new code gen D7 and D8 are tagged 7: [Lib.D7_con_entry() { ... {offset c1eu: // global R1 = R1 + 7; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } }] [Lib.D8_con_entry() { ... {offset c1ez: // global R1 = R1 + 7; call (P64[Sp])(R1) args: 8, res: 0, upd: 8; } }] When switching we now look at the info table only when the tag is 7. For example, if we derive Enum for the type above, the Cmm looks like this: c2Le: _s2Js::P64 = R1; _c2Lq::P64 = _s2Js::P64 & 7; switch [1 .. 7] _c2Lq::P64 { case 1 : goto c2Lk; case 2 : goto c2Ll; case 3 : goto c2Lm; case 4 : goto c2Ln; case 5 : goto c2Lo; case 6 : goto c2Lp; case 7 : goto c2Lj; } // Read info table for tag c2Lj: _c2Lv::I64 = %MO_UU_Conv_W32_W64(I32[I64[_s2Js::P64 & (-8)] - 4]); if (_c2Lv::I64 != 6) goto c2Lu; else goto c2Lt; Generated Cmm sizes do not change too much, but binaries are very slightly larger, due to the fact that the new instructions are longer in encoded form. E.g. previously entry code for D8 above would be 00000000000001c0 <Lib_D8_con_info>: 1c0: 48 ff c3 inc %rbx 1c3: ff 65 00 jmpq *0x0(%rbp) With this patch 00000000000001d0 <Lib_D8_con_info>: 1d0: 48 83 c3 07 add $0x7,%rbx 1d4: ff 65 00 jmpq *0x0(%rbp) This is one byte longer. Secondly, reading info table directly and then switching is shorter _c1co: movq -1(%rbx),%rax movl -4(%rax),%eax // Switch on info table tag jmp *_n1d5(,%rax,8) than doing the same switch, and then for the tag 7 doing another switch: // When tag is 7 _c1ct: andq $-8,%rbx movq (%rbx),%rax movl -4(%rax),%eax // Switch on info table tag ... Some changes of binary sizes in actual programs: - In NoFib the worst case is 0.1% increase in benchmark "parser" (see NoFib results below). All programs get slightly larger. - Stage 2 compiler size does not change. - In "containers" (the library) size of all object files increases 0.0005%. Size of the test program "bitqueue-properties" increases 0.03%. nofib benchmarks kindly provided by Ömer (@osa1): NoFib Results ============= -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.0% 0.0% -0.0% -0.0% -0.0% CSD +0.0% 0.0% 0.0% +0.0% +0.0% FS +0.0% 0.0% 0.0% +0.0% 0.0% S +0.0% 0.0% -0.0% 0.0% 0.0% VS +0.0% 0.0% -0.0% +0.0% +0.0% VSD +0.0% 0.0% -0.0% +0.0% -0.0% VSM +0.0% 0.0% 0.0% 0.0% 0.0% anna +0.0% 0.0% +0.1% -0.9% -0.0% ansi +0.0% 0.0% -0.0% +0.0% +0.0% atom +0.0% 0.0% 0.0% 0.0% 0.0% awards +0.0% 0.0% -0.0% +0.0% 0.0% banner +0.0% 0.0% -0.0% +0.0% 0.0% bernouilli +0.0% 0.0% +0.0% +0.0% +0.0% binary-trees +0.0% 0.0% -0.0% -0.0% -0.0% boyer +0.0% 0.0% +0.0% 0.0% -0.0% boyer2 +0.0% 0.0% +0.0% 0.0% -0.0% bspt +0.0% 0.0% +0.0% +0.0% 0.0% cacheprof +0.0% 0.0% +0.1% -0.8% 0.0% calendar +0.0% 0.0% -0.0% +0.0% -0.0% cichelli +0.0% 0.0% +0.0% 0.0% 0.0% circsim +0.0% 0.0% -0.0% -0.1% -0.0% clausify +0.0% 0.0% +0.0% +0.0% 0.0% comp_lab_zift +0.0% 0.0% +0.0% 0.0% -0.0% compress +0.0% 0.0% +0.0% +0.0% 0.0% compress2 +0.0% 0.0% 0.0% 0.0% 0.0% constraints +0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 +0.0% 0.0% +0.0% 0.0% 0.0% cryptarithm2 +0.0% 0.0% +0.0% -0.0% 0.0% cse +0.0% 0.0% +0.0% +0.0% 0.0% digits-of-e1 +0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 +0.0% 0.0% +0.0% -0.0% -0.0% dom-lt +0.0% 0.0% +0.0% +0.0% 0.0% eliza +0.0% 0.0% -0.0% +0.0% 0.0% event +0.0% 0.0% -0.0% -0.0% -0.0% exact-reals +0.0% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.0% 0.0% -0.0% -0.0% -0.0% expert +0.0% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.0% 0.0% +0.0% 0.0% 0.0% fasta +0.0% 0.0% -0.0% -0.0% -0.0% fem +0.0% 0.0% +0.0% +0.0% +0.0% fft +0.0% 0.0% +0.0% -0.0% -0.0% fft2 +0.0% 0.0% +0.0% +0.0% +0.0% fibheaps +0.0% 0.0% +0.0% +0.0% 0.0% fish +0.0% 0.0% +0.0% +0.0% 0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.0% 0.0% +0.0% -0.0% +0.0% gamteb +0.0% 0.0% +0.0% -0.0% -0.0% gcd +0.0% 0.0% +0.0% +0.0% 0.0% gen_regexps +0.0% 0.0% +0.0% -0.0% -0.0% genfft +0.0% 0.0% -0.0% -0.0% -0.0% gg +0.0% 0.0% 0.0% -0.0% 0.0% grep +0.0% 0.0% +0.0% +0.0% +0.0% hidden +0.0% 0.0% +0.0% -0.0% -0.0% hpg +0.0% 0.0% +0.0% -0.1% -0.0% ida +0.0% 0.0% +0.0% -0.0% -0.0% infer +0.0% 0.0% -0.0% -0.0% -0.0% integer +0.0% 0.0% -0.0% -0.0% -0.0% integrate +0.0% 0.0% 0.0% +0.0% 0.0% k-nucleotide +0.0% 0.0% -0.0% -0.0% -0.0% kahan +0.0% 0.0% -0.0% -0.0% -0.0% knights +0.0% 0.0% +0.0% -0.0% -0.0% lambda +0.0% 0.0% +1.2% -6.1% -0.0% last-piece +0.0% 0.0% +0.0% -0.0% -0.0% lcss +0.0% 0.0% +0.0% -0.0% -0.0% life +0.0% 0.0% +0.0% -0.0% -0.0% lift +0.0% 0.0% +0.0% +0.0% 0.0% linear +0.0% 0.0% +0.0% +0.0% +0.0% listcompr +0.0% 0.0% -0.0% -0.0% -0.0% listcopy +0.0% 0.0% -0.0% -0.0% -0.0% maillist +0.0% 0.0% +0.0% -0.0% -0.0% mandel +0.0% 0.0% +0.0% +0.0% +0.0% mandel2 +0.0% 0.0% +0.0% +0.0% -0.0% mate +0.0% 0.0% +0.0% +0.0% +0.0% minimax +0.0% 0.0% -0.0% +0.0% -0.0% mkhprog +0.0% 0.0% +0.0% +0.0% +0.0% multiplier +0.0% 0.0% 0.0% +0.0% -0.0% n-body +0.0% 0.0% +0.0% -0.0% -0.0% nucleic2 +0.0% 0.0% +0.0% +0.0% -0.0% para +0.0% 0.0% +0.0% +0.0% +0.0% paraffins +0.0% 0.0% +0.0% +0.0% +0.0% parser +0.1% 0.0% +0.4% -1.7% -0.0% parstof +0.0% 0.0% -0.0% -0.0% -0.0% pic +0.0% 0.0% +0.0% 0.0% -0.0% pidigits +0.0% 0.0% -0.0% -0.0% -0.0% power +0.0% 0.0% +0.0% -0.0% -0.0% pretty +0.0% 0.0% +0.0% +0.0% +0.0% primes +0.0% 0.0% +0.0% 0.0% 0.0% primetest +0.0% 0.0% +0.0% +0.0% +0.0% prolog +0.0% 0.0% +0.0% +0.0% +0.0% puzzle +0.0% 0.0% +0.0% +0.0% +0.0% queens +0.0% 0.0% 0.0% +0.0% +0.0% reptile +0.0% 0.0% +0.0% +0.0% 0.0% reverse-complem +0.0% 0.0% -0.0% -0.0% -0.0% rewrite +0.0% 0.0% +0.0% 0.0% -0.0% rfib +0.0% 0.0% +0.0% +0.0% +0.0% rsa +0.0% 0.0% +0.0% +0.0% +0.0% scc +0.0% 0.0% +0.0% +0.0% +0.0% sched +0.0% 0.0% +0.0% +0.0% +0.0% scs +0.0% 0.0% +0.0% +0.0% 0.0% simple +0.0% 0.0% +0.0% +0.0% +0.0% solid +0.0% 0.0% +0.0% +0.0% 0.0% sorting +0.0% 0.0% +0.0% -0.0% 0.0% spectral-norm +0.0% 0.0% -0.0% -0.0% -0.0% sphere +0.0% 0.0% +0.0% -1.0% 0.0% symalg +0.0% 0.0% +0.0% +0.0% +0.0% tak +0.0% 0.0% +0.0% +0.0% +0.0% transform +0.0% 0.0% +0.4% -1.3% +0.0% treejoin +0.0% 0.0% +0.0% -0.0% 0.0% typecheck +0.0% 0.0% -0.0% +0.0% 0.0% veritas +0.0% 0.0% +0.0% -0.1% +0.0% wang +0.0% 0.0% +0.0% +0.0% +0.0% wave4main +0.0% 0.0% +0.0% 0.0% -0.0% wheel-sieve1 +0.0% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.0% 0.0% +0.0% +0.0% 0.0% x2n1 +0.0% 0.0% +0.0% +0.0% 0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -6.1% -0.0% Max +0.1% 0.0% +1.2% +0.0% +0.0% Geometric Mean +0.0% -0.0% +0.0% -0.1% -0.0% NoFib GC Results ================ -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim +0.0% 0.0% -0.0% -0.0% -0.0% constraints +0.0% 0.0% -0.0% 0.0% -0.0% fibheaps +0.0% 0.0% 0.0% -0.0% -0.0% fulsom +0.0% 0.0% 0.0% -0.6% -0.0% gc_bench +0.0% 0.0% 0.0% 0.0% -0.0% hash +0.0% 0.0% -0.0% -0.0% -0.0% lcss +0.0% 0.0% 0.0% -0.0% 0.0% mutstore1 +0.0% 0.0% 0.0% -0.0% -0.0% mutstore2 +0.0% 0.0% +0.0% -0.0% -0.0% power +0.0% 0.0% -0.0% 0.0% -0.0% spellcheck +0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.6% -0.0% Max +0.0% 0.0% +0.0% 0.0% 0.0% Geometric Mean +0.0% +0.0% +0.0% -0.1% +0.0% Fixes #14373 These performance regressions appear to be a fluke in CI. See the discussion in !1742 for details. Metric Increase: T6048 T12234 T12425 Naperian T12150 T5837 T13035 - - - - - ee07421f by Simon Peyton Jones at 2019-12-06T21:21:14-05:00 Work in progress on coercionLKind, coercionRKind This is a preliminary patch for #17515 - - - - - 0a4ca9eb by Simon Peyton Jones at 2019-12-06T21:21:14-05:00 Split up coercionKind This patch implements the idea in #17515, splitting `coercionKind` into: * `coercion{Left,Right}Kind`, which computes the left/right side of the pair * `coercionKind`, which computes the pair of coercible types This is reduces allocation since we frequently only need only one side of the pair. Specifically, we see the following improvements on x86-64 Debian 9: | test | new | old | relative chg. | | :------- | ---------: | ------------: | ------------: | | T5030 | 695537752 | 747641152.0 | -6.97% | | T5321Fun | 449315744 | 474009040.0 | -5.21% | | T9872a | 2611071400 | 2645040952.0 | -1.28% | | T9872c | 2957097904 | 2994260264.0 | -1.24% | | T12227 | 773435072 | 812367768.0 | -4.79% | | T12545 | 3142687224 | 3215714752.0 | -2.27% | | T14683 | 9392407664 | 9824775000.0 | -4.40% | Metric Decrease: T12545 T9872a T14683 T5030 T12227 T9872c T5321Fun T9872b - - - - - d46a72e1 by Gabor Greif at 2019-12-09T12:05:15-05:00 Fix comment typos The below is only necessary to fix the CI perf fluke that happened in 9897e8c8ef0b19a9571ef97a1d9bb050c1ee9121: ------------------------- Metric Decrease: T5837 T6048 T9020 T12425 T12234 T13035 T12150 Naperian ------------------------- - - - - - e3bba7e4 by Micha Wiedenmann at 2019-12-10T19:52:44-05:00 users guide: Motivation of DefaultSignatures - - - - - 843ceb38 by Ben Gamari at 2019-12-10T19:53:54-05:00 rts: Add a long form flag to enable the non-moving GC The old flag, `-xn`, was quite cryptic. Here we add `--nonmoving-gc` in addition. - - - - - 921d3238 by Ryan Scott at 2019-12-10T19:54:34-05:00 Ignore unary constraint tuples during typechecking (#17511) We deliberately avoid defining a magical `Unit%` class, for reasons that I have expounded upon in the newly added `Note [Ignore unary constraint tuples]` in `TcHsType`. However, a sneaky user could try to insert `Unit%` into their program by way of Template Haskell, leading to the interface-file error observed in #17511. To avoid this, any time we encounter a unary constraint tuple during typechecking, we drop the surrounding constraint tuple application. This is safe to do since `Unit% a` and `a` would be semantically equivalent (unlike other forms of unary tuples). Fixes #17511. - - - - - 436ec9f3 by Ben Gamari at 2019-12-10T19:55:37-05:00 gitlab-ci: Move changelog linting logic to shell script Allowing it to be easily used locally. - - - - - 2f6b434f by Ben Gamari at 2019-12-10T19:55:37-05:00 gitlab-ci: Move changelog linting logic to shell script Allowing it to be easily used locally. - - - - - 7a5a6e07 by Ben Gamari at 2019-12-10T19:56:25-05:00 base: Fix incorrect @since in GHC.Natural Fixes #17547. - - - - - 2bbfaf8a by Ben Gamari at 2019-12-10T19:57:01-05:00 hadrian: AArch64 supports the GHCi interpreter and SMP I'm not sure how this was omitted from the list of supported architectures. - - - - - 8f1ceb67 by John Ericson at 2019-12-10T19:57:39-05:00 Move Int# section of primops.txt.pp This matches the organization of the fixed-sized ones, and keeps each Int* next to its corresponding Word*. - - - - - 7a823b0f by John Ericson at 2019-12-10T19:57:39-05:00 Move Int64# and Word64# sections of primops.txt.pp This way it is next to the other fixed-sized ones. - - - - - 8dd9929a by Ben Gamari at 2019-12-10T19:58:19-05:00 testsuite: Add (broken) test for #17510 - - - - - 6e47a76a by Ben Gamari at 2019-12-10T19:58:59-05:00 Re-layout validate script This script was previously a whitespace nightmare. - - - - - f80c4a66 by Crazycolorz5 at 2019-12-11T14:12:17-05:00 rts: Specialize hashing at call site rather than in struct. Separate word and string hash tables on the type level, and do not store the hashing function. Thus when a different hash function is desire it is provided upon accessing the table. This is worst case the same as before the change, and in the majority of cases is better. Also mark the functions for aggressive inlining to improve performance. {F1686506} Reviewers: bgamari, erikd, simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #13165 Differential Revision: https://phabricator.haskell.org/D4889 - - - - - 2d1b9619 by Richard Eisenberg at 2019-12-11T14:12:55-05:00 Warn on inferred polymorphic recursion Silly users sometimes try to use visible dependent quantification and polymorphic recursion without a CUSK or SAK. This causes unexpected errors. So we now adjust expectations with a bit of helpful messaging. Closes #17541 and closes #17131. test cases: dependent/should_fail/T{17541{,b},17131} - - - - - 4dde485e by Oleg Grenrus at 2019-12-12T02:24:46-05:00 Add --show-unit-ids flag to ghc-pkg I only added it into --simple-output and ghc-pkg check output; there are probably other places where it can be adopted. - - - - - e6e1ec08 by Ben Gamari at 2019-12-12T02:25:33-05:00 testsuite: Simplify and clarify performance test baseline search The previous implementation was extremely complicated, seemingly to allow the local and CI namespaces to be searched incrementally. However, it's quite unclear why this is needed and moreover the implementation seems to have had quadratic runtime cost in the search depth(!). - - - - - 29c4609c by Ben Gamari at 2019-12-12T02:26:19-05:00 testsuite: Add test for #17549 - - - - - 9f0ee253 by Ben Gamari at 2019-12-12T02:26:56-05:00 gitlab-ci: Move -dwarf and -debug jobs to full-build stage This sacrifices some precision in favor of improving parallelism. - - - - - 7179b968 by Ben Gamari at 2019-12-12T02:27:34-05:00 Revert "rts: Drop redundant flags for libffi" This seems to have regressed builds using `--with-system-libffi` (#17520). This reverts commit 3ce18700f80a12c48a029b49c6201ad2410071bb. - - - - - cc7d5650 by Oleg Grenrus at 2019-12-16T10:20:56+02:00 Having no shake upper bound is irresposible Given that shake is far from "done" API wise, and is central component to the build system. - - - - - 9431f905 by Oleg Grenrus at 2019-12-16T10:55:50+02:00 Add index-state to hadrian/cabal.project Then one is freer to omit upper bounds, as we won't pick any new entries on Hackage while building hadrian itself. - - - - - 3e17a866 by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00 Remove dataConSig As suggested in #17291 - - - - - 75355fde by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00 Use "OrCoVar" functions less As described in #17291, we'd like to separate coercions and expressions in a more robust fashion. This is a small step in this direction. - `mkLocalId` now panicks on a covar. Calls where this was not the case were changed to `mkLocalIdOrCoVar`. - Don't use "OrCoVar" functions in places where we know the type is not a coercion. - - - - - f9686e13 by Richard Eisenberg at 2019-12-16T19:32:21-05:00 Do more validity checks for quantified constraints Close #17583. Test case: typecheck/should_fail/T17563 - - - - - af763765 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Fix Windows artifact collection Variable interpolation in gitlab-ci.yml apparently doesn't work. Sigh. - - - - - e6d4b902 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Use xz --threads on Debian 10 - - - - - 8ba650e9 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Allow debian 8 build to fail The python release shipped with deb8 (3.3) is too old for our testsuite driver. - - - - - ac25a3f6 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Use xz --threads on Alpine - - - - - cc628088 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Another approach for xz detection - - - - - 37d788ab by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Re-add release-x86_64-deb9 job Also eliminate some redundancy. - - - - - f8279138 by Ben Gamari at 2019-12-16T19:33:01-05:00 gitlab-ci: Drop redundant release-x86_64-linux-deb9 job - - - - - 8148ff06 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark cgrun057 as broken on ARMv7 Due to #17554. It's very surprising that this only occurs on ARMv7 but this is the only place I've seen this failure thusfar. - - - - - 85e5696d by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark prog001 as fragile on ARMv7 Due to #17555. - - - - - a5f0aab0 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T10272 as broken on ARMv7 Due to #17556. - - - - - 1e6827c6 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T13825-debugger as broken on ARMv7 Due to #17557. - - - - - 7cef0b7d by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T14028 as broken on ARMv7 Due to #17558. - - - - - 6ea4eb4b by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Make ghc_built_by_llvm check more precise Previously it would hackily look at the flavour name to determine whether LLVM was used to build stage2 ghc. However, this didn't work at all with Hadrian and would miss cases like ARM where we use the LLVM backend by default. See #16087 for the motivation for why ghc_built_by_llvm is needed at all. This should catch one of the ARMv7 failures described in #17555. - - - - - c3e82bf7 by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark T5435_* tests as broken on ARM `T5435_v_asm_a`, `T5435_v_asm_b`, and `T5435_v_gcc` all fail on ARMv7. See #17559. - - - - - eb2aa851 by Ben Gamari at 2019-12-17T07:24:40-05:00 gitlab-ci: Don't allow armv7 jobs to fail - - - - - efc92216 by Ben Gamari at 2019-12-17T07:24:40-05:00 Revert "testsuite: Mark cgrun057 as broken on ARMv7" This reverts commit 6cfc47ec8a478e1751cb3e7338954da1853c3996. - - - - - 1d2bb9eb by Ben Gamari at 2019-12-17T07:24:40-05:00 testsuite: Mark print002 as fragile on ARM Due to #17557. Also accepting spurious performance change. Metric Decrease: T1969 - - - - - 41f4e4fb by Josh Meredith at 2019-12-17T07:25:17-05:00 Fix ambiguous occurence error when building Hadrian - - - - - 4374983a by Josh Meredith at 2019-12-17T07:25:17-05:00 Rename SphinxMode constructors - - - - - a8f7ecd5 by Josh Meredith at 2019-12-17T07:25:17-05:00 Use *Mode suffix instead of *M - - - - - 58655b9d by Sylvain Henry at 2019-12-18T13:43:37+01:00 Add GHC-API logging hooks * Add 'dumpAction' hook to DynFlags. It allows GHC API users to catch dumped intermediate codes and information. The format of the dump (Core, Stg, raw text, etc.) is now reported allowing easier automatic handling. * Add 'traceAction' hook to DynFlags. Some dumps go through the trace mechanism (for instance unfoldings that have been considered for inlining). This is problematic because: 1) dumps aren't written into files even with -ddump-to-file on 2) dumps are written on stdout even with GHC API 3) in this specific case, dumping depends on unsafe globally stored DynFlags which is bad for GHC API users We introduce 'traceAction' hook which allows GHC API to catch those traces and to avoid using globally stored DynFlags. * Avoid dumping empty logs via dumpAction/traceAction (but still write empty files to keep the existing behavior) - - - - - fad866e0 by Moritz Kiefer at 2019-12-19T11:15:39-05:00 Avoid race condition in hDuplicateTo In our codebase we have some code along the lines of ``` newStdout <- hDuplicate stdout stderr `hDuplicateTo` stdout ``` to avoid stray `putStrLn`s from corrupting a protocol (LSP) that is run over stdout. On CI we have seen a bunch of issues where `dup2` returned `EBUSY` so this fails with `ResourceExhausted` in Haskell. I’ve spent some time looking at the docs for `dup2` and the code in `base` and afaict the following race condition is being triggered here: 1. The user calls `hDuplicateTo stderr stdout`. 2. `hDuplicateTo` calls `hClose_help stdout_`, this closes the file handle for stdout. 3. The file handle for stdout is now free, so another thread allocating a file might get stdout. 4. If `dup2` is called while `stdout` (now pointing to something else) is half-open, it returns EBUSY. I think there might actually be an even worse case where `dup2` is run after FD 1 is fully open again. In that case, you will end up not just redirecting the original stdout to stderr but also the whatever resulted in that file handle being allocated. As far as I can tell, `dup2` takes care of closing the file handle itself so there is no reason to do this in `hDuplicateTo`. So this PR replaces the call to `hClose_help` by the only part of `hClose_help` that we actually care about, namely, `flushWriteBuffer`. I tested this on our codebase fairly extensively and haven’t been able to reproduce the issue with this patch. - - - - - 0c114c65 by Sylvain Henry at 2019-12-19T11:16:17-05:00 Handle large ARR_WORDS in heap census (fix #17572) We can do a heap census with a non-profiling RTS. With a non-profiling RTS we don't zero superfluous bytes of shrunk arrays hence a need to handle the case specifically to avoid a crash. Revert part of a586b33f8e8ad60b5c5ef3501c89e9b71794bbed - - - - - 1a0d1a65 by John Ericson at 2019-12-20T10:50:22-05:00 Deduplicate copied monad failure handler code - - - - - 70e56b27 by Ryan Scott at 2019-12-20T10:50:57-05:00 lookupBindGroupOcc: recommend names in the same namespace (#17593) Previously, `lookupBindGroupOcc`'s error message would recommend all similar names in scope, regardless of whether they were type constructors, data constructors, or functions, leading to the confusion witnessed in #17593. This is easily fixed by only recommending names in the same namespace, using the `nameSpacesRelated` function. Fixes #17593. - - - - - 3c12355e by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00 Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN Include header file `ghcautoconf.h` where the CPP macro `WORDS_BIGENDIAN` is defined. This finally fixes #17337 (in conjunction with commit 6c59cc71dc). - - - - - 11f8eef5 by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00 fixup! Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN - - - - - 40327b03 by Sylvain Henry at 2019-12-24T01:04:24-05:00 Remove outdated comment - - - - - aeea92ef by Sylvain Henry at 2019-12-25T19:23:54-05:00 Switch to ReadTheDocs theme for the user-guide - - - - - 26493eab by Gabor Greif at 2019-12-25T19:24:32-05:00 Fix copy-paste error in comment - - - - - 776df719 by Gabor Greif at 2019-12-25T19:24:32-05:00 Fix comment about minimal gcc version to be consistent what FP_GCC_VERSION requires - - - - - 3b17114d by Ömer Sinan Ağacan at 2019-12-26T14:09:11-05:00 Minor refactor in ghc.cabal.in: - Remove outdated comments - Move cutils.c from parser to cbits - Remove unused cutils.h - - - - - 334290b6 by Ryan Scott at 2019-12-26T14:09:48-05:00 Replace panic/notHandled with noExtCon in DsMeta There are many spots in `DsMeta` where `panic` or `notHandled` is used after pattern-matching on a TTG extension constructor. This is overkill, however, as using `noExtCon` would work just as well. This patch switches out these panics for `noExtCon`. - - - - - 68252aa3 by Ben Gamari at 2019-12-27T15:11:38-05:00 testsuite: Skip T17499 when built against integer-simple Since it routinely times out in CI. - - - - - 0c51aeeb by Gabor Greif at 2019-12-27T15:12:17-05:00 suppress popup dialog about missing Xcode at configure tested with `bash` and `zsh`. - - - - - 8d76bcc2 by Gabor Greif at 2019-12-27T15:12:17-05:00 while at it rename XCode to the official Xcode - - - - - 47a68205 by Ben Gamari at 2019-12-27T15:12:55-05:00 testsuite: Mark cgrun057 as fragile on ARM As reported in #17554. Only marking on ARM for now although there is evidence to suggest that the issue may occur on other platforms as well. - - - - - d03dec8f by Gabor Greif at 2019-12-27T15:13:32-05:00 use shell variable CcLlvmBackend for test Previously we used `AC_DEFINE`d variable `CC_LLVM_BACKEND` which has an empty shell expansion. - - - - - 2528e684 by Ben Gamari at 2019-12-30T06:51:32-05:00 driver: Include debug level in the recompilation check hash Fixes #17586. - - - - - f14bb50b by Ben Gamari at 2019-12-30T06:52:09-05:00 rts: Ensure that nonmoving gc isn't used with profiling - - - - - b426de37 by Ben Gamari at 2019-12-30T06:52:45-05:00 llvmGen: Ensure that entry labels don't have predecessors The LLVM IR forbids the entry label of a procedure from having any predecessors. In the case of a simple looping function the LLVM code generator broke this invariant, as noted in #17589. Fix this by moving the function prologue to its own basic block, as suggested by @kavon in #11649. Fixes #11649 and #17589. - - - - - 613f7265 by Ben Gamari at 2019-12-30T06:52:45-05:00 llvmGen: Drop old fix for #11649 This was a hack which is no longer necessary now since we introduce a dedicated entry block for each procedure. - - - - - fdeffa5e by Ben Gamari at 2019-12-30T06:53:23-05:00 rts: Error on invalid --numa flags Previously things like `+RTS --numa-debug` would enable NUMA support, despite being an invalid flag. - - - - - 9ce3ba68 by Ben Gamari at 2019-12-30T06:53:23-05:00 rts: Fix --debug-numa mode under Docker As noted in #17606, Docker disallows the get_mempolicy syscall by default. This caused numerous tests to fail under CI in the `debug_numa` way. Avoid this by disabling the NUMA probing logic when --debug-numa is in use, instead setting n_numa_nodes in RtsFlags.c. Fixes #17606. - - - - - 5baa2a43 by Ben Gamari at 2019-12-30T06:54:01-05:00 testsuite: Disable derefnull when built with LLVM LLVM does not guarantee any particular semantics when dereferencing null pointers. Consequently, this test actually passes when built with the LLVM backend. - - - - - bd544d3d by Ben Gamari at 2019-12-30T06:54:38-05:00 hadrian: Track hash of Cabal Setup builder arguments Lest we fail to rebuild when they change. Fixes #17611. - - - - - 6e2c495e by Ben Gamari at 2019-12-30T06:55:19-05:00 TcIface: Fix inverted logic in typechecking of source ticks Previously we would throw away source ticks when the debug level was non-zero. This is precisely the opposite of what was intended. Fixes #17616. Metric Decrease: T13056 T9020 T9961 T12425 - - - - - 7fad387d by Ben Gamari at 2019-12-30T06:55:55-05:00 perf_notes: Add --zero-y argument This makes it easier to see the true magnitude of fluctuations. Also do some house-keeping in the argument parsing department. - - - - - 0d42b287 by Ben Gamari at 2019-12-30T06:55:55-05:00 testsuite: Enlarge acceptance window for T1969 As noted in #17624, it's quite unstable, especially, for some reason, on i386 and armv7 (something about 32-bit platforms perhaps?). Metric Increase: T1969 - - - - - eb608235 by Sylvain Henry at 2019-12-31T14:22:32-05:00 Module hierarchy (#13009): Stg - - - - - d710fd66 by Vladislav Zavialov at 2019-12-31T14:23:10-05:00 Testsuite: update some Haddock tests Fixed tests: * haddockA039: added to all.T * haddockE004: replaced with T17561 (marked as expect_broken) New tests: * haddockA040: deriving clause for a data instance * haddockA041: haddock and CPP #include - - - - - 859ebdd4 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Add "-Iw" RTS flag for minimum wait between idle GCs (#11134) - - - - - dd4b6551 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Add additional Note explaining the -Iw flag - - - - - c4279ff1 by Kevin Buhr at 2019-12-31T23:44:39-05:00 Fix some sloppy indentation - - - - - b84c09d5 by Ömer Sinan Ağacan at 2019-12-31T23:45:19-05:00 Tweak Cmm dumps to avoid generating sections for empty groups When dumping Cmm groups check if the group is empty, to avoid generating empty sections in dump files like ==================== Output Cmm ==================== [] Also fixes a few bad indentation in the code around changes. - - - - - b2e0323f by Gabor Greif at 2020-01-03T21:22:36-05:00 Simplify mrStr - - - - - 3c9dc06b by Brian Wignall at 2020-01-04T15:55:06-05:00 Fix typos, via a Levenshtein-style corrector - - - - - d561c8f6 by Sylvain Henry at 2020-01-04T15:55:46-05:00 Add Cmm related hooks * stgToCmm hook * cmmToRawCmm hook These hooks are used by Asterius and could be useful to other clients of the GHC API. It increases the Parser dependencies (test CountParserDeps) to 184. It's still less than 200 which was the initial request (cf https://mail.haskell.org/pipermail/ghc-devs/2019-September/018122.html) so I think it's ok to merge this. - - - - - ae6b6276 by Oleg Grenrus at 2020-01-04T15:56:22-05:00 Update to Cabal submodule to v3.2.0.0-alpha3 Metric Increase: haddock.Cabal - - - - - 073f7cfd by Vladislav Zavialov at 2020-01-04T15:56:59-05:00 Add lexerDbg to dump the tokens fed to the parser This a small utility function that comes in handy when debugging the lexer and the parser. - - - - - 558d4d4a by Sylvain Henry at 2020-01-04T15:57:38-05:00 Split integerGmpInternals test in several parts This is to prepare for ghc-bignum which implements some but not all of gmp functions. - - - - - 4056b966 by Ben Gamari at 2020-01-04T15:58:15-05:00 testsuite: Mark cgrun057 as fragile on all platforms I have seen this fail both on x86-64/Debian 9 and armv7/Debian 9 See #17554. - - - - - 5ffea0c6 by Tamar Christina at 2020-01-06T18:38:37-05:00 Fix overflow. - - - - - 99a9f51b by Sylvain Henry at 2020-01-06T18:39:22-05:00 Module hierarchy: Iface (cf #13009) - - - - - 7aa4a061 by Ben Gamari at 2020-01-07T13:11:48-05:00 configure: Only check GCC version if CC is GCC Also refactor FP_GCC_EXTRA_FLAGS in a few ways: * We no longer support compilers which lack support for -fno-builtin and -fwrapv so remove the condition on GccVersion * These flags are only necessary when using the via-C backend so make them conditional on Unregisterised. Fixes #15742. - - - - - 0805ed7e by John Ericson at 2020-01-07T13:12:25-05:00 Use non-empty lists to remove partiality in matching code - - - - - 7844f3a8 by Ben Gamari at 2020-01-07T13:13:02-05:00 testsuite: Mark T17073 as broken on Windows Due to #17607. - - - - - acf40cae by Ben Gamari at 2020-01-07T13:13:02-05:00 gitlab-ci: Disallow Windows from failing - - - - - 34bc02c7 by Ben Gamari at 2020-01-07T13:13:02-05:00 configure: Find Python3 for testsuite In addition, we prefer the Mingw64 Python distribution on Windows due to #17483. - - - - - e35fe8d5 by Ben Gamari at 2020-01-07T13:13:02-05:00 testsuite: Fix Windows platform test Previously we used platform.system() and while this worked fine (e.g. returned `Windows`, as expected) locally under both msys and MingW64 Python distributions, it inexplicably returned `MINGW64_NT-10.0` under MingW64 Python on CI. It seems os.name is more reliable so we now use that instead.. - - - - - 48ef6217 by Ben Gamari at 2020-01-07T13:13:39-05:00 gitlab-ci: Rename push-test-metrics.sh to test-metrics.sh Refactoring to follow. - - - - - 2234fa92 by Ben Gamari at 2020-01-07T13:13:39-05:00 gitlab-ci: Pull test metrics before running testsuite Otherwise the testsuite driver may not have an up-to-date baseline. - - - - - 1ca9adbc by Sylvain Henry at 2020-01-07T13:14:18-05:00 Remove `parallel` check from configure.ac `parallel` is no longer a submodule since 3cb063c805ec841ca33b8371ef8aba9329221b6c - - - - - b69a3460 by Ryan Scott at 2020-01-07T13:14:57-05:00 Monomorphize HsModule to GhcPs (#17642) Analyzing the call sites for `HsModule` reveals that it is only ever used with parsed code (i.e., `GhcPs`). This simplifies `HsModule` by concretizing its `pass` parameter to always be `GhcPs`. Fixes #17642. - - - - - d491a679 by Sylvain Henry at 2020-01-08T06:16:31-05:00 Module hierarchy: Renamer (cf #13009) - - - - - d589410f by Ben Gamari at 2020-01-08T06:17:09-05:00 Bump haskeline submodule to 0.8.0.1 (cherry picked from commit feb3b955402d53c3875dd7a9a39f322827e5bd69) - - - - - 923a1272 by Ryan Scott at 2020-01-08T06:17:47-05:00 Print Core type applications with no whitespace after @ (#17643) This brings the pretty-printer for Core in line with how visible type applications are normally printed: namely, with no whitespace after the `@` character (i.e., `f @a` instead of `f @ a`). While I'm in town, I also give the same treatment to type abstractions (i.e., `\(@a)` instead of `\(@ a)`) and coercion applications (i.e., `f @~x` instead of `f @~ x`). Fixes #17643. - - - - - 49f83a0d by Adam Sandberg Eriksson at 2020-01-12T21:28:09-05:00 improve docs for HeaderInfo.getImports [skip ci] - - - - - 9129210f by Matthew Pickering at 2020-01-12T21:28:47-05:00 Overloaded Quotation Brackets (#246) This patch implements overloaded quotation brackets which generalise the desugaring of all quotation forms in terms of a new minimal interface. The main change is that a quotation, for example, [e| 5 |], will now have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass contains a single method for generating new names which is used when desugaring binding structures. The return type of functions from the `Lift` type class, `lift` and `liftTyped` have been restricted to `forall m . Quote m => m Exp` rather than returning a result in a Q monad. More details about the feature can be read in the GHC proposal. https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst - - - - - 350e2b78 by Richard Eisenberg at 2020-01-12T21:29:27-05:00 Don't zap to Any; error instead This changes GHC's treatment of so-called Naughty Quantification Candidates to issue errors, instead of zapping to Any. Close #16775. No new test cases, because existing ones cover this well. - - - - - 0b5ddc7f by Brian Wignall at 2020-01-12T21:30:08-05:00 Fix more typos, via an improved Levenshtein-style corrector - - - - - f732dbec by Ben Gamari at 2020-01-12T21:30:49-05:00 gitlab-ci: Retain bindists used by head.hackage for longer Previously we would keep them for two weeks. However, on the stable branches two weeks can easily elapse with no pushes. - - - - - c8636da5 by Sylvain Henry at 2020-01-12T21:31:30-05:00 Fix LANG=C for readelf invocation in T14999 The test fails when used with LANG=fr_FR.UTF-8 - - - - - 077a88de by Jean-Baptiste Mazon at 2020-01-12T21:32:08-05:00 users-guide/debug-info: typo “behivior” - - - - - 61916c5d by Simon Peyton Jones at 2020-01-12T21:32:44-05:00 Add comments about TH levels - - - - - 1fd766ca by Simon Peyton Jones at 2020-01-12T21:32:44-05:00 Comments about constraint floating - - - - - de01427e by Simon Peyton Jones at 2020-01-12T21:32:45-05:00 Minor refactor around quantified constraints This patch clarifies a dark corner of quantified constraints. * See Note [Yukky eq_sel for a HoleDest] in TcSMonad * Minor refactor, breaking out new function TcInteract.doTopReactEqPred - - - - - 30be3bf1 by Simon Peyton Jones at 2020-01-12T21:32:45-05:00 Comments in TcHsType - - - - - c5977d4d by Sebastian Graf at 2020-01-16T05:58:58-05:00 Better documentation for mkEtaWW [skip ci] So that hopefully I understand it faster next time. Also got rid of the confusing `orig_expr`, which makes the call site in `etaExpand` look out of sync with the passed `n` (which is not the original `n`). - - - - - 22c0bdc3 by John Ericson at 2020-01-16T05:59:37-05:00 Handle TagToEnum in the same big case as the other primops Before, it was a panic because it was handled above. But there must have been an error in my reasoning (another caller?) because #17442 reported the panic was hit. But, rather than figuring out what happened, I can just make it impossible by construction. By adding just a bit more bureaucracy in the return types, I can handle TagToEnum in the same case as all the others, so the big case is is now total, and the panic is removed. Fixes #17442 - - - - - ee5d63f4 by John Ericson at 2020-01-16T05:59:37-05:00 Get rid of OpDest `OpDest` was basically a defunctionalization. Just turn the code that cased on it into those functions, and call them directly. - - - - - 1ff55226 by John Ericson at 2020-01-16T06:00:16-05:00 Remove special case case of bool during STG -> C-- Allow removing the no longer needed cgPrimOp, getting rid of a small a small layer violation too. Change which made the special case no longer needed was #6135 / 6579a6c73082387f82b994305011f011d9d8382b, which dates back to 2013, making me feel better. - - - - - f416fe64 by Adam Wespiser at 2020-01-16T06:00:53-05:00 replace dead html link (fixes #17661) - - - - - f6bf2ce8 by Sebastian Graf at 2020-01-16T06:01:32-05:00 Revert "`exprOkForSpeculation` for Note [IO hack in the demand analyser]" This reverts commit ce64b397777408731c6dd3f5c55ea8415f9f565b on the grounds of the regression it would introduce in a couple of packages. Fixes #17653. Also undoes a slight metric increase in #13701 introduced by that commit that we didn't see prior to !1983. Metric Decrease: T13701 - - - - - a71323ff by Ben Gamari at 2020-01-17T08:43:16-05:00 gitlab-ci: Don't FORCE_SYMLINKS on Windows Not all runners have symlink permissions enabled. - - - - - 0499e3bc by Ömer Sinan Ağacan at 2020-01-20T15:31:33-05:00 Fix +RTS -Z flag documentation Stack squeezing is done on context switch, not on GC or stack overflow. Fix the documentation. Fixes #17685 [ci skip] - - - - - a661df91 by Ömer Sinan Ağacan at 2020-01-20T15:32:13-05:00 Document Stg.FVs module Fixes #17662 [ci skip] - - - - - db24e480 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Don't trash STG registers Fixes #13904. - - - - - f3d7fdb3 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix typo in readnone attribute - - - - - 442751c6 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Add lower-expect to the -O0 optimisation set @kavon says that this will improve block layout for stack checks. - - - - - e90ecc93 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix #14251 Fixes the calling convention for functions passing raw SSE-register values by adding padding as needed to get the values in the right registers. This problem cropped up when some args were unused an dropped from the live list. This folds together 2e23e1c7de01c92b038e55ce53d11bf9db993dd4 and 73273be476a8cc6c13368660b042b3b0614fd928 previously from @kavon. Metric Increase: T12707 ManyConstructors - - - - - 66e511a4 by Ben Gamari at 2020-01-20T15:33:28-05:00 testsuite: Preserve more information in framework failures Namely print the entire exception in hopes that this will help track down #17649. - - - - - b62b8cea by Ömer Sinan Ağacan at 2020-01-20T15:34:06-05:00 Remove deprecated -smp flag It was deprecated in 2012 with 46258b40 - - - - - 0c04a86a by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Reenable submodule linter - - - - - 2bfabd22 by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Allow submodule cleaning to fail on Windows Currently CI is inexplicably failing with ``` $ git submodule foreach git clean -xdf fatal: not a git repository: libffi-tarballs/../.git/modules/libffi-tarballs ``` I have no idea how this working tree got into such a state but we do need to fail more gracefully when it happens. Consequently, we allow the cleaning step to fail. - - - - - 14bced99 by Xavier Denis at 2020-01-20T15:35:21-05:00 Put the docs for :instances in alphabetical position - - - - - 7e0bb82b by Ben Gamari at 2020-01-20T15:35:57-05:00 Add missing Note [Improvement from Ground Wanteds] Closes #17659. - - - - - 17e43a7c by Ben Gamari at 2020-01-20T15:36:32-05:00 unregisterised: Fix declaration for stg_NO_FINALIZER Previously it had a redundant _entry suffix. We never noticed this previously presumably because we never generated references to it (however hard to believe this may be). However, it did start failing in !1304. - - - - - 3dae006f by PHO at 2020-01-20T15:37:08-05:00 Avoid ./configure failure on NetBSD - - - - - 738e2912 by Ben Gamari at 2020-01-24T13:42:56-05:00 testsuite: Widen acceptance window of T1969 I have seen >20% fluctuations in this number, leading to spurious failures. - - - - - ad4eb7a7 by Gabor Greif at 2020-01-25T05:19:07-05:00 Document the fact, that openFileBlocking can consume an OS thread indefinitely. Also state that a deadlock can happen with the non-threaded runtime. [ci skip] - - - - - be910728 by Sebastian Graf at 2020-01-25T05:19:46-05:00 `-ddump-str-signatures` dumps Text, not STG [skip ci] - - - - - 0e57d8a1 by Ömer Sinan Ağacan at 2020-01-25T05:20:27-05:00 Fix chaining tagged and untagged ptrs in compacting GC Currently compacting GC has the invariant that in a chain all fields are tagged the same. However this does not really hold: root pointers are not tagged, so when we thread a root we initialize a chain without a tag. When the pointed objects is evaluated and we have more pointers to it from the heap, we then add *tagged* fields to the chain (because pointers to it from the heap are tagged), ending up chaining fields with different tags (pointers from roots are NOT tagged, pointers from heap are). This breaks the invariant and as a result compacting GC turns tagged pointers into non-tagged. This later causes problem in the generated code where we do reads assuming that the pointer is aligned, e.g. 0x7(%rax) -- assumes that pointer is tagged 1 which causes misaligned reads. This caused #17088. We fix this using the "pointer tagging for large families" patch (#14373, !1742): - With the pointer tagging patch the GC can know what the tagged pointer to a CONSTR should be (previously we'd need to know the family size -- large families are always tagged 1, small families are tagged depending on the constructor). - Since we now know what the tags should be we no longer need to store the pointer tag in the info table pointers when forming chains in the compacting GC. As a result we no longer need to tag pointers in chains with 1/2 depending on whether the field points to an info table pointer, or to another field: an info table pointer is always tagged 0, everything else in the chain is tagged 1. The lost tags in pointers can be retrieved by looking at the info table. Finally, instead of using tag 1 for fields and tag 0 for info table pointers, we use two different tags for fields: - 1 for fields that have untagged pointers - 2 for fields that have tagged pointers When unchaining we then look at the pointer to a field, and depending on its tag we either leave a tagged pointer or an untagged pointer in the field. This allows chaining untagged and tagged fields together in compacting GC. Fixes #17088 Nofib results ------------- Binaries are smaller because of smaller `Compact.c` code. make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" EXTRA_HC_OPTS="-with-rtsopts=-c" NoFibRuns=1 -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.3% 0.0% +0.0% +0.0% +0.0% CSD -0.3% 0.0% +0.0% +0.0% +0.0% FS -0.3% 0.0% +0.0% -0.0% -0.0% S -0.3% 0.0% +5.4% +0.8% +3.9% VS -0.3% 0.0% +0.0% -0.0% -0.0% VSD -0.3% 0.0% -0.0% -0.0% -0.2% VSM -0.3% 0.0% +0.0% +0.0% +0.0% anna -0.1% 0.0% +0.0% +0.0% +0.0% ansi -0.3% 0.0% +0.1% +0.0% +0.0% atom -0.2% 0.0% +0.0% +0.0% +0.0% awards -0.2% 0.0% +0.0% 0.0% -0.0% banner -0.3% 0.0% +0.0% +0.0% +0.0% bernouilli -0.3% 0.0% +0.1% +0.0% +0.0% binary-trees -0.2% 0.0% +0.0% 0.0% +0.0% boyer -0.3% 0.0% +0.2% +0.0% +0.0% boyer2 -0.2% 0.0% +0.2% +0.1% +0.0% bspt -0.2% 0.0% +0.0% +0.0% +0.0% cacheprof -0.2% 0.0% +0.0% +0.0% +0.0% calendar -0.3% 0.0% +0.0% +0.0% +0.0% cichelli -0.3% 0.0% +1.1% +0.2% +0.5% circsim -0.2% 0.0% +0.0% -0.0% -0.0% clausify -0.3% 0.0% +0.0% -0.0% -0.0% comp_lab_zift -0.2% 0.0% +0.0% +0.0% +0.0% compress -0.3% 0.0% +0.0% +0.0% +0.0% compress2 -0.3% 0.0% +0.0% -0.0% -0.0% constraints -0.3% 0.0% +0.2% +0.1% +0.1% cryptarithm1 -0.3% 0.0% +0.0% -0.0% 0.0% cryptarithm2 -0.3% 0.0% +0.0% +0.0% +0.0% cse -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e1 -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e2 -0.3% 0.0% +0.0% +0.0% -0.0% dom-lt -0.2% 0.0% +0.0% +0.0% +0.0% eliza -0.2% 0.0% +0.0% +0.0% +0.0% event -0.3% 0.0% +0.1% +0.0% -0.0% exact-reals -0.2% 0.0% +0.0% +0.0% +0.0% exp3_8 -0.3% 0.0% +0.0% +0.0% +0.0% expert -0.2% 0.0% +0.0% +0.0% +0.0% fannkuch-redux -0.3% 0.0% -0.0% -0.0% -0.0% fasta -0.3% 0.0% +0.0% +0.0% +0.0% fem -0.2% 0.0% +0.1% +0.0% +0.0% fft -0.2% 0.0% +0.0% -0.0% -0.0% fft2 -0.2% 0.0% +0.0% -0.0% +0.0% fibheaps -0.3% 0.0% +0.0% -0.0% -0.0% fish -0.3% 0.0% +0.0% +0.0% +0.0% fluid -0.2% 0.0% +0.4% +0.1% +0.1% fulsom -0.2% 0.0% +0.0% +0.0% +0.0% gamteb -0.2% 0.0% +0.1% +0.0% +0.0% gcd -0.3% 0.0% +0.0% +0.0% +0.0% gen_regexps -0.3% 0.0% +0.0% -0.0% -0.0% genfft -0.3% 0.0% +0.0% +0.0% +0.0% gg -0.2% 0.0% +0.7% +0.3% +0.2% grep -0.2% 0.0% +0.0% +0.0% +0.0% hidden -0.2% 0.0% +0.0% +0.0% +0.0% hpg -0.2% 0.0% +0.1% +0.0% +0.0% ida -0.3% 0.0% +0.0% +0.0% +0.0% infer -0.2% 0.0% +0.0% -0.0% -0.0% integer -0.3% 0.0% +0.0% +0.0% +0.0% integrate -0.2% 0.0% +0.0% +0.0% +0.0% k-nucleotide -0.2% 0.0% +0.0% +0.0% -0.0% kahan -0.3% 0.0% -0.0% -0.0% -0.0% knights -0.3% 0.0% +0.0% -0.0% -0.0% lambda -0.3% 0.0% +0.0% -0.0% -0.0% last-piece -0.3% 0.0% +0.0% +0.0% +0.0% lcss -0.3% 0.0% +0.0% +0.0% 0.0% life -0.3% 0.0% +0.0% -0.0% -0.0% lift -0.2% 0.0% +0.0% +0.0% +0.0% linear -0.2% 0.0% +0.0% +0.0% +0.0% listcompr -0.3% 0.0% +0.0% +0.0% +0.0% listcopy -0.3% 0.0% +0.0% +0.0% +0.0% maillist -0.3% 0.0% +0.0% -0.0% -0.0% mandel -0.2% 0.0% +0.0% +0.0% +0.0% mandel2 -0.3% 0.0% +0.0% +0.0% +0.0% mate -0.2% 0.0% +0.0% +0.0% +0.0% minimax -0.3% 0.0% +0.0% +0.0% +0.0% mkhprog -0.2% 0.0% +0.0% +0.0% +0.0% multiplier -0.3% 0.0% +0.0% -0.0% -0.0% n-body -0.2% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.2% 0.0% +0.0% +0.0% +0.0% para -0.2% 0.0% +0.0% -0.0% -0.0% paraffins -0.3% 0.0% +0.0% -0.0% -0.0% parser -0.2% 0.0% +0.0% +0.0% +0.0% parstof -0.2% 0.0% +0.8% +0.2% +0.2% pic -0.2% 0.0% +0.1% -0.1% -0.1% pidigits -0.3% 0.0% +0.0% +0.0% +0.0% power -0.2% 0.0% +0.0% -0.0% -0.0% pretty -0.3% 0.0% -0.0% -0.0% -0.1% primes -0.3% 0.0% +0.0% +0.0% -0.0% primetest -0.2% 0.0% +0.0% -0.0% -0.0% prolog -0.3% 0.0% +0.0% -0.0% -0.0% puzzle -0.3% 0.0% +0.0% +0.0% +0.0% queens -0.3% 0.0% +0.0% +0.0% +0.0% reptile -0.2% 0.0% +0.2% +0.1% +0.0% reverse-complem -0.3% 0.0% +0.0% +0.0% +0.0% rewrite -0.3% 0.0% +0.0% -0.0% -0.0% rfib -0.2% 0.0% +0.0% +0.0% -0.0% rsa -0.2% 0.0% +0.0% +0.0% +0.0% scc -0.3% 0.0% -0.0% -0.0% -0.1% sched -0.3% 0.0% +0.0% +0.0% +0.0% scs -0.2% 0.0% +0.1% +0.0% +0.0% simple -0.2% 0.0% +3.4% +1.0% +1.8% solid -0.2% 0.0% +0.0% +0.0% +0.0% sorting -0.3% 0.0% +0.0% +0.0% +0.0% spectral-norm -0.2% 0.0% -0.0% -0.0% -0.0% sphere -0.2% 0.0% +0.0% +0.0% +0.0% symalg -0.2% 0.0% +0.0% +0.0% +0.0% tak -0.3% 0.0% +0.0% +0.0% -0.0% transform -0.2% 0.0% +0.2% +0.1% +0.1% treejoin -0.3% 0.0% +0.2% -0.0% -0.1% typecheck -0.3% 0.0% +0.0% +0.0% +0.0% veritas -0.1% 0.0% +0.0% +0.0% +0.0% wang -0.2% 0.0% +0.0% -0.0% -0.0% wave4main -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve1 -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve2 -0.3% 0.0% +0.0% -0.0% -0.0% x2n1 -0.3% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min -0.3% 0.0% -0.0% -0.1% -0.2% Max -0.1% 0.0% +5.4% +1.0% +3.9% Geometric Mean -0.3% -0.0% +0.1% +0.0% +0.1% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.2% 0.0% +1.6% +0.4% +0.7% constraints -0.3% 0.0% +4.3% +1.5% +2.3% fibheaps -0.3% 0.0% +3.5% +1.2% +1.3% fulsom -0.2% 0.0% +3.6% +1.2% +1.8% gc_bench -0.3% 0.0% +4.1% +1.3% +2.3% hash -0.3% 0.0% +6.6% +2.2% +3.6% lcss -0.3% 0.0% +0.7% +0.2% +0.7% mutstore1 -0.3% 0.0% +4.8% +1.4% +2.8% mutstore2 -0.3% 0.0% +3.4% +1.0% +1.7% power -0.2% 0.0% +2.7% +0.6% +1.9% spellcheck -0.3% 0.0% +1.1% +0.4% +0.4% -------------------------------------------------------------------------------- Min -0.3% 0.0% +0.7% +0.2% +0.4% Max -0.2% 0.0% +6.6% +2.2% +3.6% Geometric Mean -0.3% +0.0% +3.3% +1.0% +1.8% Metric changes -------------- While it sounds ridiculous, this change causes increased allocations in the following tests. We concluded that this change can't cause a difference in allocations and decided to land this patch. Fluctuations in "bytes allocated" metric is tracked in #17686. Metric Increase: Naperian T10547 T12150 T12234 T12425 T13035 T5837 T6048 - - - - - 8038cbd9 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Formulate as translation between Clause Trees We used to check `GrdVec`s arising from multiple clauses and guards in isolation. That resulted in a split between `pmCheck` and `pmCheckGuards`, the implementations of which were similar, but subtly different in detail. Also the throttling mechanism described in `Note [Countering exponential blowup]` ultimately got quite complicated because it had to cater for both checking functions. This patch realises that pattern match checking doesn't just consider single guarded RHSs, but that it's always a whole set of clauses, each of which can have multiple guarded RHSs in turn. We do so by translating a list of `Match`es to a `GrdTree`: ```haskell data GrdTree = Rhs !RhsInfo | Guard !PmGrd !GrdTree -- captures lef-to-right match semantics | Sequence !GrdTree !GrdTree -- captures top-to-bottom match semantics | Empty -- For -XEmptyCase, neutral element of Sequence ``` Then we have a function `checkGrdTree` that matches a given `GrdTree` against an incoming set of values, represented by `Deltas`: ```haskell checkGrdTree :: GrdTree -> Deltas -> CheckResult ... ``` Throttling is isolated to the `Sequence` case and becomes as easy as one would expect: When the union of uncovered values becomes too big, just return the original incoming `Deltas` instead (which is always a superset of the union, thus a sound approximation). The returned `CheckResult` contains two things: 1. The set of values that were not covered by any of the clauses, for exhaustivity warnings. 2. The `AnnotatedTree` that enriches the syntactic structure of the input program with divergence and inaccessibility information. This is `AnnotatedTree`: ```haskell data AnnotatedTree = AccessibleRhs !RhsInfo | InaccessibleRhs !RhsInfo | MayDiverge !AnnotatedTree | SequenceAnn !AnnotatedTree !AnnotatedTree | EmptyAnn ``` Crucially, `MayDiverge` asserts that the tree may force diverging values, so not all of its wrapped clauses can be redundant. While the set of uncovered values can be used to generate the missing equations for warning messages, redundant and proper inaccessible equations can be extracted from `AnnotatedTree` by `redundantAndInaccessibleRhss`. For this to work properly, the interface to the Oracle had to change. There's only `addPmCts` now, which takes a bag of `PmCt`s. There's a whole bunch of `PmCt` variants to replace the different oracle functions from before. The new `AnnotatedTree` structure allows for more accurate warning reporting (as evidenced by a number of changes spread throughout GHC's code base), thus we fix #17465. Fixes #17646 on the go. Metric Decrease: T11822 T9233 PmSeriesS haddock.compiler - - - - - 86966d48 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Properly handle constructor-bound type variables In https://gitlab.haskell.org/ghc/ghc/merge_requests/2192#note_246551 Simon convinced me that ignoring type variables existentially bound by data constructors have to be the same way as value binders. Sadly I couldn't think of a regression test, but I'm confident that this change strictly improves on the status quo. - - - - - c3fde723 by Ryan Scott at 2020-01-25T05:21:40-05:00 Handle local fixity declarations in DsMeta properly `DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the effect of causing local fixity declarations to be dropped when quoted in Template Haskell. But there is no good reason for this state of affairs, as the code in `DsMeta.repFixD` (which handles top-level fixity declarations) handles local fixity declarations just fine. This patch factors out the necessary parts of `repFixD` so that they can be used in `rep_sig` as well. There was one minor complication: the fixity signatures for class methods in each `HsGroup` were stored both in `FixSig`s _and_ the list of `LFixitySig`s for top-level fixity signatures, so I needed to take action to prevent fixity signatures for class methods being converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting these fixity signatures in two places and added `Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls` to explain the new design. Fixes #17608. Bumps the Haddock submodule. - - - - - 6e2d9ee2 by Sylvain Henry at 2020-01-25T05:22:20-05:00 Module hierarchy: Cmm (cf #13009) - - - - - 8b726534 by PHO at 2020-01-25T05:23:01-05:00 Fix rts allocateExec() on NetBSD Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page mapping both writable and executable at the same time. Use libffi which knows how to work around it. - - - - - 6eb566a0 by Xavier Denis at 2020-01-25T05:23:39-05:00 Add ghc-in-ghci for stack based builds - - - - - b1a32170 by Xavier Denis at 2020-01-25T05:23:39-05:00 Create ghci.cabal.sh - - - - - 0a5e4f5f by Sylvain Henry at 2020-01-25T05:24:19-05:00 Split glasgow_exts into several files (#17316) - - - - - b3e5c678 by Ben Gamari at 2020-01-25T05:24:57-05:00 hadrian: Throw error on duplicate-named flavours Throw an error if the user requests a flavour for which there is more than one match. Fixes #17156. - - - - - 0940b59a by Ryan Scott at 2020-01-25T08:15:05-05:00 Do not bring visible foralls into scope in hsScopedTvs Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended that visible dependent quantification could not possibly happen at the term level, and cemented that assumption with an `ASSERT`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) = ASSERT( vis_flag == ForallInvis ) ... ``` It turns out that this assumption is wrong. You can end up tripping this `ASSERT` if you stick it to the man and write a type for a term that uses visible dependent quantification anyway, like in this example: ```hs {-# LANGUAGE ScopedTypeVariables #-} x :: forall a -> a -> a x = x ``` That won't typecheck, but that's not the point. Before the typechecker has a chance to reject this, the renamer will try to use `hsScopedTvs` to bring `a` into scope over the body of `x`, since `a` is quantified by a `forall`. This, in turn, causes the `ASSERT` to fail. Bummer. Instead of walking on this dangerous ground, this patch makes GHC adopt a more hardline stance by pattern-matching directly on `ForallInvis` in `hsScopedTvs`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ... ``` Now `a` will not be brought over the body of `x` at all (which is how it should be), there's no chance of the `ASSERT` failing anymore (as it's gone), and best of all, the behavior of `hsScopedTvs` does not change. Everyone wins! Fixes #17687. - - - - - 1132602f by Ryan Scott at 2020-01-27T10:03:42-05:00 Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase Richard points out in #17688 that we use `splitLHsForAllTy` and `splitLHsSigmaTy` in places that we ought to be using the corresponding `-Invis` variants instead, identifying two bugs that are caused by this oversight: * Certain TH-quoted type signatures, such as those that appear in quoted `SPECIALISE` pragmas, silently turn visible `forall`s into invisible `forall`s. * When quoted, the type `forall a -> (a ~ a) => a` will turn into `forall a -> a` due to a bug in `DsMeta.repForall` that drops contexts that follow visible `forall`s. These are both ultimately caused by the fact that `splitLHsForAllTy` and `splitLHsSigmaTy` split apart visible `forall`s in addition to invisible ones. This patch cleans things up: * We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis` throughout the codebase. Relatedly, the `splitLHsForAllTy` and `splitLHsSigmaTy` have been removed, as they are easy to misuse. * `DsMeta.repForall` now only handles invisible `forall`s to reduce the chance for confusion with visible `forall`s, which need to be handled differently. I also renamed it from `repForall` to `repForallT` to emphasize that its distinguishing characteristic is the fact that it desugars down to `L.H.TH.Syntax.ForallT`. Fixes #17688. - - - - - 97d0b0a3 by Matthew Pickering at 2020-01-27T10:04:19-05:00 Make Block.h compile with c++ compilers - - - - - 4bada77d by Tom Ellis at 2020-01-27T12:30:46-05:00 Disable two warnings for files that trigger them incomplete-uni-patterns and incomplete-record-updates will be in -Wall at a future date, so prepare for that by disabling those warnings on files that trigger them. - - - - - 0188404a by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to stage 2 build - - - - - acae02c1 by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to Hadrian - - - - - bf38a20e by Sylvain Henry at 2020-01-31T02:46:15-05:00 Call `interpretPackageEnv` from `setSessionDynFlags` interpretPackageEnv modifies the flags by reading the dreaded package environments. It is much less surprising to call it from `setSessionDynFlags` instead of reading package environments as a side-effect of `initPackages`. - - - - - 29c701c1 by Sylvain Henry at 2020-01-31T02:46:15-05:00 Refactor package related code The package terminology is a bit of a mess. Cabal packages contain components. Instances of these components when built with some flags/options/dependencies are called units. Units are registered into package databases and their metadata are called PackageConfig. GHC only knows about package databases containing units. It is a sad mismatch not fixed by this patch (we would have to rename parameters such as `package-id <unit-id>` which would affect users). This patch however fixes the following internal names: - Renames PackageConfig into UnitInfo. - Rename systemPackageConfig into globalPackageDatabase[Path] - Rename PkgConfXX into PkgDbXX - Rename pkgIdMap into unitIdMap - Rename ModuleToPkgDbAll into ModuleNameProvidersMap - Rename lookupPackage into lookupUnit - Add comments on DynFlags package related fields It also introduces a new `PackageDatabase` datatype instead of explicitly passing the following tuple: `(FilePath,[PackageConfig])`. The `pkgDatabase` field in `DynFlags` now contains the unit info for each unit of each package database exactly as they have been read from disk. Previously the command-line flag `-distrust-all-packages` would modify these unit info. Now this flag only affects the "dynamic" consolidated package state found in `pkgState` field. It makes sense because `initPackages` could be called first with this `distrust-all-packages` flag set and then again (using ghc-api) without and it should work (package databases are not read again from disk when `initPackages` is called the second time). Bump haddock submodule - - - - - 942c7148 by Ben Gamari at 2020-01-31T02:46:54-05:00 rename: Eliminate usage of mkVarOccUnique Replacing it with `newSysName`. Fixes #17061. - - - - - 41117d71 by Ben Gamari at 2020-01-31T02:47:31-05:00 base: Use one-shot kqueue on macOS The underlying reason requiring that one-shot usage be disabled (#13903) has been fixed. Closes #15768. - - - - - 01b15b83 by Ben Gamari at 2020-01-31T02:48:08-05:00 testsuite: Don't crash on encoding failure in print If the user doesn't use a Unicode locale then the testsuite driver would previously throw framework failures due to encoding failures. We now rather use the `replace` error-handling strategy. - - - - - c846618a by Ömer Sinan Ağacan at 2020-01-31T12:21:10+03:00 Do CafInfo/SRT analysis in Cmm This patch removes all CafInfo predictions and various hacks to preserve predicted CafInfos from the compiler and assigns final CafInfos to interface Ids after code generation. SRT analysis is extended to support static data, and Cmm generator is modified to allow generating static_link fields after SRT analysis. This also fixes `-fcatch-bottoms`, which introduces error calls in case expressions in CorePrep, which runs *after* CoreTidy (which is where we decide on CafInfos) and turns previously non-CAFFY things into CAFFY. Fixes #17648 Fixes #9718 Evaluation ========== NoFib ----- Boot with: `make boot mode=fast` Run: `make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" NoFibRuns=1` -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.0% 0.0% -0.0% -0.0% -0.0% CSD -0.0% 0.0% -0.0% -0.0% -0.0% FS -0.0% 0.0% -0.0% -0.0% -0.0% S -0.0% 0.0% -0.0% -0.0% -0.0% VS -0.0% 0.0% -0.0% -0.0% -0.0% VSD -0.0% 0.0% -0.0% -0.0% -0.5% VSM -0.0% 0.0% -0.0% -0.0% -0.0% anna -0.1% 0.0% -0.0% -0.0% -0.0% ansi -0.0% 0.0% -0.0% -0.0% -0.0% atom -0.0% 0.0% -0.0% -0.0% -0.0% awards -0.0% 0.0% -0.0% -0.0% -0.0% banner -0.0% 0.0% -0.0% -0.0% -0.0% bernouilli -0.0% 0.0% -0.0% -0.0% -0.0% binary-trees -0.0% 0.0% -0.0% -0.0% -0.0% boyer -0.0% 0.0% -0.0% -0.0% -0.0% boyer2 -0.0% 0.0% -0.0% -0.0% -0.0% bspt -0.0% 0.0% -0.0% -0.0% -0.0% cacheprof -0.0% 0.0% -0.0% -0.0% -0.0% calendar -0.0% 0.0% -0.0% -0.0% -0.0% cichelli -0.0% 0.0% -0.0% -0.0% -0.0% circsim -0.0% 0.0% -0.0% -0.0% -0.0% clausify -0.0% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.0% 0.0% -0.0% -0.0% -0.0% compress -0.0% 0.0% -0.0% -0.0% -0.0% compress2 -0.0% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.0% 0.0% -0.0% -0.0% -0.0% cse -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.0% 0.0% -0.0% -0.0% -0.0% dom-lt -0.0% 0.0% -0.0% -0.0% -0.0% eliza -0.0% 0.0% -0.0% -0.0% -0.0% event -0.0% 0.0% -0.0% -0.0% -0.0% exact-reals -0.0% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.0% 0.0% -0.0% -0.0% -0.0% expert -0.0% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.0% 0.0% -0.0% -0.0% -0.0% fasta -0.0% 0.0% -0.0% -0.0% -0.0% fem -0.0% 0.0% -0.0% -0.0% -0.0% fft -0.0% 0.0% -0.0% -0.0% -0.0% fft2 -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% fish -0.0% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.0% 0.0% -0.0% -0.0% -0.0% gamteb -0.0% 0.0% -0.0% -0.0% -0.0% gcd -0.0% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.0% 0.0% -0.0% -0.0% -0.0% genfft -0.0% 0.0% -0.0% -0.0% -0.0% gg -0.0% 0.0% -0.0% -0.0% -0.0% grep -0.0% 0.0% -0.0% -0.0% -0.0% hidden -0.0% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.0% 0.0% -0.0% -0.0% -0.0% infer -0.0% 0.0% -0.0% -0.0% -0.0% integer -0.0% 0.0% -0.0% -0.0% -0.0% integrate -0.0% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.0% 0.0% -0.0% -0.0% -0.0% kahan -0.0% 0.0% -0.0% -0.0% -0.0% knights -0.0% 0.0% -0.0% -0.0% -0.0% lambda -0.0% 0.0% -0.0% -0.0% -0.0% last-piece -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% life -0.0% 0.0% -0.0% -0.0% -0.0% lift -0.0% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.0% 0.0% -0.0% -0.0% -0.0% listcopy -0.0% 0.0% -0.0% -0.0% -0.0% maillist -0.0% 0.0% -0.0% -0.0% -0.0% mandel -0.0% 0.0% -0.0% -0.0% -0.0% mandel2 -0.0% 0.0% -0.0% -0.0% -0.0% mate -0.0% 0.0% -0.0% -0.0% -0.0% minimax -0.0% 0.0% -0.0% -0.0% -0.0% mkhprog -0.0% 0.0% -0.0% -0.0% -0.0% multiplier -0.0% 0.0% -0.0% -0.0% -0.0% n-body -0.0% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.0% 0.0% -0.0% -0.0% -0.0% para -0.0% 0.0% -0.0% -0.0% -0.0% paraffins -0.0% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.0% 0.0% -0.0% -0.0% -0.0% pidigits -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% pretty -0.0% 0.0% -0.3% -0.4% -0.4% primes -0.0% 0.0% -0.0% -0.0% -0.0% primetest -0.0% 0.0% -0.0% -0.0% -0.0% prolog -0.0% 0.0% -0.0% -0.0% -0.0% puzzle -0.0% 0.0% -0.0% -0.0% -0.0% queens -0.0% 0.0% -0.0% -0.0% -0.0% reptile -0.0% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.0% 0.0% -0.0% -0.0% -0.0% rewrite -0.0% 0.0% -0.0% -0.0% -0.0% rfib -0.0% 0.0% -0.0% -0.0% -0.0% rsa -0.0% 0.0% -0.0% -0.0% -0.0% scc -0.0% 0.0% -0.3% -0.5% -0.4% sched -0.0% 0.0% -0.0% -0.0% -0.0% scs -0.0% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.0% 0.0% -0.0% -0.0% -0.0% sorting -0.0% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.0% 0.0% -0.0% -0.0% -0.0% sphere -0.0% 0.0% -0.0% -0.0% -0.0% symalg -0.0% 0.0% -0.0% -0.0% -0.0% tak -0.0% 0.0% -0.0% -0.0% -0.0% transform -0.0% 0.0% -0.0% -0.0% -0.0% treejoin -0.0% 0.0% -0.0% -0.0% -0.0% typecheck -0.0% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.0% 0.0% -0.0% -0.0% -0.0% wave4main -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.0% 0.0% -0.0% -0.0% -0.0% x2n1 -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.3% -0.5% -0.5% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% -0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% gc_bench -0.0% 0.0% -0.0% -0.0% -0.0% hash -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% spellcheck -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.0% -0.0% -0.0% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% +0.0% -0.0% -0.0% -0.0% Manual inspection of programs in testsuite/tests/programs --------------------------------------------------------- I built these programs with a bunch of dump flags and `-O` and compared STG, Cmm, and Asm dumps and file sizes. (Below the numbers in parenthesis show number of modules in the program) These programs have identical compiler (same .hi and .o sizes, STG, and Cmm and Asm dumps): - Queens (1), andre_monad (1), cholewo-eval (2), cvh_unboxing (3), andy_cherry (7), fun_insts (1), hs-boot (4), fast2haskell (2), jl_defaults (1), jq_readsPrec (1), jules_xref (1), jtod_circint (4), jules_xref2 (1), lennart_range (1), lex (1), life_space_leak (1), bargon-mangler-bug (7), record_upd (1), rittri (1), sanders_array (1), strict_anns (1), thurston-module-arith (2), okeefe_neural (1), joao-circular (6), 10queens (1) Programs with different compiler outputs: - jl_defaults (1): For some reason GHC HEAD marks a lot of top-level `[Int]` closures as CAFFY for no reason. With this patch we no longer make them CAFFY and generate less SRT entries. For some reason Main.o is slightly larger with this patch (1.3%) and the executable sizes are the same. (I'd expect both to be smaller) - launchbury (1): Same as jl_defaults: top-level `[Int]` closures marked as CAFFY for no reason. Similarly `Main.o` is 1.4% larger but the executable sizes are the same. - galois_raytrace (13): Differences are in the Parse module. There are a lot, but some of the changes are caused by the fact that for some reason (I think a bug) GHC HEAD marks the dictionary for `Functor Identity` as CAFFY. Parse.o is 0.4% larger, the executable size is the same. - north_array: We now generate less SRT entries because some of array primops used in this program like `NewArrayOp` get eliminated during Stg-to-Cmm and turn some CAFFY things into non-CAFFY. Main.o gets 24% larger (9224 bytes from 9000 bytes), executable sizes are the same. - seward-space-leak: Difference in this program is better shown by this smaller example: module Lib where data CDS = Case [CDS] [(Int, CDS)] | Call CDS CDS instance Eq CDS where Case sels1 rets1 == Case sels2 rets2 = sels1 == sels2 && rets1 == rets2 Call a1 b1 == Call a2 b2 = a1 == a2 && b1 == b2 _ == _ = False In this program GHC HEAD builds a new SRT for the recursive group of `(==)`, `(/=)` and the dictionary closure. Then `/=` points to `==` in its SRT field, and `==` uses the SRT object as its SRT. With this patch we use the closure for `/=` as the SRT and add `==` there. Then `/=` gets an empty SRT field and `==` points to `/=` in its SRT field. This change looks fine to me. Main.o gets 0.07% larger, executable sizes are identical. head.hackage ------------ head.hackage's CI script builds 428 packages from Hackage using this patch with no failures. Compiler performance -------------------- The compiler perf tests report that the compiler allocates slightly more (worst case observed so far is 4%). However most programs in the test suite are small, single file programs. To benchmark compiler performance on something more realistic I build Cabal (the library, 236 modules) with different optimisation levels. For the "max residency" row I run GHC with `+RTS -s -A100k -i0 -h` for more accurate numbers. Other rows are generated with just `-s`. (This is because `-i0` causes running GC much more frequently and as a result "bytes copied" gets inflated by more than 25x in some cases) * -O0 | | GHC HEAD | This MR | Diff | | --------------- | -------------- | -------------- | ------ | | Bytes allocated | 54,413,350,872 | 54,701,099,464 | +0.52% | | Bytes copied | 4,926,037,184 | 4,990,638,760 | +1.31% | | Max residency | 421,225,624 | 424,324,264 | +0.73% | * -O1 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 245,849,209,992 | 246,562,088,672 | +0.28% | | Bytes copied | 26,943,452,560 | 27,089,972,296 | +0.54% | | Max residency | 982,643,440 | 991,663,432 | +0.91% | * -O2 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 291,044,511,408 | 291,863,910,912 | +0.28% | | Bytes copied | 37,044,237,616 | 36,121,690,472 | -2.49% | | Max residency | 1,071,600,328 | 1,086,396,256 | +1.38% | Extra compiler allocations -------------------------- Runtime allocations of programs are as reported above (NoFib section). The compiler now allocates more than before. Main source of allocation in this patch compared to base commit is the new SRT algorithm (GHC.Cmm.Info.Build). Below is some of the extra work we do with this patch, numbers generated by profiled stage 2 compiler when building a pathological case (the test 'ManyConstructors') with '-O2': - We now sort the final STG for a module, which means traversing the entire program, generating free variable set for each top-level binding, doing SCC analysis, and re-ordering the program. In ManyConstructors this step allocates 97,889,952 bytes. - We now do SRT analysis on static data, which in a program like ManyConstructors causes analysing 10,000 bindings that we would previously just skip. This step allocates 70,898,352 bytes. - We now maintain an SRT map for the entire module as we compile Cmm groups: data ModuleSRTInfo = ModuleSRTInfo { ... , moduleSRTMap :: SRTMap } (SRTMap is just a strict Map from the 'containers' library) This map gets an entry for most bindings in a module (exceptions are THUNKs and CAFFY static functions). For ManyConstructors this map gets 50015 entries. - Once we're done with code generation we generate a NameSet from SRTMap for the non-CAFFY names in the current module. This set gets the same number of entries as the SRTMap. - Finally we update CafInfos in ModDetails for the non-CAFFY Ids, using the NameSet generated in the previous step. This usually does the least amount of allocation among the work listed here. Only place with this patch where we do less work in the CAF analysis in the tidying pass (CoreTidy). However that doesn't save us much, as the pass still needs to traverse the whole program and update IdInfos for other reasons. Only thing we don't here do is the `hasCafRefs` pass over the RHS of bindings, which is a stateless pass that returns a boolean value, so it doesn't allocate much. (Metric changes blow are all increased allocations) Metric changes -------------- Metric Increase: ManyAlternatives ManyConstructors T13035 T14683 T1969 T9961 - - - - - 2a87a565 by Andreas Klebinger at 2020-01-31T12:21:10+03:00 A few optimizations in STG and Cmm parts: (Guided by the profiler output) - Add a few bang patterns, INLINABLE annotations, and a seqList in a few places in Cmm and STG parts. - Do not add external variables as dependencies in STG dependency analysis (GHC.Stg.DepAnal). - - - - - bef704b6 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve skolemisation This patch avoids skolemiseUnboundMetaTyVar making up a fresh Name when it doesn't need to. See Note [Skolemising and identity] Improves error messsages for partial type signatures. - - - - - cd110423 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve pretty-printing for TyConBinders In particular, show their kinds. - - - - - 913287a0 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Fix scoping of TyCon binders in TcTyClsDecls This patch fixes #17566 by refactoring the way we decide the final identity of the tyvars in the TyCons of a possibly-recursive nest of type and class decls, possibly with associated types. It's all laid out in Note [Swizzling the tyvars before generaliseTcTyCon] Main changes: * We have to generalise each decl (with its associated types) all at once: TcTyClsDecls.generaliseTyClDecl * The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs * The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether Other smaller things: * A little refactoring, moving bindTyClTyVars from tcTyClDecl1 to tcDataDefn, tcSynRhs, etc. Clearer, reduces the number of parameters * Reduce the amount of swizzling required. Specifically, bindExplicitTKBndrs_Q_Tv doesn't need to clone a new Name for the TyVarTv, and not cloning means that in the vasly common case, swizzleTyConBndrs is a no-op In detail: Rename newTyVarTyVar --> cloneTyVarTyVar Add newTyVarTyTyVar that doesn't clone Use the non-cloning newTyVarTyVar in bindExplicitTKBndrs_Q_Tv Rename newFlexiKindedTyVarTyVar --> cloneFlexiKindedTyVarTyVar * Define new utility function and use it HsDecls.familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p) Updates haddock submodule. - - - - - 58ed6c4a by Ben Gamari at 2020-02-01T02:29:23-05:00 rts/M32Alloc: Don't attempt to unmap non-existent pages The m32 allocator's `pages` list may contain NULLs in the case that the page was flushed. Some `munmap` implementations (e.g. FreeBSD's) don't like it if we pass them NULL. Don't do that. - - - - - 859db7d6 by Ömer Sinan Ağacan at 2020-02-01T14:18:49+03:00 Improve/fix -fcatch-bottoms documentation Old documentation suggests that -fcatch-bottoms only adds a default alternative to bottoming case expression, but that's not true. We use a very simplistic "is exhaustive" check and add default alternatives to any case expression that does not cover all constructors of the type. In case of GADTs this simple check assumes all constructors should be covered, even the ones ruled out by the type of the scrutinee. Update the documentation to reflect this. (Originally noticed in #17648) [ci skip] - - - - - 54dfa94a by John Ericson at 2020-02-03T21:14:24-05:00 Fix docs for FrontendResult Other variant was removed in ac1a379363618a6f2f17fff65ce9129164b6ef30 but docs were no changed. - - - - - 5e63d9c0 by John Ericson at 2020-02-03T21:15:02-05:00 Refactor HscMain.finish I found the old control flow a bit hard to follow; I rewrote it to first decide whether to desugar, and then use that choice when computing whether to simplify / what sort of interface file to write. I hope eventually we will always write post-tc interface files, which will make the logic of this function even simpler, and continue the thrust of this refactor. - - - - - e580e5b8 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 Do not build StgCRunAsm.S for unregisterised builds For unregisterised builds StgRun/StgReturn are implemented via a mini interpreter in StgCRun.c and therefore would collide with the implementations in StgCRunAsm.S. - - - - - e3b0bd97 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 fixup! fixup! Do not build StgCRunAsm.S for unregisterised builds - - - - - eb629fab by John Ericson at 2020-02-04T09:29:38-05:00 Delete some superfluous helper functions in HscMain The driver code is some of the nastiest in GHC, and I am worried about being able to untangle all the tech debt. In `HscMain` we have a number of helpers which are either not-used or little used. I delete them so we can reduce cognative load, distilling the essential complexity away from the cruft. - - - - - c90eca55 by Sebastian Graf at 2020-02-05T09:21:29-05:00 PmCheck: Record type constraints arising from existentials in `PmCoreCt`s In #17703 (a follow-up of !2192), we established that contrary to my belief, type constraints arising from existentials in code like ```hs data Ex where Ex :: a -> Ex f _ | let x = Ex @Int 15 = case x of Ex -> ... ``` are in fact useful. This commit makes a number of refactorings and improvements to comments, but fundamentally changes `addCoreCt.core_expr` to record the type constraint `a ~ Int` in addition to `x ~ Ex @a y` and `y ~ 15`. Fixes #17703. - - - - - 6d3b5d57 by Ömer Sinan Ağacan at 2020-02-05T09:22:10-05:00 testlib: Extend existing *_opts in extra_*_opts Previously we'd override the existing {run,hc} opts in extra_{run,hc}_opts, which caused flakiness in T1969, see #17712. extra_{run,hc}_opts now extends {run,hc} opts, instead of overriding. Also we shrank the allocation area for T1969 in order to increase residency sampling frequency. Fixes #17712 - - - - - 9c89a48d by Ömer Sinan Ağacan at 2020-02-05T09:22:52-05:00 Remove CafInfo-related code from STG lambda lift pass After c846618ae0 we don't have accurate CafInfos for Ids in the current module and we're free to introduce new CAFFY or non-CAFFY bindings or change CafInfos of existing binders; so no we no longer need to maintain CafInfos in Core or STG passes. - - - - - 70ddb8bf by Ryan Scott at 2020-02-05T09:23:30-05:00 Add regression test for #17773 - - - - - e8004e5d by Ben Gamari at 2020-02-05T13:55:19-05:00 gitlab-ci: Allow Windows builds to fail again Due to T7702 and the process issues described in #17777. - - - - - 29b72c00 by Ben Gamari at 2020-02-06T11:55:41-05:00 VarSet: Introduce nonDetFoldVarSet - - - - - c4e6b35d by Ben Gamari at 2020-02-06T11:55:41-05:00 Move closeOverKinds and friends to TyCoFVs - - - - - ed2f0e5c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Reform the free variable finders for types This patch delivers on (much of) #17509. * Introduces the shallow vs deep free variable distinction * Introduce TyCoRep.foldType, foldType :: Monoid a => TyCoFolder env a -> env -> Type -> a and use it in the free variable finders. * Substitution in TyCoSubst * ASSERTs are on for checkValidSubst * checkValidSubst uses shallowTyCoVarsOfTypes etc Quite a few things still to do * We could use foldType in lots of other places * We could use mapType for substitution. (Check that we get good code!) * Some (but not yet all) clients of substitution can now save time by using shallowTyCoVarsOfTypes * All calls to tyCoVarsOfTypes should be inspected; most of them should be shallow. Maybe. * Currently shallowTyCoVarsOfTypes still returns unification variables, but not CoVarHoles. Reason: we need to return unification variables in some of the calls in TcSimplify, eg when promoting. * We should do the same thing for tyCoFVsOfTypes, which is currently unchanged. * tyCoFVsOfTypes returns CoVarHoles, because of the use in TcSimplify.mkResidualConstraints. See Note [Emitting the residual implication in simplifyInfer] * #17509 talks about "relevant" variables too. - - - - - 01a1f4fb by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for noFreeVarsOfType - - - - - 0e59afd6 by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Simplify closeOverKinds - - - - - 9ca5c88e by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for coVarsOfType - - - - - 5541b87c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for exactTyCoVarsOfType This entailed * Adding a tcf_view field to TyCoFolder * Moving exactTyCoVarsOtType to TcType. It properly belongs there, since only the typechecker calls this function. But it also means that we can "see" and inline tcView. Metric Decrease: T14683 - - - - - 7c122851 by Simon Peyton Jones at 2020-02-06T11:56:02-05:00 Comments only - - - - - 588acb99 by Adam Sandberg Eriksson at 2020-02-08T10:15:38-05:00 slightly better named cost-centres for simple pattern bindings #17006 ``` main = do print $ g [1..100] a where g xs x = map (`mod` x) xs a :: Int = 324 ``` The above program previously attributed the cost of computing 324 to a cost centre named `(...)`, with this change the cost is attributed to `a` instead. This change only affects simple pattern bindings (decorated variables: type signatures, parens, ~ annotations and ! annotations). - - - - - 309f8cfd by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Remove unnecessary parentheses - - - - - 7755ffc2 by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Introduce IsPass; refactor wrappers. There are two main payloads of this patch: 1. This introduces IsPass, which allows e.g. printing code to ask what pass it is running in (Renamed vs Typechecked) and thus print extension fields. See Note [IsPass] in Hs.Extension 2. This moves the HsWrap constructor into an extension field, where it rightly belongs. This is done for HsExpr and HsCmd, but not for HsPat, which is left as an exercise for the reader. There is also some refactoring around SyntaxExprs, but this is really just incidental. This patch subsumes !1721 (sorry @chreekat). Along the way, there is a bit of refactoring in GHC.Hs.Extension, including the removal of NameOrRdrName in favor of NoGhcTc. This meant that we had no real need for GHC.Hs.PlaceHolder, so I got rid of it. Updates haddock submodule. ------------------------- Metric Decrease: haddock.compiler ------------------------- - - - - - 7d452be4 by Dylan Yudaken at 2020-02-08T10:17:17-05:00 Fix hs_try_putmvar losing track of running cap If hs_try_putmvar was called through an unsafe import, it would lose track of the running cap causing a deadlock - - - - - c2e301ae by Ben Gamari at 2020-02-08T10:17:55-05:00 compiler: Qualify imports of Data.List - - - - - aede171a by Ben Gamari at 2020-02-08T10:17:55-05:00 testsuite: Fix -Wcompat-unqualified-imports issues - - - - - 4435a8e0 by Ben Gamari at 2020-02-08T10:17:55-05:00 Introduce -Wcompat-unqualified-imports This implements the warning proposed in option (B) of the Data.List.singleton CLC [discussion][]. This warning, which is included in `-Wcompat` is intended to help users identify imports of modules that will change incompatibly in future GHC releases. This currently only includes `Data.List` due to the expected specialisation and addition of `Data.List.singleton`. Fixes #17244. [discussion]: https://groups.google.com/d/msg/haskell-core-libraries/q3zHLmzBa5E/PmlAs_kYAQAJ - - - - - 28b5349a by Ben Gamari at 2020-02-08T10:17:55-05:00 Bump stm and process submodules - - - - - 7d04b9f2 by Ben Gamari at 2020-02-08T10:18:31-05:00 hadrian: Allow override of Cabal configuration in hadrian.settings Fixes #17612 by adding a `cabal.configure.opts` key for `hadrian.settings`. - - - - - 88bf81aa by Andreas Klebinger at 2020-02-08T10:19:10-05:00 Optimize unpackCString# to allocate less. unpackCString# is a recursive function which for each iteration returns a Cons cell containing the current Char, and a thunk for unpacking the rest of the string. In this patch we change from storing addr + offset inside this thunk to storing only the addr, simply incrementing the address on each iteration. This saves one word of allocation per unpacked character. For a program like "main = print "<largishString>" this amounts to 2-3% fewer % in bytes allocated. I also removed the now redundant local unpack definitions. This removes one call per unpack operation. - - - - - bec76733 by Ben Gamari at 2020-02-08T10:19:57-05:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 545cf1e1 by Ben Gamari at 2020-02-08T10:20:37-05:00 hadrian: Depend upon libray dependencies when configuring packages This will hopefully fix #17631. - - - - - 047d3d75 by Ben Gamari at 2020-02-08T10:21:16-05:00 testsuite: Add test for #15316 This is the full testcase for T15316. - - - - - 768e5866 by Julien Debon at 2020-02-08T10:22:07-05:00 doc(Data.List): Add some examples to Data.List - - - - - 3900cb83 by Julien Debon at 2020-02-08T10:22:07-05:00 Apply suggestion to libraries/base/GHC/List.hs - - - - - bd666766 by Ben Gamari at 2020-02-08T10:22:45-05:00 users-guide: Clarify that bundled patsyns were introduced in GHC 8.0 Closes #17094. - - - - - 95741ea1 by Pepe Iborra at 2020-02-08T10:23:23-05:00 Update to hie-bios 0.3.2 style program cradle - - - - - fb5c1912 by Sylvain Henry at 2020-02-08T10:24:07-05:00 Remove redundant case This alternative is redundant and triggers no warning when building with 8.6.5 - - - - - 5d83d948 by Matthew Pickering at 2020-02-08T10:24:43-05:00 Add mkHieFileWithSource which doesn't read the source file from disk cc/ @pepeiborra - - - - - dfdae56d by Andreas Klebinger at 2020-02-08T10:25:20-05:00 Rename ghcAssert to stgAssert in hp2ps/Main.h. This fixes #17763 - - - - - 658f7ac6 by Ben Gamari at 2020-02-08T10:26:00-05:00 includes: Avoid using single-line comments in HsFFI.h While single-line comments are supported by C99, dtrace on SmartOS apparently doesn't support them yet. - - - - - c95920a6 by Ömer Sinan Ağacan at 2020-02-08T10:26:42-05:00 Import qualified Prelude in parser This is in preparation of backwards-incompatible changes in happy. See https://github.com/simonmar/happy/issues/166 - - - - - b6dc319a by Ömer Sinan Ağacan at 2020-02-08T10:27:23-05:00 Add regression test for #12760 The bug seems to be fixed in the meantime, make sure it stays fixed. Closes #12760 - - - - - b3857b62 by Ben Gamari at 2020-02-08T10:28:03-05:00 base: Drop out-of-date comment The comment in GHC.Base claimed that ($) couldn't be used in that module as it was wired-in. However, this is no longer true; ($) is merely known key and is defined in Haskell (with a RuntimeRep-polymorphic type) in GHC.Base. The one piece of magic that ($) retains is that it a special typing rule to allow type inference with higher-rank types (e.g. `runST $ blah`; see Note [Typing rule for ($)] in TcExpr). - - - - - 1183ae94 by Daniel Gröber at 2020-02-08T10:29:00-05:00 rts: Fix Arena blocks accounting for MBlock sized allocations When requesting more than BLOCKS_PER_MBLOCK blocks allocGroup can return a different number of blocks than requested. Here we use the number of requested blocks, however arenaFree will subtract the actual number of blocks we got from arena_blocks (possibly) resulting in a negative value and triggering ASSERT(arena_blocks >= 0). - - - - - 97d59db5 by Daniel Gröber at 2020-02-08T10:29:48-05:00 rts: Fix need_prealloc being reset when retainer profiling is on - - - - - 1f630025 by Krzysztof Gogolewski at 2020-02-09T02:52:27-05:00 Add a test for #15712 - - - - - 2ac784ab by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Add --test-metrics argument Allowing the test metric output to be captured to a file, a la the METRIC_FILE environment variable of the make build system. - - - - - f432d8c6 by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Fix --test-summary argument This appears to be a cut-and-paste error. - - - - - a906595f by Arnaud Spiwack at 2020-02-09T02:53:50-05:00 Fix an outdated note link This link appears to have been forgotten in 0dad81ca5fd1f63bf8a3b6ad09787559e8bd05c0 . - - - - - 3ae83da1 by Alp Mestanogullari at 2020-02-09T02:54:28-05:00 hadrian: Windows fixes (bindists, CI) This commit implements a few Windows-specific fixes which get us from a CI job that can't even get as far as starting the testsuite driver, to a state where we can run the entire testssuite (but have test failures to fix). - Don't forget about a potential extension for the haddock program, when preparing the bindist. - Build the timeout program, used by the testsuite driver on Windows in place of the Python script used elsewhere, using the boot compiler. We could alternatively build it with the compiler that we're going to test but this would be a lot more tedious to write. - Implement a wrapper-script less installation procedure for Windows, in `hadrian/bindist/Makefile. - Make dependencies a bit more accurate in the aforementioned Makefile. - Update Windows/Hadrian CI job accordingly. This patch fixes #17486. - - - - - 82f9be8c by Roland Senn at 2020-02-09T02:55:06-05:00 Fix #14628: Panic (No skolem Info) in GHCi This patch implements the [sugggestion from Simon (PJ)](https://gitlab.haskell.org/ghc/ghc/issues/14628#note_146559): - Make `TcErrors.getSkolemInfo` return a `SkolemInfo` rather than an `Implication`. - If `getSkolemInfo` gets `RuntimeUnk`s, just return a new data constructor in `SkolemInfo`, called `RuntimeUnkSkol`. - In `TcErrors.pprSkols` print something sensible for a `RuntimeUnkSkol`. The `getSkolemInfo` function paniced while formating suggestions to add type annotations (subfunction `suggestAddSig`) to a *"Couldn't match type ‘x’ with ‘y’"* error message. The `getSkolemInfo` function didn't find any Implication value and paniced. With this patch the `getSkolemInfo` function does no longer panic, if it finds `RuntimeUnkSkol`s. As the panic occured while processing an error message, we don't need to implement any new error message! - - - - - b2e18e26 by Andreas Klebinger at 2020-02-09T02:55:46-05:00 Fix -ddump-stg-final. Once again make sure this dumps the STG used for codegen. - - - - - 414e2f62 by Sylvain Henry at 2020-02-09T02:56:26-05:00 Force -fPIC for intree GMP (fix #17799) Configure intree GMP with `--with-pic` instead of patching it. Moreover the correct patching was only done for x86_64/darwin (see #17799). - - - - - f0fd72ee by Sebastian Graf at 2020-02-09T17:22:38-05:00 8.10 Release notes for improvements to the pattern-match checker [skip ci] A little late to the game, but better late than never. - - - - - 00dc0f7e by Ömer Sinan Ağacan at 2020-02-09T17:23:17-05:00 Add regression test for #13142 Closes #13142 - - - - - f3e737bb by Sebastian Graf at 2020-02-10T20:04:09-05:00 Fix long distance info for record updates For record updates where the `record_expr` is a variable, as in #17783: ```hs data PartialRec = No | Yes { a :: Int, b :: Bool } update No = No update r@(Yes {}) = r { b = False } ``` We should make use of long distance info in `-Wincomplete-record-updates` checking. But the call to `matchWrapper` in the `RecUpd` case didn't specify a scrutinee expression, which would correspond to the `record_expr` `r` here. That is fixed now. Fixes #17783. - - - - - 5670881d by Tamar Christina at 2020-02-10T20:05:04-05:00 Fs: Fix UNC remapping code. - - - - - 375b3c45 by Oleg Grenrus at 2020-02-11T05:07:30-05:00 Add singleton to Data.OldList - - - - - de32beff by Richard Eisenberg at 2020-02-11T05:08:10-05:00 Do not create nested quantified constraints Previously, we would accidentally make constraints like forall a. C a => forall b. D b => E a b c as we traversed superclasses. No longer! This patch also expands Note [Eagerly expand given superclasses] to work over quantified constraints; necessary for T16502b. Close #17202 and #16502. test cases: typecheck/should_compile/T{17202,16502{,b}} - - - - - e319570e by Ben Gamari at 2020-02-11T05:08:47-05:00 rts: Use nanosleep instead of usleep usleep was removed in POSIX.1-2008. - - - - - b75e7486 by Ben Gamari at 2020-02-11T05:09:24-05:00 rts: Remove incorrect assertions around MSG_THROWTO messages Previously we would assert that threads which are sending a `MSG_THROWTO` message must have their blocking status be blocked on the message. In the usual case of a thread throwing to another thread this is guaranteed by `stg_killThreadzh`. However, `throwToSelf`, used by the GC to kill threads which ran out of heap, failed to guarantee this. Noted while debugging #17785. - - - - - aba51b65 by Sylvain Henry at 2020-02-11T05:10:04-05:00 Add arithmetic exception primops (#14664) - - - - - b157399f by Ben Gamari at 2020-02-11T05:10:40-05:00 configure: Don't assume Gnu linker on Solaris Compl Yue noticed that the linker was dumping the link map on SmartOS. This is because Smartos uses the Solaris linker, which uses the `-64` flag, not `-m64` like Gnu ld, to indicate that it should link for 64-bits. Fix the configure script to handle the Solaris linker correctly. - - - - - d8d73d77 by Simon Peyton Jones at 2020-02-11T05:11:18-05:00 Notes only: telescopes This documentation-only patch fixes #17793 - - - - - 58a4ddef by Alp Mestanogullari at 2020-02-11T05:12:17-05:00 hadrian: build (and ship) iserv on Windows - - - - - 82023524 by Matthew Pickering at 2020-02-11T18:04:17-05:00 TemplateHaskellQuotes: Allow nested splices There is no issue with nested splices as they do not require any compile time code execution. All execution is delayed until the top-level splice. - - - - - 50e24edd by Ömer Sinan Ağacan at 2020-02-11T18:04:57-05:00 Remove Hadrian's copy of (Data.Functor.<&>) The function was added to base with base-4.11 (GHC 8.4) - - - - - f82a2f90 by Sylvain Henry at 2020-02-12T01:56:46-05:00 Document GMP build [skip ci] - - - - - da7f7479 by Sylvain Henry at 2020-02-12T01:57:27-05:00 Module hierarchy: ByteCode and Runtime (cf #13009) Update haddock submodule - - - - - 04f51297 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Fix naming of tests for #12923 - - - - - 31fc3321 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Add regression test for #12926 Closes #12926 - - - - - f0c0ee7d by Krzysztof Gogolewski at 2020-02-12T01:58:51-05:00 Fix order of arguments in specializer (#17801) See https://gitlab.haskell.org/ghc/ghc/issues/17801#note_253330 No regression test, as it's hard to trigger. - - - - - 059c3c9d by Sebastian Graf at 2020-02-12T11:00:58+01:00 Separate CPR analysis from the Demand analyser The reasons for that can be found in the wiki: https://gitlab.haskell.org/ghc/ghc/wikis/nested-cpr/split-off-cpr We now run CPR after demand analysis (except for after the final demand analysis run just before code gen). CPR got its own dump flags (`-ddump-cpr-anal`, `-ddump-cpr-signatures`), but not its own flag to activate/deactivate. It will run with `-fstrictness`/`-fworker-wrapper`. As explained on the wiki page, this step is necessary for a sane Nested CPR analysis. And it has quite positive impact on compiler performance: Metric Decrease: T9233 T9675 T9961 T15263 - - - - - f5ffd8d9 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Expose GHC.Unicode.unicodeVersion This exposes a Data.Version.Version representing the version of the Unicode database used by `base`. This should clear up some confusion I have seen in tickets regarding with which Unicode versions a given GHC can be expected to work. While in town I also regenerated (but did not update) the Unicode database with database 12.0.0. Strangely, the file cited in the README no longer existed. Consequently, I used https://www.unicode.org/Public/12.0.0/ucd/UnicodeData.txt and was slightly surprised to find that there were a few changes. - - - - - 6c2585e0 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Update Unicode database to 12.1.0 Using `curl https://www.unicode.org/Public/12.1.0/ucd/UnicodeData.txt | libraries/base/cbits/ubconfc 12.1.0`. - - - - - df084681 by Krzysztof Gogolewski at 2020-02-12T23:58:52+01:00 Always display inferred variables using braces We now always show "forall {a}. T" for inferred variables, previously this was controlled by -fprint-explicit-foralls. This implements part 1 of https://github.com/ghc-proposals/ghc-proposals/pull/179. Part of GHC ticket #16320. Furthermore, when printing a levity restriction error, we now display the HsWrap of the expression. This lets users see the full elaboration with -fprint-typechecker-elaboration (see also #17670) - - - - - 16d643cf by Sylvain Henry at 2020-02-13T09:16:04-05:00 Remove -ddump-srts flag This flag is deemed not useful. - - - - - fa28ae95 by Sylvain Henry at 2020-02-13T09:16:04-05:00 Fix flag documentation (#17826) - - - - - 1bfd8259 by Sylvain Henry at 2020-02-13T09:16:43-05:00 Ensure that Hadrian is built correctly before using it When Hadrian failed to build, the script would pick a previously built Hadrian (if available) instead of failing. - - - - - cd6e786a by Ömer Sinan Ağacan at 2020-02-14T05:29:56-05:00 Add test for #17648 - - - - - 9f2c3677 by Sylvain Henry at 2020-02-14T05:30:39-05:00 GMP expects the Target platform as --host parameter - - - - - aa6086fd by Oleg Grenrus at 2020-02-14T05:31:16-05:00 Add explicit LANGUAGE Safe to template-haskell (cherry picked from commit a5e0f376821ca882880b03b07b451aa574e289ec) - - - - - af6a0c36 by Ben Gamari at 2020-02-14T05:31:53-05:00 hadrian: Add execution and target architecture to stage-compilation figure - - - - - cf739945 by Sylvain Henry at 2020-02-14T05:32:37-05:00 Module hierarchy: HsToCore (cf #13009) - - - - - 719db318 by Simon Peyton Jones at 2020-02-14T05:33:16-05:00 De-duplicate overlapping Notes Documentation only. Fixes #17827 - - - - - 7550417a by Sylvain Henry at 2020-02-14T05:33:56-05:00 Hadrian: drop Sphinx flag checking for PDF documentation (#17825) It seems that Sphinx produces the ghc-flags.txt in doc/users_guide/_build rather than pdfRoot. We could copy ghc-flags.txt into pdfRoot (like happens naturally in the HTML case) but the benefit is pretty small. Let's just only check the HTML case. - - - - - 813842f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 make: Be more selective in building windows-extra-src tarball - - - - - 0725f4bb by Ben Gamari at 2020-02-14T10:16:36-05:00 Rework handling of win32 toolchain tarballs - - - - - 565ce7ae by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Consolidate CI logic This moves nearly all of the CI logic to .gitlab/ci.sh. This improves things in a number of ways: * it's harder for inconsistencies to arise between architectures * it's easier to share logic between architectures * on Windows, it's easier to ensure that all CI steps are executed from within a properly initialized mingw session. While in town I also add a FreeBSD build job and update the Windows job to use the gitlab-runner PowerShell executor, since cmd.exe will be deprecated soon (fixing #17699). - - - - - 9cbace74 by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Deduplicate nightly job configuration - - - - - 6e837144 by Ben Gamari at 2020-02-14T10:16:36-05:00 integer-gmp: Fix unused command-line argument -L is only needed during linking. - - - - - e5ee07ab by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Don't ask sed to operate in-place on symlinks Some sed implementations (e.g. FreeBSD) refuse to operate in-place on symlinks. - - - - - 71e5e68f by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Disable tests that assume name of libstdc++ on FreeBSD - - - - - 7b2da0f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Mark T6132 as broken on FreeBSD - - - - - 8ef7a15a by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite/T16930: Don't rely on gnu grep specific --include In BSD grep this flag only affects directory recursion. - - - - - 6060003e by Ben Gamari at 2020-02-14T10:16:36-05:00 Pass -Wno-unused-command-line-arguments during link on FreeBSD FreeBSD cc throws a warning if we pass -pthread without actually using any pthread symbols. - - - - - 97497bae by Ben Gamari at 2020-02-14T10:16:36-05:00 base: Always clamp reads/writes to 2GB in length Previously we did this only on Darwin due to #17414. However, even on other platforms >2GB writes are on shaky ground. POSIX explicitly says that the result is implementation-specified and Linux will write at most 0x7ffff000, even on 64-bit platforms. Moreover, getting the sign of the syscall result correct is tricky, as demonstrated by the fact that T17414 currently fails on FreeBSD. For simplicity we now just uniformly clamp to 0x7ffff000 on all platforms. - - - - - 49be2a3f by Ben Gamari at 2020-02-14T10:16:36-05:00 configure: Fix sphinx version test The check for the "v" prefix is redundant. - - - - - f7f7a556 by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix unknown link targets - - - - - a204102c by Ben Gamari at 2020-02-14T10:16:37-05:00 docs/compare-flags: Don't use python f-strings - - - - - 92e15a37 by Ben Gamari at 2020-02-14T10:16:37-05:00 gitlab-ci: Fix various shellcheck warnings - - - - - 459f7c6e by Ben Gamari at 2020-02-14T10:16:37-05:00 hadrian: Drop empty arguments from target list Fixes #17748. - - - - - c06df28d by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix "invalid file" failure I have no idea how this worked previously. Different Python version? - - - - - 3fe8444f by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Mark T7702 as fragile on Windows Due to #16799. There was previously an attempt to mark it as broken but the `opsys` name was incorrect. - - - - - fe02f781 by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Assert the opsys names are known Previously opsys would take any string. This meant it was very easy for a typo to silently render the predicate ineffective. Fix this by checking the given operating system name against a list of known values. - - - - - 149e2a3a by Ben Gamari at 2020-02-14T10:16:59-05:00 compare-flags: Don't rely on encoding flag of subprocess.check_output Apparently it isn't supported by some slightly older Python versions. - - - - - 798d59f6 by Ben Gamari at 2020-02-14T10:16:59-05:00 rts: Add more debug output to failed path in onIOComplete This will help track down #17035. - - - - - e35f3f98 by Ben Gamari at 2020-02-14T10:16:59-05:00 gitlab-ci: Allow i386 Windows builds to fail again Due to the resistance of #17736 to resolution. - - - - - 261a3cf8 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Build integer-simple job in the validate flavour - - - - - b613a961 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Always use mingw64 python on Windows - - - - - 1bc8c8cd by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Allow Windows build to fail due to #17777 The fact that `exec` isn't POSIX compliant means that things can break in arbitrarily bad ways. Sometimes things happen to work correctly but sadly this isn't always the case. - - - - - ac63020d by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Drop unnecessary GHC_VERSION check - - - - - 6926f369 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump process submodule Folds in the second part of Phyx's Windows process exit fixes [1], hopefully finally resolving issue #17480. [1] https://github.com/haskell/process/pull/160 - - - - - 584eee71 by Tamar Christina at 2020-02-14T10:17:00-05:00 SysTools: Use "process job" when spawning processes on Windows GHC should make calls using process jobs when calling out to GCC and LD. The reason is these use the exec () family of posix functions. Window's process model doesn't allow replacement of processes so this is emulated by creating a new process and immediately exiting the old one. Because of this when using normal Windows wait functions you would return even without the child process having finished. In this case if you are depending on data from the child you will enter a race condition. The usual fix for this is to use process jobs and wait for the termination of all children that have ever been spawn by the process you called. But also waiting for the freeing of all resources. - - - - - ecabfa28 by Tamar Christina at 2020-02-14T10:17:00-05:00 Revert "compiler: Disable atomic renaming on Windows" The original reason this was disabled should be fixed by the previous commit. This reverts commit 1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb. - - - - - 06d60c66 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump Cabal submodule - - - - - 8cabb384 by Ben Gamari at 2020-02-14T10:17:00-05:00 compare-flags: Fix output - - - - - 8cf646d3 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Document -ddump-srts - - - - - 932307a5 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Fix broken reference - - - - - e77818de by Ben Gamari at 2020-02-15T09:26:55-05:00 Accept performance changes These manifested in the integer-simple job. Metric Decrease: T12227 T5549 T14936 T4830 Conversions T5237 T8766 T4801 T10359 Metric Increase: T12234 T6048 T3294 T14683 T3064 T9872b T9872c T783 T5837 T10678 T14697 T5631 T9203 T13719 T12707 T13056 T9630 T10547 T9872d T1969 WWRec T10370 T5321FD haddock.Cabal T5642 T9872a T15263 T12425 MultiLayerModules T5205 T9233 T13379 haddock.base T9020 T13035 T12150 T9961 - - - - - 785008c1 by Ben Gamari at 2020-02-15T09:30:13-05:00 testsuite: Sort test names in expected change output - - - - - 9e851472 by Ömer Sinan Ağacan at 2020-02-16T10:38:41+03:00 Revert "users-guide: Document -ddump-srts" This reverts commit 8cf646d36b02b8ea1c289cb52781c9171853b514. The flag was removed by 16d643cf. [ci skip] - - - - - 9792c816 by Ben Gamari at 2020-02-16T09:47:08-05:00 testsuite: Probe whether symlinks are usable on Windows Closes #17706. - - - - - ee1e5342 by Vladislav Zavialov at 2020-02-16T09:47:44-05:00 Fix the "unused terminals: 2" warning in Parser.y - - - - - b4a8ce52 by Roland Senn at 2020-02-18T20:14:42-05:00 If a :reload finds syntax errors in the module graph, remove the loaded modules. (Fixes #17549) The processing in `compiler/main/GhcMake.hs` computes the ModuleGraph. If it finds errors in the module header or in the import specifications, then the new module graph is incomplete and should not be used. The code before #17549 just reported the errors and left the old ModuleGraph in place. The new code of this MR replaces the old ModuleGraph with an empty one. - - - - - d7029cc0 by Sylvain Henry at 2020-02-18T20:15:30-05:00 Hadrian: refactor GMP in-tree build support (#17756) * Hadrian doesn't use integer-gmp/config.mk file anymore to determine if building GMP in-tree is required. "config.mk" is created by Cabal when the integer-gmp package is configured and this file is still untracked by Hadrian. This led to a tricky configure "race" because "config.mk" is built by the "setup-config" rule, but this rule is also used to find dependencies, in particular the "ghc-gmp.h" header, but the creation of this file was depending (without being tracked) on "config.mk". Now Hadrian only builds in-tree GMP if `--with-intree-gmp` is passed to the top-level configure script. * in-tree GMP isn't built once for all in a fixed stage (Stage1) anymore. It is built per stage which is required if we build a cross-compiler * switching between in-tree and external GMP is now supported without having to clean the build directory first. * "wrappers.c" now includes "ghc-gmp.h" instead of "ghc.h". It helps ensuring that the build system generates "ghc-gmp.h". * build in-tree GMP in "<root>/stageN/gmp/gmpbuild" and produce useful artefacts (libgmp.a, gmp.h, objs/*.o) in "<root>/stageN/gmp" - - - - - 40d917fb by Vladislav Zavialov at 2020-02-18T20:16:07-05:00 Remove the MonadFail P instance There were two issues with this instance: * its existence meant that a pattern match failure in the P monad would produce a user-visible parse error, but the error message would not be helpful to the user * due to the MFP migration strategy, we had to use CPP in Lexer.x, and that created issues for #17750 Updates haddock submodule. - - - - - 5a1ce45d by Joshua Price at 2020-02-18T20:16:47-05:00 Fix unboxed tuple size limit (#17837) - - - - - 192caf58 by Vladislav Zavialov at 2020-02-18T20:17:24-05:00 Fix testsuite driver output (#17847) - - - - - 1500f089 by Sylvain Henry at 2020-02-18T20:18:12-05:00 Modules: Llvm (#13009) - - - - - d53e81c0 by Niklas Hambüchen at 2020-02-20T10:36:22-05:00 8.10 Release notes for atomic .o writes [skip ci] - - - - - 19680ee5 by Niklas Hambüchen at 2020-02-20T10:37:53-05:00 8.10 Release notes for --disable-delayed-os-memory-return [skip ci] - - - - - 74ad75e8 by Simon Peyton Jones at 2020-02-20T21:17:57-05:00 Re-implement unsafe coercions in terms of unsafe equality proofs (Commit message written by Omer, most of the code is written by Simon and Richard) See Note [Implementing unsafeCoerce] for how unsafe equality proofs and the new unsafeCoerce# are implemented. New notes added: - [Checking for levity polymorphism] in CoreLint.hs - [Implementing unsafeCoerce] in base/Unsafe/Coerce.hs - [Patching magic definitions] in Desugar.hs - [Wiring in unsafeCoerce#] in Desugar.hs Only breaking change in this patch is unsafeCoerce# is not exported from GHC.Exts, instead of GHC.Prim. Fixes #17443 Fixes #16893 NoFib ----- -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.1% 0.0% -0.0% -0.0% -0.0% CSD -0.1% 0.0% -0.0% -0.0% -0.0% FS -0.1% 0.0% -0.0% -0.0% -0.0% S -0.1% 0.0% -0.0% -0.0% -0.0% VS -0.1% 0.0% -0.0% -0.0% -0.0% VSD -0.1% 0.0% -0.0% -0.0% -0.1% VSM -0.1% 0.0% -0.0% -0.0% -0.0% anna -0.0% 0.0% -0.0% -0.0% -0.0% ansi -0.1% 0.0% -0.0% -0.0% -0.0% atom -0.1% 0.0% -0.0% -0.0% -0.0% awards -0.1% 0.0% -0.0% -0.0% -0.0% banner -0.1% 0.0% -0.0% -0.0% -0.0% bernouilli -0.1% 0.0% -0.0% -0.0% -0.0% binary-trees -0.1% 0.0% -0.0% -0.0% -0.0% boyer -0.1% 0.0% -0.0% -0.0% -0.0% boyer2 -0.1% 0.0% -0.0% -0.0% -0.0% bspt -0.1% 0.0% -0.0% -0.0% -0.0% cacheprof -0.1% 0.0% -0.0% -0.0% -0.0% calendar -0.1% 0.0% -0.0% -0.0% -0.0% cichelli -0.1% 0.0% -0.0% -0.0% -0.0% circsim -0.1% 0.0% -0.0% -0.0% -0.0% clausify -0.1% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.1% 0.0% -0.0% -0.0% -0.0% compress -0.1% 0.0% -0.0% -0.0% -0.0% compress2 -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.1% 0.0% -0.0% -0.0% -0.0% cse -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.1% 0.0% -0.0% -0.0% -0.0% dom-lt -0.1% 0.0% -0.0% -0.0% -0.0% eliza -0.1% 0.0% -0.0% -0.0% -0.0% event -0.1% 0.0% -0.0% -0.0% -0.0% exact-reals -0.1% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.1% 0.0% -0.0% -0.0% -0.0% expert -0.1% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.1% 0.0% -0.0% -0.0% -0.0% fasta -0.1% 0.0% -0.5% -0.3% -0.4% fem -0.1% 0.0% -0.0% -0.0% -0.0% fft -0.1% 0.0% -0.0% -0.0% -0.0% fft2 -0.1% 0.0% -0.0% -0.0% -0.0% fibheaps -0.1% 0.0% -0.0% -0.0% -0.0% fish -0.1% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.1% 0.0% +0.0% +0.0% +0.0% gamteb -0.1% 0.0% -0.0% -0.0% -0.0% gcd -0.1% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.1% 0.0% -0.0% -0.0% -0.0% genfft -0.1% 0.0% -0.0% -0.0% -0.0% gg -0.1% 0.0% -0.0% -0.0% -0.0% grep -0.1% 0.0% -0.0% -0.0% -0.0% hidden -0.1% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.1% 0.0% -0.0% -0.0% -0.0% infer -0.1% 0.0% -0.0% -0.0% -0.0% integer -0.1% 0.0% -0.0% -0.0% -0.0% integrate -0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.1% 0.0% -0.0% -0.0% -0.0% kahan -0.1% 0.0% -0.0% -0.0% -0.0% knights -0.1% 0.0% -0.0% -0.0% -0.0% lambda -0.1% 0.0% -0.0% -0.0% -0.0% last-piece -0.1% 0.0% -0.0% -0.0% -0.0% lcss -0.1% 0.0% -0.0% -0.0% -0.0% life -0.1% 0.0% -0.0% -0.0% -0.0% lift -0.1% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.1% 0.0% -0.0% -0.0% -0.0% listcopy -0.1% 0.0% -0.0% -0.0% -0.0% maillist -0.1% 0.0% -0.0% -0.0% -0.0% mandel -0.1% 0.0% -0.0% -0.0% -0.0% mandel2 -0.1% 0.0% -0.0% -0.0% -0.0% mate -0.1% 0.0% -0.0% -0.0% -0.0% minimax -0.1% 0.0% -0.0% -0.0% -0.0% mkhprog -0.1% 0.0% -0.0% -0.0% -0.0% multiplier -0.1% 0.0% -0.0% -0.0% -0.0% n-body -0.1% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.1% 0.0% -0.0% -0.0% -0.0% para -0.1% 0.0% -0.0% -0.0% -0.0% paraffins -0.1% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.1% 0.0% -0.0% -0.0% -0.0% pidigits -0.1% 0.0% -0.0% -0.0% -0.0% power -0.1% 0.0% -0.0% -0.0% -0.0% pretty -0.1% 0.0% -0.1% -0.1% -0.1% primes -0.1% 0.0% -0.0% -0.0% -0.0% primetest -0.1% 0.0% -0.0% -0.0% -0.0% prolog -0.1% 0.0% -0.0% -0.0% -0.0% puzzle -0.1% 0.0% -0.0% -0.0% -0.0% queens -0.1% 0.0% -0.0% -0.0% -0.0% reptile -0.1% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.1% 0.0% -0.0% -0.0% -0.0% rewrite -0.1% 0.0% -0.0% -0.0% -0.0% rfib -0.1% 0.0% -0.0% -0.0% -0.0% rsa -0.1% 0.0% -0.0% -0.0% -0.0% scc -0.1% 0.0% -0.1% -0.1% -0.1% sched -0.1% 0.0% -0.0% -0.0% -0.0% scs -0.1% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.1% 0.0% -0.0% -0.0% -0.0% sorting -0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.1% 0.0% -0.0% -0.0% -0.0% sphere -0.1% 0.0% -0.0% -0.0% -0.0% symalg -0.1% 0.0% -0.0% -0.0% -0.0% tak -0.1% 0.0% -0.0% -0.0% -0.0% transform -0.1% 0.0% -0.0% -0.0% -0.0% treejoin -0.1% 0.0% -0.0% -0.0% -0.0% typecheck -0.1% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.1% 0.0% -0.0% -0.0% -0.0% wave4main -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.1% 0.0% -0.0% -0.0% -0.0% x2n1 -0.1% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.5% -0.3% -0.4% Max -0.0% 0.0% +0.0% +0.0% +0.0% Geometric Mean -0.1% -0.0% -0.0% -0.0% -0.0% Test changes ------------ - break006 is marked as broken, see #17833 - The compiler allocates less when building T14683 (an unsafeCoerce#- heavy happy-generated code) on 64-platforms. Allocates more on 32-bit platforms. - Rest of the increases are tiny amounts (still enough to pass the threshold) in micro-benchmarks. I briefly looked at each one in a profiling build: most of the increased allocations seem to be because of random changes in the generated code. Metric Decrease: T14683 Metric Increase: T12150 T12234 T12425 T13035 T14683 T5837 T6048 Co-Authored-By: Richard Eisenberg <rae at cs.brynmawr.edu> Co-Authored-By: Ömer Sinan Ağacan <omeragacan at gmail.com> - - - - - 6880d6aa by Sylvain Henry at 2020-02-20T21:18:48-05:00 Disentangle DynFlags and SDoc Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly CodeGen related (e.g. depend on target platform constants) and will be fixed separately. Metric Decrease: T12425 T9961 WWRec T1969 T14683 - - - - - 70a90110 by Julien Debon at 2020-02-20T21:19:27-05:00 doc(List): Add examples to GHC.List * Add examples * Cleanup documentation * Clarify merge process and Marge bot - - - - - c8439fc7 by Peter Trommler at 2020-02-20T21:20:05-05:00 Fix testsuite on powerpc64le Remove expect broken on recomp tests, #11260 was closed by !2264 and #11323 most likely by !2264 as well. GHCi scripts tests work on GHCi but not the external interpreter, adjust test configuration accordingly. Fixes unexpected passes. Mark test requiring DWARF expect fail on powerpc64[le] for #11261. - - - - - 65b7256a by Ömer Sinan Ağacan at 2020-02-20T21:20:45-05:00 Use concatMap(M) instead of `concat . map` and the monadic variant - - - - - 8b76d457 by Roland Senn at 2020-02-20T21:21:28-05:00 Fix #17832: Weird handling of exports named main in 8.10-rc1 Switching from `lookupGlobalOccRn_maybe` to `lookupInfoOccRn` to check whether a `main` function is in scope. Unfortunately `lookupGlobalOccRn_maybe` complains if there are multiple `main` functions in scope. - - - - - 466e1ad5 by Krzysztof Gogolewski at 2020-02-20T21:22:11-05:00 Use TTG for HsSplicedT constructor The constructor HsSplicedT occurs only in the GhcTc pass. This enforces this fact statically via TTG. - - - - - 4e622fca by Alexis King at 2020-02-20T21:22:49-05:00 Normalize types when dropping absent arguments from workers fixes #17852 - - - - - a533e547 by Adam Sandberg Eriksson at 2020-02-20T21:23:31-05:00 Mention users guide and release notes in merge request template - - - - - 05251b17 by Ben Gamari at 2020-02-20T21:24:08-05:00 gitlab-ci: Fix typo in BIN_DIST_PREP_TAR_COMP variable name - - - - - f44c7e67 by Ben Gamari at 2020-02-20T21:24:46-05:00 gitlab-ci: Avoid duplicating ~/.cabal contents with every build Previously our attempt to cache the cabal store would `cp cabal-cache ~/.cabal`. However, if the latter already existed this meant that we would end up with ~/.cabal/cabal-cache. Not only would this not help caching but it would exponentially grow the size of ~/.cabal. Not good! - - - - - c5ec9965 by Ben Gamari at 2020-02-20T21:56:13-05:00 GHC.Hs.Extension: Use Type instead of * - - - - - 89cb4cc4 by Ben Gamari at 2020-02-20T21:56:13-05:00 Use Type instead of * in GHC - - - - - 04eb0d6c by Ben Gamari at 2020-02-20T21:56:13-05:00 Enable -Wstar-is-type in -Wall As noted in [proposal 0143][proposal] this is supposed to happen in 8.12. Also fix an incorrect claim in the users guide that -Wstar-is-type is enabled by default. [proposal]: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0143-remove-star-kind.rst - - - - - 6de966f1 by Andreas Klebinger at 2020-02-20T21:56:15-05:00 Fix #17724 by having occAnal preserve used bindings. It sometimes happened that occAnal would remove bindings as dead code by relying on bindings to be in dependency order. The fix was contributed by SPJ. - - - - - abd7f962 by Ben Gamari at 2020-02-20T21:56:15-05:00 users-guide: Mention dependency on `exceptions` in release notes Fixes #17845. - - - - - 58175379 by Sylvain Henry at 2020-02-20T21:56:20-05:00 Hadrian: minor GMP refactoring Somehow I forgot to totally remove `gmpContext` in d7029cc09edc052c2f97effe33233c53340fcce0. This patch fixes it and adds some additional comments. - - - - - 33fa8d94 by Ryan Scott at 2020-02-20T21:56:21-05:00 Generalize liftData to work over any Quote (#17857) The Overloaded Quotations proposal generalized the type of `lift` to work over any `Quote`, but not the type of `liftData`, leading to #17857. Thankfully, generalizing `liftData` is extremely straightforward. Fixes #17857. - - - - - 3cea6795 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Make: fix sdist target (#17848) - - - - - e2cce997 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Hadrian: fix source-dist target (#17849) - - - - - 0a4c89b2 by Matthew Pickering at 2020-02-21T20:44:45-05:00 Special case `mkTyConApp liftedTypeKind []` We really need to make sure that these are shared because otherwise GHC will allocate thousands of identical `TyConApp` nodes. See #17292 ------------------------- Metric Decrease: haddock.Cabal T14683 ------------------------- - - - - - 0482f58a by Matthew Pickering at 2020-02-21T20:45:21-05:00 TH: wrapGenSyns, don't split the element type too much The invariant which allowed the pervious method of splitting the type of the body to find the type of the elements didn't work in the new overloaded quotation world as the type can be something like `WriterT () m a` rather than `Q a` like before. Fixes #17839 - - - - - be7068a6 by Vladislav Zavialov at 2020-02-21T20:45:59-05:00 Parser API annotations: RealSrcLoc During parsing, GHC collects lexical information about AST nodes and stores it in a map. It is needed to faithfully restore original source code, e.g. compare these expressions: a = b a = b The position of the equality sign is not recorded in the AST, so it must be stored elsewhere. This system is described in Note [Api annotations]. Before this patch, the mapping was represented by: Map (SrcSpan, AnnKeywordId) SrcSpan After this patch, the mapping is represented by: Map (RealSrcSpan, AnnKeywordId) RealSrcSpan The motivation behind this change is to avoid using the Ord SrcSpan instance (required by Map here), as it interferes with #17632 (see the discussion there). SrcSpan is isomorphic to Either String RealSrcSpan, but we shouldn't use those strings as Map keys. Those strings are intended as hints to the user, e.g. "<interactive>" or "<compiler-generated code>", so they are not a valid way to identify nodes in the source code. - - - - - 240f5bf6 by Sylvain Henry at 2020-02-21T20:46:40-05:00 Modules: Driver (#13009) submodule updates: nofib, haddock - - - - - 9d094111 by Sylvain Henry at 2020-02-21T20:47:19-05:00 Hadrian: `docs` rule needs `configure` (#17840) - - - - - 1674353a by Ben Gamari at 2020-02-23T17:31:19-05:00 fs: Port fixes from ghc-jailbreak repository * Override rename, unlink, and remove * Factor out wchar conversion - - - - - 853210f2 by Adam Sandberg Ericsson at 2020-02-23T17:32:03-05:00 show gcc linker options in configure summary - - - - - 2831544a by Adam Sandberg Ericsson at 2020-02-23T17:32:44-05:00 hadrian: docs depend on stage1 ghc - - - - - 1d9df9e0 by Adam Sandberg Ericsson at 2020-02-23T17:33:23-05:00 ci: after 5ce63d52fed the linux bindist for doc-tarball has changed name - - - - - 26e8fff3 by Vladislav Zavialov at 2020-02-24T02:05:30-05:00 Remove Ord SrcLoc, Ord SrcSpan Before this patch, GHC relied on Ord SrcSpan to identify source elements, by using SrcSpan as Map keys: blackList :: Map SrcSpan () -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map SrcSpan Name -- compiler/GHC/HsToCore/Docs.hs Firstly, this design is not valid in presence of UnhelpfulSpan, as it distinguishes between UnhelpfulSpan "X" and UnhelpfulSpan "Y", but those strings are messages for the user, unfit to serve as identifiers for source elements. Secondly, this design made it hard to extend SrcSpan with additional data. Recall that the definition of SrcSpan is: data SrcSpan = RealSrcSpan !RealSrcSpan | UnhelpfulSpan !FastString Say we want to extend the RealSrcSpan constructor with additional information: data SrcSpan = RealSrcSpan !RealSrcSpan !AdditionalInformation | UnhelpfulSpan !FastString getAdditionalInformation :: SrcSpan -> AdditionalInformation getAdditionalInformation (RealSrcSpan _ a) = a Now, in order for Map SrcSpan to keep working correctly, we must *ignore* additional information when comparing SrcSpan values: instance Ord SrcSpan where compare (RealSrcSpan r1 _) (RealSrcSpan r2 _) = compare r1 r2 ... However, this would violate an important law: a == b therefore f a == f b Ignoring AdditionalInformation in comparisons would mean that with f=getAdditionalInformation, the law above does not hold. A more robust design is to avoid Ord SrcSpan altogether, which is what this patch implements. The mappings are changed to use RealSrcSpan instead: blackList :: Set RealSrcSpan -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map RealSrcSpan Name -- compiler/GHC/HsToCore/Docs.hs All SrcSpan comparisons are now done with explicit comparison strategies: SrcLoc.leftmost_smallest SrcLoc.leftmost_largest SrcLoc.rightmost_smallest These strategies are not subject to the law mentioned above and can easily discard both the string stored in UnhelpfulSpan and AdditionalInformation. Updates haddock submodule. - - - - - 5aa6c188 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Shuffle text - - - - - e3f17413 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Drop old release notes - - - - - 84dd9610 by Ben Gamari at 2020-02-24T02:06:09-05:00 Bump directory submodule to 1.3.6.0 - - - - - e295a024 by Stefan Pavikevik at 2020-02-24T20:53:44-05:00 check for safe arguments, raising error when invalid (fix #17720) - - - - - 354e2787 by Krzysztof Gogolewski at 2020-02-24T20:54:35-05:00 Comments, small refactor * Remove outdated Note [HsForAllTy tyvar binders] and [Context quantification]. Since the wildcard refactor 1e041b7382, HsForAllTy no longer has an flag controlling explicity. The field `hsq_implicit` is gone too. The current situation is covered by Note [HsType binders] which is already linked from LHsQTyVars. * Small refactor in CoreLint, extracting common code to a function * Remove "not so sure about WpFun" in TcEvidence, per Richard's comment https://gitlab.haskell.org/ghc/ghc/merge_requests/852#note_223226 * Use mkIfThenElse in Foreign/Call, as it does exactly what we need. - - - - - 1b1067d1 by Sylvain Henry at 2020-02-24T20:55:25-05:00 Modules: CmmToAsm (#13009) - - - - - 621468f6 by Alexis King at 2020-02-26T15:08:09-05:00 Treat coercions as arguments for floating and inlining This reverts commit 8924224ecfa065ebc67b96a90d01cf9d2edd0e77 and fixes #17787. - - - - - def486c9 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Allow libnuma library path to be specified - - - - - ed03d4e7 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Refactor gmp arguments Move the gmp configuration to its own binding. - - - - - 09b88384 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Tell Cabal about integer-gmp library location - - - - - 161e08c5 by Krzysztof Gogolewski at 2020-02-26T15:09:30-05:00 Remove dead code * FailablePattern can no longer be created since ab51bee40c82 Therefore, Opt_WarnMissingMonadFailInstances has no effect anymore. * XWrap is no longer used, it was moved to an extension field - - - - - e0d09db3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Use 8.8.3 to bootstrap on Windows This should fix #17861. - - - - - 972bcf3a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Fix symlink test Needs to `write` bytes, not str. - - - - - 273e60de by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add shell subcommand for debugging within CI environment - - - - - 43b13ed3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Fix colors on Darwin Darwin sh doesn't support \e. - - - - - 217546a7 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Flush stdout buffers in InitEventLogging Otherwise we are sensitive to libc's buffering strategy. Similar to the issue fixed in 543dfaab166c81f46ac4af76918ce32190aaab22. - - - - - c7d4fa55 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add run_hadrian subcommand I've ruined two trees already by failing to pass --flavour to hadrian. Let's factor this out so it can be reused during troubleshooting. - - - - - 7dc54873 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Allow tests to be marked as broken on the command line This allows us to work-around distribution-specific breakage easily. - - - - - 25e2458e by Ben Gamari at 2020-02-26T15:10:09-05:00 hadrian: Add --broken-test flag This exposes the flag of the same name supported by the testsuite driver. - - - - - 55769996 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Mark some tests as broken on Alpine - - - - - 9ee7f87d by Ben Gamari at 2020-02-26T15:10:09-05:00 SysTools: Don't use process jobs if they are broken - - - - - bfaa3961 by Ben Gamari at 2020-02-26T15:10:09-05:00 Bump hsc2hs submodule Fixes name of C compiler. - - - - - b2b49a0a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Make hasMetricsFile RHS more descriptive - - - - - 817f93ea by Sylvain Henry at 2020-02-26T15:10:58-05:00 Modules: Core (#13009) Update haddock submodule - - - - - 74311e10 by Sebastian Graf at 2020-02-27T16:22:45-05:00 PmCheck: Implement Long-distance information with Covered sets Consider ```hs data T = A | B | C f :: T -> Int f A = 1 f x = case x of A -> 2 B -> 3 C -> 4 ``` Clearly, the RHS returning 2 is redundant. But we don't currently see that, because our approximation to the covered set of the inner case expression just picks up the positive information from surrounding pattern matches. It lacks the context sensivity that `x` can't be `A` anymore! Therefore, we adopt the conceptually and practically superior approach of reusing the covered set of a particular GRHS from an outer pattern match. In this case, we begin checking the `case` expression with the covered set of `f`s second clause, which encodes the information that `x` can't be `A` anymore. After this MR, we will successfully warn about the RHS returning 2 being redundant. Perhaps surprisingly, this was a great simplification to the code of both the coverage checker and the desugarer. Found a redundant case alternative in `unix` submodule, so we have to bump it with a fix. Metric Decrease: T12227 - - - - - 59c023ba by Adam Sandberg Ericsson at 2020-02-27T16:23:25-05:00 configure: correctly generate LIBRARY_template_haskell_VERSION - - - - - 9be82389 by Krzysztof Gogolewski at 2020-02-28T02:35:35-05:00 boot: Remove remote origin check Previously, we used relative paths in submodules. When cloning from GitHub, they had to be manually tweaked. Since a76b233d we use absolute paths, so this workaround can be removed. - - - - - f4b6b594 by Ben Gamari at 2020-02-28T02:36:12-05:00 nonmoving: Fix marking in compact regions Previously we were tracing the object we were asked to mark, even if it lives in a compact region. However, there is no need to do this; we need only to mark the region itself as live. I have seen a segfault due to this due to the concurrent mark seeing a an object in the process of being compacted by the mutator. - - - - - f97d1fb6 by Alp Mestanogullari at 2020-02-28T02:36:59-05:00 base: use an explicit import list in System.Environment.ExecutablePath This was making -Werror builds fail on Windows (at least with Hadrian). - - - - - 66f5d6d6 by Simon Peyton Jones at 2020-02-28T22:03:23-05:00 Improve error handling for VTA + deferred type errors This fixes #17792 See Note [VTA for out-of-scope functions] in TcExpr - - - - - 37f12603 by Ilias Tsitsimpis at 2020-02-28T22:04:04-05:00 llvm-targets: Add arm-unknown-linux-gnueabi Add arm-unknown-linux-gnueabi, which is used by Debian's ARM EABI port (armel), as an LLVM target. - - - - - 327b29e1 by Vladislav Zavialov at 2020-02-29T05:06:31-05:00 Monotonic locations (#17632) When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the tool may insert #line pragmas to adjust the locations reported to the user. As the result, the locations recorded in RealSrcLoc are not monotonic. Elements that appear later in the StringBuffer are not guaranteed to have a higher line/column number. In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily modify locations. This lack of guarantees makes ideas such as #17544 infeasible. This patch adds an additional bit of information to every SrcLoc: newtype BufPos = BufPos { bufPos :: Int } A BufPos represents the location in the StringBuffer, unaffected by any pragmas. Updates haddock submodule. Metric Increase: haddock.Cabal haddock.base haddock.compiler MultiLayerModules Naperian parsing001 T12150 - - - - - 99d2de86 by Ben Gamari at 2020-02-29T05:07:10-05:00 plugins: Ensure that loadInterface plugins can see annotations loadInterface replaces the `mi_decls`, `mi_insts`, `mi_fam_insts`, `mi_rules`, `mi_anns` fields of ModIface with `undefined` before inserting the interface into the EPS. However, we still want to give loadInterface plugins access to these fields. Consequently, we want to pass the unmodified `ModIface` the plugin. - - - - - a999ee96 by Xavier Denis at 2020-02-29T05:07:50-05:00 Rename ghci.sh and build.sh to ghci and build respectively Convert hadrian buildscripts to unsuffixed, dashed form final cleanups - - - - - b5fb58fd by Ömer Sinan Ağacan at 2020-02-29T05:08:36-05:00 Document and refactor a few things around bitmap scavenging - Added a few comments in StgPAP - Added a few comments and assertions in scavenge_small_bitmap and walk_large_bitmap - Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted dead code, used PlatformWordSize type. - - - - - 18757cab by Sylvain Henry at 2020-02-29T05:09:25-05:00 Refactor runtime interpreter code In #14335 we want to be able to use both the internal interpreter (for the plugins) and the external interpreter (for TH and GHCi) at the same time. This patch performs some preliminary refactoring: the `hsc_interp` field of HscEnv replaces `hsc_iserv` and is now used to indicate which interpreter (internal, external) to use to execute TH and GHCi. Opt_ExternalInterpreter flag and iserv options in DynFlags are now queried only when we set the session DynFlags. It should help making GHC multi-target in the future by selecting an interpreter according to the selected target. - - - - - b86a6395 by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct relative links to haddocks from users guide (fixes #17866) - - - - - 0f55df7f by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct link to th haddocks from users guide - - - - - 252e5117 by Jean-Baptiste Mazon at 2020-02-29T05:10:46-05:00 rts: enforce POSIX numeric locale for heap profiles - - - - - 34c7d230 by Sylvain Henry at 2020-02-29T05:11:27-05:00 Fix Hadrian's ``--configure`` (fix #17883) - - - - - 04d30137 by Ömer Sinan Ağacan at 2020-02-29T05:12:06-05:00 Simplify IfaceIdInfo type IfaceIdInfo type is confusing: there's practically no difference between `NoInfo` and `HasInfo []`. The comments say NoInfo is used when -fomit-interface-pragmas is enabled, but we don't need to distinguish `NoInfo` from `HasInfo []` in when reading the interface so the distinction is not important. This patch simplifies the type by removing NoInfo. When we have no info we use an empty list. With this change we no longer read the info list lazily when reading an IfaceInfoItem, but when reading an IfaceId the ifIdInfo field is read lazily, so I doubt this is going to be a problem. - - - - - 3979485b by Roland Senn at 2020-02-29T17:36:59+01:00 Show breakpoint locations of breakpoints which were ignored during :force (#2950) GHCi is split up into 2 major parts: The user-interface (UI) and the byte-code interpreter. With `-fexternal-interpreter` they even run in different processes. Communication between the UI and the Interpreter (called `iserv`) is done using messages over a pipe. This is called `Remote GHCI` and explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`. To process a `:force` command the UI sends a `Seq` message to the `iserv` process. Then `iserv` does the effective evaluation of the value. When during this process a breakpoint is hit, the `iserv` process has no additional information to enhance the `Ignoring breakpoint` output with the breakpoint location. To be able to print additional breakpoint information, there are 2 possible implementation choices: 1. Store the needed information in the `iserv` process. 2. Print the `Ignoring breakpoint` from the UI process. For option 1 we need to store the breakpoint info redundantely in 2 places and this is bad. Therfore option 2 was implemented in this MR: - The user enters a `force` command - The UI sends a `Seq` message to the `iserv` process. - If processing of the `Seq` message hits a breakpoint, the `iserv` process returns control to the UI process. - The UI looks up the source location of the breakpoint, and prints the enhanced `Ignoring breakpoint` output. - The UI sends a `ResumeSeq` message to the `iserv` process, to continue forcing. - - - - - 3cf7303b by Krzysztof Gogolewski at 2020-03-02T01:18:33-05:00 Remove dead code * The names in PrelName and THNames are no longer used since TH merged types and kinds, Typeable is kind-polymorphic, .net support was removed * unqualQuasiQuote no longer used since 6f8ff0bbad3b9fa3 - - - - - dbea7e9d by Ilias Tsitsimpis at 2020-03-02T01:19:12-05:00 Do not define hs_atomic{read,write}64() on non-64bit Do not define hs_atomicread64() and hs_atomicwrite64() on machines where WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic functions which work on 64-bit values. Without this, compilation fails on MIPSel and PowerPC with the following error: /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64': atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8' /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64': atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8' Fixes #17886. - - - - - 7c0c76fb by Roland Senn at 2020-03-02T17:13:55-05:00 Set `ImpredicativeTypes` during :print command. (#14828) If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the type of <term> has nested `forall`s or `=>`s. This is because the GHCi debugger's internals will attempt to unify a metavariable with the type of <term> and then display the result, but if the type has nested `forall`s or `=>`s, then unification will fail. As a result, `:print` will bail out and the unhelpful result will be `<term> = (_t1::t1)` (where `t1` is a metavariable). Beware: <term> can have nested `forall`s even if its definition doesn't use RankNTypes! Here is an example from #14828: class Functor f where fmap :: (a -> b) -> f a -> f b Somewhat surprisingly, `:print fmap` considers the type of fmap to have nested foralls. This is because the GHCi debugger sees the type `fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`. We could envision deeply instantiating this type to get the type `forall f a b. Functor f => (a -> b) -> f a -> f b`, but this trick wouldn't work for higher-rank types. Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using `:print` and friends in the GHCi debugger. This is allows metavariables to unify with types that have nested (or higher-rank) `forall`s/`=>`s, which makes `:print fmap` display as `fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected. Although ImpredicativeTypes is a somewhat unpredictable from a type inference perspective, there is no danger in using it in the GHCi debugger, since all of the terms that the GHCi debugger deals with have already been typechecked. - - - - - 2a2f51d7 by Sylvain Henry at 2020-03-02T17:14:38-05:00 Use configure script to detect that we should use in-tree GMP on Windows - - - - - 8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00 Be explicit about how stack usage of mvar primops are covered. This fixes #17893 [skip-ci] - - - - - cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Add getCurrentThreadCPUTime helper - - - - - ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00 nonmoving-gc: Track time usage of nonmoving marking - - - - - 022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00 Stats: Add sync pauses to +RTS -S output - - - - - 06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Report nonmoving collector statistics in machine-readable output - - - - - 70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00 nonmoving: Fix collection of sparks Previously sparks living in the non-moving heap would be promptly GC'd by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag, which non-moving heap blocks do not have set. Fix this by implementing proper support in pruneSparkQueue for determining reachability in the non-moving heap. The story is told in Note [Spark management in the nonmoving heap]. - - - - - 9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00 gitlab-ci: Disable Sphinx documentation in Alpine build - - - - - 8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 Fix Windows breakage by not touching locales on Windows - - - - - b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: ensure C numerics in heap profiles using Windows locales if needed - - - - - 7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: refactor and comment profile locales - - - - - 5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00 Use InstanceSigs in GND/DerivingVia-generated code (#17899) Aside from making the generated code easier to read when `-ddump-deriv` is enabled, this makes the error message in `T15073` substantially simpler (see the updated `T15073` expected stderr). Fixes #17899. - - - - - 70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00 SysTools: Ensure that error parser can handle absolute paths on Windows This fixes #17786, where the error parser fails to correctly handle the drive name in absolute Windows paths. Unfortunately I couldn't find a satisfactory way to test this. - - - - - 85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00 testsuite: Add test for #17786 This isn't pretty but it's perhaps better than nothing. - - - - - ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00 Hadrian: track missing configure results - - - - - ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00 Add regression test for T17904 Closes #17904 - - - - - 5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00 anyRewritableTyVar now looks in RuntimeReps Previously, anyRewritableTyVar looked only at the arg and res of `arg -> res`, but their RuntimeReps are also subject to rewriting. Easy to fix. Test case: typecheck/should_compile/T17024 Fixes #17024. - - - - - 5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00 Clarify a Lint message When developing a plugin I had a shadowing problem, where I generated code app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B} This is obviously wrong, since the occurrence of `f` to the right of the arrow refers to the `x` binder (they share a Unique). However, it is rather confusing when Lint reports Mismatch in type between binder and occurrence Var: x{v rB7} since it is printing the binder, rather than the occurrence. It is rather easy to read this as claiming there is something wrong with the `x` occurrence! We change the report to explicitly print both the binder and the occurrence variables. - - - - - 7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00 Comments only Clarify code added in #17852 and MR !2724 - - - - - 3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00 Misc cleanup - Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole - - - - - abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00 Typos in comments [skip ci] - - - - - bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00 rts: Prefer darwin-specific getCurrentThreadCPUTime macOS Catalina now supports a non-POSIX-compliant version of clock_gettime which cannot use the clock_gettime codepath. Fixes #17906. - - - - - 20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00 Split GHC.Iface.Utils module * GHC.Iface.Recomp: recompilation avoidance stuff * GHC.Iface.Make: mkIface* Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and renamed it `writeIface` for consistency. - - - - - 1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00 Fixed a minor typo in codegen.rst - - - - - 0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00 Re-quantify when generalising over rewrite rule types Previously, `tcRules` would check for naughty quantification candidates (see `Note [Naughty quantification candidates]` in `TcMType`) when generalising over the type of a rewrite rule. This caused sensible-looking rewrite rules (like those in #17710) to be rejected. A more permissing (and easier-to-implement) approach is to do what is described in `Note [Generalising in tcTyFamInstEqnGuts]` in `TcTyClsDecls`: just re-quantify all the type variable binders, regardless of the order in which the user specified them. After all, the notion of type variable specificity has no real meaning in rewrite rules, since one cannot "visibly apply" a rewrite rule. I have written up this wisdom in `Note [Re-quantify type variables in rules]` in `TcRules`. As a result of this patch, compiling the `ExplicitForAllRules1` test case now generates one fewer warning than it used to. As far as I can tell, this is benign, since the thing that the disappearing warning talked about was also mentioned in an entirely separate warning. Fixes #17710. - - - - - 336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00 testsuite: Mark ghci056 and ghcilink004 as fragile in unreg As noted in #17018. Also fix fragile declaration of T13786, which only runs in the normal way. - - - - - c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00 Deepen call stack for isIn I see quite a few warnings like: WARNING: file compiler/utils/Util.hs, line 593 Over-long elem in unionLists But the call stack is uninformative. Better to add HasDebugCallStack to isIn. Ditto isn'tIn. - - - - - 3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00 Zero any slop after compaction in compacting GC In copying GC, with the relevant debug flags enabled, we release the old blocks after a GC, and the block allocator zeroes the space before releasing a block. This effectively zeros the old heap. In compacting GC we reuse the blocks and previously we didn't zero the unused space in a compacting generation after compaction. With this patch we zero the slop between the free pointer and the end of the block when we're done with compaction and when switching to a new block (because the current block doesn't have enough space for the next object we're shifting). - - - - - 8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor GHC.Driver.Session (Ways and Flags) * extract flags and ways into their own modules (with some renaming) * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases * when GHC uses dynamic linking (WayDyn), `interpWays` was only reporting WayDyn even if the host was profiled (WayProf). Now it returns both as expected (might fix #16803). * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for differently ordered lists. Now we sort and nub the list to fix this. - - - - - bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor interpreterDynamic and interpreterProfiled * `interpreterDynamic` and `interpreterProfiled` now take `Interp` parameters instead of DynFlags * slight refactoring of `ExternalInterp` so that we can read the iserv configuration (which is pure) without reading an MVar. - - - - - a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Use a Set to represent Ways Should make `member` queries faster and avoid messing up with missing `nubSort`. Metric Increase: hie002 - - - - - cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00 Make DeriveFunctor-generated code require fewer beta reductions Issue #17880 demonstrates that `DeriveFunctor`-generated code is surprisingly fragile when rank-_n_ types are involved. The culprit is that `$fmap` (the algorithm used to generate `fmap` implementations) was too keen on applying arguments with rank-_n_ types to lambdas, which fail to typecheck more often than not. In this patch, I change `$fmap` (both the specification and the implementation) to produce code that avoids creating as many lambdas, avoiding problems when rank-_n_ field types arise. See the comments titled "Functor instances" in `TcGenFunctor` for a more detailed description. Not only does this fix #17880, but it also ensures that the code that `DeriveFunctor` generates will continue to work after simplified subsumption is implemented (see #17775). What is truly amazing is that #17880 is actually a regression (introduced in GHC 7.6.3) caused by commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to that commit, the version of `$fmap` that was used was almost identical to the one used in this patch! Why did that commit change `$fmap` then? It was to avoid severe performance issues that would arise for recursive `fmap` implementations, such as in the example below: ```hs data List a = Nil | Cons a (List a) deriving Functor -- ===> instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs) ``` The fact that `\y -> f y` was eta expanded caused significant performance overheads. Commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance issue, but it went too far. As a result, this patch partially reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e. To ensure that the performance issues pre-#7436 do not resurface, I have taken some precautionary measures: * I have added a special case to `$fmap` for situations where the last type variable in an application of some type occurs directly. If this special case fires, we avoid creating a lambda expression. This ensures that we generate `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived `Functor List` instance above. For more details, see `Note [Avoid unnecessary eta expansion in derived fmap implementations]` in `TcGenFunctor`. * I have added a `T7436b` test case to ensure that the performance of this derived `Functor List`-style code does not regress. When implementing this, I discovered that `$replace`, the algorithm which generates implementations of `(<$)`, has a special case that is very similar to the `$fmap` special case described above. `$replace` marked this special case with a custom `Replacer` data type, which was a bit overkill. In order to use the same machinery for both `Functor` methods, I ripped out `Replacer` and instead implemented a simple way to detect the special case. See the updated commentary in `Note [Deriving <$]` for more details. - - - - - 1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Properly parenthesise LastStmt After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ``` - - - - - 5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Do not print ApplicativeDo join * Do not print `join` in ApplictiveStmt, unless ppr-debug * Print parens around multiple parallel binds When ApplicativeDo is enabled, the renamer analyses the statements of a `do` block and in certain cases marks them as needing to be rewritten using `join`. For example, if you have: ``` foo = do a <- e1 b <- e2 doSomething a b ``` it will be desugared into: ``` foo = join (doSomething <$> e1 <*> e2) ``` After renaming but before desugaring the expression is stored essentially as: ``` foo = do [will need join] (a <- e1 | b <- e2) [no return] doSomething a b ``` Before this change, the pretty printer would print a call to `join`, even though it is not needed at this stage at all. The expression will be actually rewritten into one using join only at desugaring, at which point a literal call to join will be inserted. - - - - - 3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00 Expose compulsory unfoldings always The unsafeCoerce# patch requires that unsafeCoerce# has a compulsory unfolding that is always available. So we have to be careful to expose compulsory unfoldings unconditionally and consistently. We didn't get this quite right: #17871. This patch fixes it. No real surprises here. See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - - - - - 6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00 hadrian: improve dependency tracking for the check-* programs The code in Rules.Register responsible for finding all the build artifacts that Cabal installs when registering a library (static/shared libs, .hi files, ...) was looking in the wrong place. This patch fixes that logic and makes sure we gather all those artifacts in a list to declare that the rule for a given `.conf` file, our proxy for "Hadrian, please install this package in the package db for this stage", also produces those artifacts under the said package database. We also were completely missing some logic to declare that the check-* programs have dependencies besides their source code, at least when testing an in-tree compiler. Finally, this patch also removes redundant packages from 'testsuitePackages', since they should already be covered by the stage<N>Packages lists from Settings.Default. With this patch, after a complete build and freezing stage 1, a change to `compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it, and rebuilding the few programs that depend on it, _including_ `check-ppr` and `check-api-annotations` (therefore fixing #17273). - - - - - 44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00 Rename isDllName I wanted to fix the dangling comment in `isDllName` ("This is the cause of #", #8696 is already mentioned earlier). I took the opportunity to change the function name to better reflect what it does. - - - - - 2f292db8 by Paavo at 2020-03-13T02:31:03-04:00 Update documentation for closureSize - - - - - f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00 gitlab-ci: Rework triggering of release builds Use a push option instead of tagging. - - - - - 7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00 gitlab-ci: Distinguish integer-simple test envs Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes. - - - - - c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00 Fix Lint Ticket #17590 pointed out a bug in the way the linter dealt with type lets, exposed by the new uniqAway story. The fix is described in Note [Linting type lets]. I ended up putting the in-scope Ids in a different env field, le_ids, rather than (as before) sneaking them into the TCvSubst. Surprisingly tiresome, but done. Metric Decrease: hie002 - - - - - b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00 Hadrian: fix absolute buildroot support (#17822) Shake's "**" wildcard doesn't match absolute root. We must use "//" instead. - - - - - 4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00 Make: refactor GMP rules Document and use simpler rules for the ghc-gmp.h header. - - - - - 7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00 Use correct option name (-opti) (fix #17314) s/pgmo/opti - - - - - 8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script. Previously it was possible to override the stage0 C compiler via `CC_STAGE0`, but you couldn't override `ld` or `ar` in stage0. This change allows overriding them by setting `LD_STAGE0` or `AR_STAGE0`, respectively. Our team uses this feature internally to take more control of our GHC build and make it run more hermetically. - - - - - 7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0. - - - - - 20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00 nonmoving: Don't traverse filled segment list in pause The non-moving collector would previously walk the entire filled segment list during the preparatory pause. However, this is far more work than is strictly necessary. We can rather get away with merely collecting the allocators' filled segment list heads and process the lists themselves during the concurrent phase. This can significantly reduce the maximum gen1 GC pause time in programs with high rates of long-lived allocations. - - - - - fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00 nonmoving: Remove redundant bitmap clearing nonmovingSweep already clears the bitmap in the sweep loop. There is no reason to do so a second time. - - - - - 2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Simple refactor of cheapEqExpr No change in functionality. Just seems tidier (and signficantly more efficient) to deal with ticks directly than to call stripTicksTopE. - - - - - 88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Improve CSE.combineAlts This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642 - - - - - 8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00 gitlab-ci: Add integer-simple release build for Windows Closes #16144. - - - - - e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. - - - - - 73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. - - - - - 93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00 base: Make `open` calls interruptible As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible. - - - - - bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00 Remove second tcLookupTcTyCon in tcDataDefn Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row: 1. in bindTyClTyVars itself 2. in the continuation passed to it Now bindTyClTyVars passes the TcTyCon to the continuation, making the second lookup unnecessary. - - - - - 3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00 Enable stage1 build of haddock The submodule has already been bumped to contain the fix. - - - - - 49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00 rts: Fix printClosure when printing fwd ptrs - - - - - 1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00 Remove unused field var_inline (#17915) - - - - - d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00 Document restriction on SCC pragma syntax Currently, the names of cost centres must be quoted or be lowercase identifiers. Fixes #17916. - - - - - b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00 Remove some dead code >From the notes.ghc.drop list found using weeder in #17713 - - - - - dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00 Note platform-specific Foreign.C.Types in context Also fix the markup in the general note at the top of the module. Haddock (usability trade-off), does not support multi-line emphasised text. - - - - - 2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00 Refactor CmmToAsm (disentangle DynFlags) This patch disentangles a bit more DynFlags from the native code generator (CmmToAsm). In more details: - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the configuration of a native code generation session - explicitly pass NCGConfig/Platform arguments when necessary - as a consequence `sdocWithPlatform` is gone and there are only a few `sdocWithDynFlags` left - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig) There are still some places where DynFlags is used, especially because of pretty-printing (CLabel), because of Cmm helpers (such as `cmmExprType`) and because of `Outputable` instance for the instructions. These are left for future refactoring as this patch is already big. - - - - - c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00 Add a -no-haddock flag. This flag undoes the effect of a previous "-haddock" flag. Having both flags makes it easier for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC). I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list. - - - - - cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00 Fix global_link of TSOs for threads reachable via dead weaks Fixes #17785 Here's how the problem occurs: - In generation 0 we have a TSO that is finished (i.e. it has no more work to do or it is killed). - The TSO only becomes reachable after collectDeadWeakPtrs(). - After collectDeadWeakPtrs() we switch to WeakDone phase where we don't move TSOs to different lists anymore (like the next gen's thread list or the resurrected_threads list). - So the TSO will never be moved to a generation's thread list, but it will be promoted to generation 1. - Generation 1 collected via mark-compact, and because the TSO is reachable it is marked, and its `global_link` field, which is bogus at this point (because the TSO is not in a list), will be threaded. - Chaos ensues. In other words, when these conditions hold: - A TSO is reachable only after collectDeadWeakPtrs() - It's finished (what_next is ThreadComplete or ThreadKilled) - It's retained by mark-compact collector (moving collector doesn't evacuate the global_list field) We end up doing random mutations on the heap because the TSO's global_list field is not valid, but it still looks like a heap pointer so we thread it during compacting GC. The fix is simple: when we traverse old_threads lists to resurrect unreachable threads the threads that won't be resurrected currently stays on the old_threads lists. Those threads will never be visited again by MarkWeak so we now reset the global_list fields. This way compacting GC does not thread pointers to nowhere. Testing ------- The reproducer in #17785 is quite large and hard to build, because of the dependencies, so I'm not adding a regression test. In my testing the reproducer would take a less than 5 seconds to run, and once in every ~5 runs would fail with a segfault or an assertion error. In other cases it also fails with a test failure. Because the tests never fail with the bug fix, assuming the code is correct, this also means that this bug can sometimes lead to incorrect runtime results. After the fix I was able to run the reproducer repeatedly for about an hour, with no runtime crashes or test failures. To run the reproducer clone the git repo: $ git clone https://github.com/osa1/streamly --branch ghc-segfault Then clone primitive and atomic-primops from their git repos and point to the clones in cabal.project.local. The project should then be buildable using GHC HEAD. Run the executable `properties` with `+RTS -c -DZ`. In addition to the reproducer above I run the test suite using: $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \ -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr' This enables compacting GC always in both GHC when building the test programs and when running the test programs, and also enables sanity checking when running the test programs. These set of flags are not compatible for all tests so there are some failures, but I got the same set of failures with this patch compared to GHC HEAD. - - - - - 818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00 base: add strict IO functions: readFile', getContents', hGetContents' - - - - - 18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00 Modules: Core (#13009) Update submodule: haddock - - - - - 92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00 Update sanity checking for TSOs: - Remove an invalid assumption about GC checking what_next field. The GC doesn't care about what_next at all, if a TSO is reachable then all its pointers are followed (other than global_tso, which is only followed by compacting GC). - Remove checkSTACK in checkTSO: TSO stacks will be visited in checkHeapChain, or checkLargeObjects etc. - Add an assertion in checkTSO to check that the global_link field is sane. - Did some refactor to remove forward decls in checkGlobalTSOList and added braces around single-statement if statements. - - - - - e1aa4052 by PHO at 2020-03-17T07:36:09-04:00 Don't use non-portable operator "==" in configure.ac The test operator "==" is a Bash extension and produces a wrong result if /bin/sh is not Bash. - - - - - 89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00 Document the units of -ddump-timings Right now, in the output of -ddump-timings to a file, you can't tell what the units are: ``` CodeGen [TemplateTestImports]: alloc=22454880 time=14.597 ``` I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`: ``` when (verbosity dflags >= 2 && prtimings == PrintTimings) $ liftIO $ logInfo dflags (defaultUserStyle dflags) (text "!!!" <+> what <> colon <+> text "finished in" <+> doublePrec 2 time <+> text "milliseconds" <> comma <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") ``` which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB) - - - - - beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00 Implement mapTyCo like foldTyCo This patch makes mapType use the successful idiom described in TyCoRep Note [Specialising foldType] I have not yet changed any functions to use mapType, though there may be some suitable candidates. This patch should be a no-op in terms of functionality but, because it inlines the mapper itself, I'm hoping that there may be some modest perf improvements. Metric Decrease: T5631 T5642 T3064 T9020 T14683 hie002 haddock.Cabal haddock.base haddock.compiler - - - - - 5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00 Don't update ModDetails with CafInfos when opts are disabled This is consistent with the interface file behavior where we omit HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0). ModDetails and ModIface are just different representations of the same thing, so they really need to be in sync. This patch does the right thing and does not need too much explanation, but here's an example of a problem not doing this causes in !2842: -- MyInteger.hs module MyInteger ( MyInteger (MyInteger) , ToMyInteger (toMyInteger) ) where newtype MyInteger = MyInteger Integer class ToMyInteger a where toMyInteger :: a -> MyInteger instance ToMyInteger Integer where toMyInteger = MyInteger {- . succ -} -- Main.hs module Main ( main ) where import MyInteger (MyInteger (MyInteger), toMyInteger) main :: IO () main = do let (MyInteger i) = (id . toMyInteger) (41 :: Integer) print i If I build this with -O0, without this fix, we generate a ModDetails with accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the value: R3 = MyInteger.$fToMyIntegerInteger_closure + 1; R2 = GHC.Base.id_closure; R1 = GHC.Base.._closure; Sp = Sp - 16; call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24; Now we change the definition by uncommenting the `succ` part and it becomes a thunk: MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)] :: MyInteger.ToMyInteger GHC.Integer.Type.Integer [GblId[DFunId(nt)]] = {} \u [] $ctoMyInteger_rEA; and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the use site: we can no longer tag it. But becuase the interface fingerprint does not change (because ModIface does not change) we don't rebuild Main and tag the thunk. (1.2% increase in allocations when building T12545 on armv7 because we generate more code without CafInfos) Metric Increase: T12545 - - - - - 5b632dad by Paavo at 2020-03-17T07:38:48-04:00 Add example for Data.Semigroup.diff - - - - - 4d85d68b by Paavo at 2020-03-17T07:38:48-04:00 Clean up - - - - - 75168d07 by Paavo at 2020-03-17T07:38:48-04:00 Make example collapsible - - - - - 53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00 Fix #17021 by checking more return kinds All the details are in new Note [Datatype return kinds] in TcTyClsDecls. Test case: typecheck/should_fail/T17021{,b} typecheck/should_compile/T17021a Updates haddock submodule - - - - - 528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00 Modules: Core operations (#13009) - - - - - 4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00 Add release note about fix to #16502. We thought we needed to update the manual, but the fix for #16502 actually brings the implementation in line with the manual. So we just alert users of how to update their code. - - - - - 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings Fix #18323 by adding a few lines of code to handle non-recursive pattern bindings. see GHC.Tc.Gen.Bind Note [Special case for non-recursive pattern bindings] Alas, this confused the pattern-match overlap checker; see #18323. Note that this patch only affects pattern bindings like that for (x,y) in this program combine :: (forall a . [a] -> a) -> [forall a. a -> a] -> ((forall a . [a] -> a), [forall a. a -> a]) breaks = let (x,y) = combine head ids in x y True We need ImpredicativeTypes for those [forall a. a->a] types to be valid. And with ImpredicativeTypes the old, unprincipled "allow unification variables to unify with a polytype" story actually works quite well. So this test compiles fine (if delicatedly) with old GHCs; but not with QuickLook unless we add this patch - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -ddump-stg was dumping the initial STG (just after Core-to-STG pass) which was misleading because we want the final STG to know if a function allocates or not. Now we have a new flag -ddump-stg-from-core for this and -ddump-stg is deprecated. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y In preparation for the next version of 'happy', c95920 added a qualified import to GHC/Parser.y but for some reason neglected GHC/Cmm/Parser.y This patch adds the missing qualified import to GHC/Cmm/Parser.y and also adds a clarifying comment to explain why this import is needed. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) With validate-x86_64-linux-deb9-hadrian: T1969 -3.4% (threshold: +/-1%) T3294 -3.3% (threshold: +/-1%) T12707 -1.4% (threshold: +/-1%) Additionally with validate-x86_64-linux-deb9-unreg-hadrian: T4801 -2.4% (threshold: +/-2%) T13035 -1.4% (threshold: +/-1%) T13379 -2.4% (threshold: +/-2%) ManyAlternatives -2.5% (threshold: +/-2%) ManyConstructors -3.0% (threshold: +/-2%) Metric Decrease: T12707 T1969 T3294 ManyAlternatives ManyConstructors T13035 T13379 T4801 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' In #18069 we are observing MVar deadlocks from somewhere in ghc.exe. This use of MVar stood out as being one of the more likely culprits. Here we make sure that it is exception-safe. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) This patch mainly just replaces use of XRec p (IdP p) with LIdP p One slightly more significant change is to parameterise HsPatSynDetails over the pass rather than the argument type, so that it's uniform with HsConDeclDetails and HsConPatDetails. I also got rid of the dead code GHC.Hs.type.conDetailsArgs But this is all just minor refactoring. No change in functionality. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing When we pretty-print a UnitId for the user, we try to map it back to its origin package name, version and component to print "package-version:component" instead of some hash. The UnitId type doesn't carry these information, so we have to look into a UnitState to find them. This is why the Outputable instance of UnitId used `sdocWithDynFlags` in order to access the `unitState` field of DynFlags. This is wrong for several reasons: 1. The DynFlags are accessed when the message is printed, not when it is generated. So we could imagine that the unitState may have changed in-between. Especially if we want to allow unit unloading. 2. We want GHC to support several independent sessions at once, hence several UnitState. The current approach supposes there is a unique UnitState as a UnitId doesn't indicate which UnitState to use. See the Note [Pretty-printing UnitId] in GHC.Unit for the new approach implemented by this patch. One step closer to remove `sdocDynFlags` field from `SDocContext` (#10143). Fix #18124. Also fix some Backpack code to use SDoc instead of String. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats GNU as and the AIX assembler support floating point literals. SPARC seems to have support too but I cannot test on SPARC. Curiously, `doubleToBytes` is also used in the LLVM backend. To avoid endianness issues when cross-compiling float and double literals are printed as C-style floating point values. The assembler then takes care of memory layout and endianness. This was brought up in #18431 by @hsyl20. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories There were four categories of primops: Monadic, Dyadic, Compare, GenPrimOp. The compiler does not treat Monadic and Dyadic in any special way, we can just replace them with GenPrimOp. Compare is still used in isComparisonPrimOp. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `hsExprNeedsParens`, `hsTypeNeedsParens`, and `patNeedsParens` previously assumed that all uses of explicit tuples in the source syntax never need to be parenthesized. This is true save for one exception: boxed one-tuples, which use the `Solo` data type from `GHC.Tuple` instead of special tuple syntax. This patch adds the necessary logic to the three `*NeedsParens` functions to handle `Solo` correctly. Fixes #18612. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - Add three pseudoops to primops.txt.pp, so that Haddock renders the documentation - Update comments - Remove special case for "->" - it's no longer exported from GHC.Prim - Remove reference to Note [Compiling GHC.Prim] - the ad-hoc fix is no longer there after updates to levity polymorphism. - Document GHC.Prim - Remove the comment that lazy is levity-polymorphic. As far as I can tell, it never was: in 80e399639, only the unfolding was given an open type variable. - Remove haddock hack in GHC.Magic - no longer neccessary after adding realWorld# to primops.txt.pp. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance FastStrings can be compared in 2 ways: by Unique or lexically. We don't want to bless one particular way with an "Ord" instance because it leads to bugs (#18562) or to suboptimal code (e.g. using lexical comparison while a Unique comparison would suffice). UTF-8 encoding has the advantage that sorting strings by their encoded bytes also sorts them by their Unicode code points, without having to decode the actual code points. BUT GHC uses Modified UTF-8 which diverges from UTF-8 by encoding \0 as 0xC080 instead of 0x00 (to avoid null bytes in the middle of a String so that the string can still be null-terminated). This patch adds a new `utf8CompareShortByteString` function that performs sorting by bytes but that also takes Modified UTF-8 into account. It is much more performant than decoding the strings into [Char] to perform comparisons (which we did in the previous patch). Bump haddock submodule - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 The code that converts promoted tuple data constructors to `IfaceType`s in `GHC.CoreToIface` was using `isTupleDataCon`, which conflates boxed and unboxed tuple data constructors. To avoid this, this patch introduces `isBoxedTupleDataCon`, which is like `isTupleDataCon` but only works for _boxed_ tuple data constructors. While I was in town, I was horribly confused by the fact that there were separate functions named `isUnboxedTupleCon` and `isUnboxedTupleTyCon` (similarly, `isUnboxedSumCon` and `isUnboxedSumTyCon`). It turns out that the former only works for data constructors, despite its very general name! I opted to rename `isUnboxedTupleCon` to `isUnboxedTupleDataCon` (similarly, I renamed `isUnboxedSumCon` to `isUnboxedSumDataCon`) to avoid this potential confusion, as well as to be more consistent with the naming convention I used for `isBoxedTupleDataCon`. Fixes #18644. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows The fix to #17962 ended up regressing on Windows as it failed to replicate the logic responsible for overriding the toolchain paths on Windows. This resulted in a hard-coded path to a directory that likely doesn't exist on the user's system (#18550). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling In b592bd98ff25730bbe3c13d6f62a427df8c78e28 we started using -dead_strip_dylib on macOS when lining dynamic libraries and binaries. The underlying reason being the Load Command Size Limit in macOS Sierra (10.14) and later. GHC will produce @rpath/libHS... dependency entries together with a corresponding RPATH entry pointing to the location of the libHS... library. Thus for every library we produce two Load Commands. One to specify the dependent library, and one with the path where to find it. This makes relocating libraries and binaries easier, as we just need to update the RPATH entry with the install_name_tool. The dynamic linker will then subsitute each @rpath with the RPATH entries it finds in the libraries load commands or the environement, when looking up @rpath relative libraries. -dead_strip_dylibs intructs the linker to drop unused libraries. This in turn help us reduce the number of referenced libraries, and subsequently the size of the load commands. This however does not remove the RPATH entries. Subsequently we can end up (in extreme cases) with only a single @rpath/libHS... entry, but 100s or more RPATH entries in the Load Commands. This patch rectifies this (slighly unorthodox) by passing *no* -rpath arguments to the linker at link time, but -headerpad 8000. The headerpad argument is in hexadecimal and the maxium 32k of the load command size. This tells the linker to pad the load command section enough for us to inject the RPATHs later. We then proceed to link the library or binary with -dead_strip_dylibs, and *after* the linking inspect the library to find the left over (non-dead-stripped) dependencies (using otool). We find the corresponding RPATHs for each @rpath relative dependency, and inject them into the library or binary using the install_name_tool. Thus achieving a deadstripped dylib (and rpaths) build product. We can not do this in GHC, without starting to reimplement a dynamic linker as we do not know which symbols and subsequently libraries are necessary. Commissioned-by: Mercury Technologies, Inc. (mercury.com) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) This fixes #18660 by changing `isLHsForAllTy` to `isLHsInvisForAllTy`, which is sufficient to make the `forall`-or-nothing rule only apply to invisible `forall`s. I also updated some related documentation and Notes while I was in the neighborhood. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops Change the constructors for the primop union, and also names of the literal conversion functions. "2" runs into trouble when we need to do conversions from fixed-width types, and end up with thing like "Int642Word". Only the names internal to GHC are changed, as I don't want to worry about breaking changes ATM. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking Previously, associated type family defaults were validity-checked during typechecking. Unfortunately, the error messages that these checks produce run the risk of printing knot-tied type constructors, which will cause GHC to diverge. In order to preserve the current error message's descriptiveness, this patch postpones these validity checks until after typechecking, which are now located in the new function `GHC.Tc.Validity.checkValidAssocTyFamDeflt`. Fixes #18648. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @alanz pointed out on ghc-devs that the payload of this pragma does not appear to be used anywhere. I (@bgamari) did some digging and traced the pragma's addition back to d386e0d2 (way back in 2006!). It appears that it was intended to be used by code generators for use in informing the code coveraging checker about generated code provenance. When it was added it used the pragma's "payload" fields as source location information to build an "ExternalBox". However, it looks like this was dropped a year later in 55a5d8d9. At this point it seems like the pragma serves no useful purpose. Given that it also is not documented, I think we should remove it. Updates haddock submodule Closes #18639 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) We didn't consider the RHS of a pattern-binding before, which led to surprising warnings listed in #18572. As can be seen from the regression test T18572, we get the expected output now. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following source syntax (#18565) Previously, we desugared and coverage checked plain guard trees as described in Lower Your Guards. That caused (in !3849) quite a bit of pain when we need to partially recover tree structure of the input syntax to return covered sets for long-distance information, for example. In this refactor, I introduced a guard tree variant for each relevant source syntax component of a pattern-match (mainly match groups, match, GRHS, empty case, pattern binding). I made sure to share as much coverage checking code as possible, so that the syntax-specific checking functions are just wrappers around the more substantial checking functions for the LYG primitives (`checkSequence`, `checkGrds`). The refactoring payed off in clearer code and elimination of all panics related to assumed guard tree structure and thus fixes #18565. I also took the liberty to rename and re-arrange the order of functions and comments in the module, deleted some dead and irrelevant Notes, wrote some new ones and gave an overview module haddock. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) In #18341, we discovered an incorrect digression from Lower Your Guards. This MR changes what's necessary to support properly fixing #18341. In particular, bottomness constraints are now properly tracked in the oracle/inhabitation testing, as an additional field `vi_bot :: Maybe Bool` in `VarInfo`. That in turn allows us to model newtypes as advertised in the Appendix of LYG and fix #17725. Proper handling of ⊥ also fixes #17977 (once again) and fixes #18670. For some reason I couldn't follow, this also fixes #18273. I also added a couple of regression tests that were missing. Most of them were already fixed before. In summary, this patch fixes #18341, #17725, #18273, #17977 and #18670. Metric Decrease: T12227 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - b9d4dd9c by Ben Gamari at 2020-10-24T20:44:17-04:00 SMP.h: Add C11-style atomic operations - - - - - ccf2d4b0 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts: Infrastructure for testing with ThreadSanitizer - - - - - a61f66d6 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/CNF: Initialize all bdescrs in group It seems wise and cheap to ensure that the whole bdescr of all blocks of a compact group is valid, even if most cases only look at the flags field. - - - - - 65136c13 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/Capability: Intialize interrupt field Previously this was left uninitialized. Also clarify some comments. - - - - - b3ce6aca by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/Task: Make comments proper Notes - - - - - d3890ac7 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/SpinLock: Move to proper atomics This is fairly straightforward; we just needed to use relaxed operations for the PROF_SPIN counters and a release store instead of a write barrier. - - - - - ef88712f by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/OSThreads: Fix data race Previously we would race on the cached processor count. Avoiding this is straightforward; just use relaxed operations. - - - - - 33a719c3 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/ClosureMaros: Use relaxed atomics - - - - - f08951fd by Ben Gamari at 2020-10-24T20:59:39-04:00 configure: Bump minimum-supported gcc version to 4.7 Since the __atomic_* builtins are not supported until gcc 4.7. Given that this version was released in 2012 I think this is acceptable. - - - - - d584923a by Ben Gamari at 2020-10-24T20:59:39-04:00 testsuite: Fix thread leak in hs_try_putmvar00[13] - - - - - bf1b0bc7 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts: Introduce SET_HDR_RELEASE Also ensure that we also store the info table pointer last to ensure that the synchronization covers all stores. - - - - - 1a2e9f5e by Ben Gamari at 2020-10-24T21:00:19-04:00 gitlab-ci: Add nightly-x86_64-linux-deb9-tsan job - - - - - 58a5b0e5 by GHC GitLab CI at 2020-10-24T21:00:19-04:00 testsuite: Mark setnumcapabilities001 as broken with TSAN Due to #18808. - - - - - d9bc7dea by GHC GitLab CI at 2020-10-24T21:00:19-04:00 testsuite: Skip divbyzero and derefnull under TSAN ThreadSanitizer changes the output of these tests. - - - - - fcc42a10 by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Skip high memory usage tests with TSAN ThreadSanitizer significantly increases the memory footprint of tests, so much so that it can send machines into OOM. - - - - - cae4bb3e by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark hie002 as high_memory_usage This test has a peak residency of 1GByte; this is large enough to classify as "high" in my book. - - - - - dae1b86a by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark T9872[abc] as high_memory_usage These all have a maximum residency of over 2 GB. - - - - - c5a0bb22 by Ben Gamari at 2020-10-24T21:00:19-04:00 gitlab-ci: Disable documentation in TSAN build Haddock chews through enough memory to cause the CI builders to OOM and there's frankly no reason to build documentation in this job anyways. - - - - - 4cb1232e by Ben Gamari at 2020-10-24T21:00:19-04:00 TSANUtils: Ensure that C11 atomics are supported - - - - - 7ed15f7f by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark T3807 as broken with TSAN Due to #18883. - - - - - f7e6f012 by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark T13702 as broken with TSAN due to #18884 - - - - - 16b136b0 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Factor out logic to identify a good capability for running a task Not only does this make the control flow a bit clearer but it also allows us to add a TSAN suppression on this logic, which requires (harmless) data races. - - - - - 2781d68c by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Annotate benign race in waitForCapability - - - - - f6b4b492 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Clarify locking behavior of releaseCapability_ - - - - - 65219810 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Add assertions for task ownership of capabilities - - - - - 31fa87ec by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Use relaxed atomics on n_returning_tasks This mitigates the warning of a benign race on n_returning_tasks in shouldYieldCapability. See #17261. - - - - - 6517a2ea by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Mitigate races in capability interruption logic - - - - - 2e9ba3f2 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts/Capability: Use relaxed operations for last_free_capability - - - - - e10dde37 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Use relaxed operations for cap->running_task (TODO) This shouldn't be necessary since only the owning thread of the capability should be touching this. - - - - - 855325cd by Ben Gamari at 2020-10-24T21:00:37-04:00 rts/Schedule: Use relaxed operations for sched_state - - - - - 811f915d by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Accept data race in work-stealing implementation This race is okay since the task is owned by the capability pushing it. By Note [Ownership of Task] this means that the capability is free to write to `task->cap` without taking `task->lock`. Fixes #17276. - - - - - 8d2b3c3d by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Eliminate data races on pending_sync - - - - - f8871018 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts/Schedule: Eliminate data races on recent_activity We cannot safely use relaxed atomics here. - - - - - d079b943 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Avoid data races in message handling - - - - - 06f80497 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts/Messages: Drop incredibly fishy write barrier executeMessage previously had a write barrier at the beginning of its loop apparently in an attempt to synchronize with another thread's writes to the Message. I would guess that the author had intended to use a load barrier here given that there are no globally-visible writes done in executeMessage. I've removed the redundant barrier since the necessary load barrier is now provided by the ACQUIRE_LOAD. - - - - - d4a87779 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts/ThreadPaused: Avoid data races - - - - - 56778ab3 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts/Schedule: Eliminate data races in run queue management - - - - - 086521f7 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts: Eliminate shutdown data race on task counters - - - - - abad9778 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts/Threads: Avoid data races (TODO) Replace barriers with appropriate ordering. Drop redundant barrier in tryWakeupThread (the RELEASE barrier will be provided by sendMessage's mutex release). We use relaxed operations on why_blocked and the stack although it's not clear to me why this is necessary. - - - - - 2f56be8a by Ben Gamari at 2020-10-24T21:00:39-04:00 rts/Messages: Annotate benign race - - - - - 7c0cdab1 by Ben Gamari at 2020-10-24T21:00:39-04:00 rts/RaiseAsync: Synchronize what_next read - - - - - 6cc2a8a5 by Ben Gamari at 2020-10-24T21:00:39-04:00 rts/Task: Move debugTrace to avoid data race Specifically, we need to hold all_tasks_mutex to read taskCount. - - - - - bbaec97d by Ben Gamari at 2020-10-24T21:00:39-04:00 Disable flawed assertion - - - - - dd175a92 by Ben Gamari at 2020-10-24T21:00:39-04:00 Document schedulePushWork race - - - - - 3416244b by Ben Gamari at 2020-10-24T21:00:40-04:00 Capabiliity: Properly fix data race on n_returning_tasks There is a real data race but can be made safe by using proper atomic (but relaxed) accesses. - - - - - dffd9432 by Ben Gamari at 2020-10-24T21:00:40-04:00 rts: Make write of to_cap->inbox atomic This is necessary since emptyInbox may read from to_cap->inbox without taking cap->lock. - - - - - 1f4cbc29 by Ben Gamari at 2020-10-24T21:00:57-04:00 rts/BlockAlloc: Use relaxed operations - - - - - d0d07cff by Ben Gamari at 2020-10-24T21:00:57-04:00 rts: Rework handling of mutlist scavenging statistics - - - - - 9e5c7f6d by Ben Gamari at 2020-10-24T21:00:57-04:00 rts: Avoid data races in StablePtr implementation This fixes two potentially problematic data races in the StablePtr implementation: * We would fail to RELEASE the stable pointer table when enlarging it, causing other cores to potentially see uninitialized memory. * We would fail to ACQUIRE when dereferencing a stable pointer. - - - - - 316add67 by Ben Gamari at 2020-10-24T21:00:57-04:00 rts/Storage: Use atomics - - - - - 5c23bc4c by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Updates: Use proper atomic operations - - - - - 3d0f033c by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Weak: Eliminate data races By taking all_tasks_mutex in stat_exit. Also better-document the fact that the task statistics are protected by all_tasks_mutex. - - - - - edb4b92b by Ben Gamari at 2020-10-24T21:01:18-04:00 rts/WSDeque: Rewrite with proper atomics After a few attempts at shoring up the previous implementation, I ended up turning to the literature and now use the proven implementation, > N.M. Lê, A. Pop, A.Cohen, and F.Z. Nardelli. "Correct and Efficient > Work-Stealing for Weak Memory Models". PPoPP'13, February 2013, > ACM 978-1-4503-1922/13/02. Note only is this approach formally proven correct under C11 semantics but it is also proved to be a bit faster in practice. - - - - - d39bbd3d by Ben Gamari at 2020-10-24T21:01:33-04:00 rts: Use relaxed atomics for whitehole spin stats - - - - - 8f802f38 by Ben Gamari at 2020-10-24T21:01:33-04:00 rts: Avoid lock order inversion during fork Fixes #17275. - - - - - cef667b0 by GHC GitLab CI at 2020-10-24T21:01:34-04:00 rts: Use proper relaxe operations in getCurrentThreadCPUTime Here we are doing lazy initialization; it's okay if we do the check more than once, hence relaxed operation is fine. - - - - - 8cf50eb1 by Ben Gamari at 2020-10-24T21:01:54-04:00 rts/STM: Use atomics This fixes a potentially harmful race where we failed to synchronize before looking at a TVar's current_value. Also did a bit of refactoring to avoid abstract over management of max_commits. - - - - - 88a7ce38 by Ben Gamari at 2020-10-24T21:01:54-04:00 rts/stm: Strengthen orderings to SEQ_CST instead of volatile Previously the `current_value`, `first_watch_queue_entry`, and `num_updates` fields of `StgTVar` were marked as `volatile` in an attempt to provide strong ordering. Of course, this isn't sufficient. We now use proper atomic operations. In most of these cases I strengthen the ordering all the way to SEQ_CST although it's possible that some could be weakened with some thought. - - - - - f97c59ce by Ben Gamari at 2020-10-24T21:02:11-04:00 Mitigate data races in event manager startup/shutdown - - - - - c7c3f8aa by Ben Gamari at 2020-10-24T21:02:22-04:00 rts: Accept benign races in Proftimer - - - - - 5a98dfca by Ben Gamari at 2020-10-24T21:02:22-04:00 rts: Pause timer while changing capability count This avoids #17289. - - - - - 01d95525 by Ben Gamari at 2020-10-24T21:02:22-04:00 Fix #17289 - - - - - 9a528985 by Ben Gamari at 2020-10-24T21:02:23-04:00 suppress #17289 (ticker) race - - - - - 1726ec41 by Ben Gamari at 2020-10-24T21:02:23-04:00 rts: Fix timer initialization Previously `initScheduler` would attempt to pause the ticker and in so doing acquire the ticker mutex. However, initTicker, which is responsible for initializing said mutex, hadn't been called yet. - - - - - bfbe4366 by Ben Gamari at 2020-10-24T21:02:23-04:00 rts: Fix races in Pthread timer backend shudown We can generally be pretty relaxed in the barriers here since the timer thread is a loop. - - - - - 297acc71 by Ben Gamari at 2020-10-24T21:02:44-04:00 rts/Stats: Hide a few unused unnecessarily global functions - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - aad1f803 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/GC: Use atomics - - - - - d0bc0517 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Use RELEASE ordering in unlockClosure - - - - - d44f5232 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/Storage: Accept races on heap size counters - - - - - 4e4a7386 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Join to concurrent mark thread during shutdown Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread. - - - - - a80cc857 by GHC GitLab CI at 2020-10-30T00:41:14-04:00 rts: Fix race in GC CPU time accounting Ensure that the GC leader synchronizes with workers before calling stat_endGC. - - - - - 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 105d43db by Ben Gamari at 2020-10-30T14:02:19-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - f7b45cde by Ben Gamari at 2020-10-30T14:02:19-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - bd4abdc9 by Ben Gamari at 2020-11-01T01:10:31-04:00 testsuite: Add performance test for #18698 - - - - - dfd27445 by Hécate at 2020-11-01T01:11:09-04:00 Add the proper HLint rules and remove redundant keywords from compiler - - - - - ce1bb995 by Hécate at 2020-11-01T08:52:08-05:00 Fix a leak in `transpose` This patch was authored by David Feuer <david.feuer at gmail.com> - - - - - e63db32c by Ben Gamari at 2020-11-01T08:52:44-05:00 Scav: Use bd->gen_no instead of bd->gen->no This potentially saves a cache miss per scavenge. - - - - - b1dda153 by Ben Gamari at 2020-11-01T12:58:36-05:00 rts/Stats: Protect with mutex While on face value this seems a bit heavy, I think it's far better than enforcing ordering on every access. - - - - - 5c2e6bce by Ben Gamari at 2020-11-01T12:58:36-05:00 rts: Tear down stats_mutex after exitHeapProfiling Since the latter wants to call getRTSStats. - - - - - ef25aaa1 by Ben Gamari at 2020-11-01T13:02:11-05:00 rts: Annotate hopefully "benign" races in freeGroup - - - - - 3a181553 by Ben Gamari at 2020-11-01T13:02:18-05:00 Strengthen ordering in releaseGCThreads - - - - - af474f62 by Ben Gamari at 2020-11-01T13:05:38-05:00 Suppress data race due to close This suppresses the other side of a race during shutdown. - - - - - b4686bff by Ben Gamari at 2020-11-01T13:09:59-05:00 Merge branch 'wip/tsan/ci' into wip/tsan/all - - - - - b8e66e0e by Ben Gamari at 2020-11-01T13:10:01-05:00 Merge branch 'wip/tsan/storage' into wip/tsan/all - - - - - 375512cf by Ben Gamari at 2020-11-01T13:10:02-05:00 Merge branch 'wip/tsan/wsdeque' into wip/tsan/all - - - - - 65ebf07e by Ben Gamari at 2020-11-01T13:10:03-05:00 Merge branch 'wip/tsan/misc' into wip/tsan/all - - - - - 55c375d0 by Ben Gamari at 2020-11-01T13:10:04-05:00 Merge branch 'wip/tsan/stm' into wip/tsan/all - - - - - a9f75fe2 by Ben Gamari at 2020-11-01T13:10:06-05:00 Merge branch 'wip/tsan/event-mgr' into wip/tsan/all - - - - - 8325d658 by Ben Gamari at 2020-11-01T13:10:24-05:00 Merge branch 'wip/tsan/timer' into wip/tsan/all - - - - - 07e82ba5 by Ben Gamari at 2020-11-01T13:10:35-05:00 Merge branch 'wip/tsan/stats' into wip/tsan/all - - - - - 4ce2f7d6 by GHC GitLab CI at 2020-11-02T23:45:06-05:00 testsuite: Add --top flag to driver This allows us to make `config.top` a proper Path. Previously it was a str, which caused the Ghostscript detection logic to break. - - - - - 0b772221 by Ben Gamari at 2020-11-02T23:45:42-05:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 81006a06 by David Eichmann at 2020-11-02T23:46:19-05:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - bfb1e272 by Ryan Scott at 2020-11-02T23:46:55-05:00 Display results of GHC.Core.Lint.lint* functions consistently Previously, the functions in `GHC.Core.Lint` used a patchwork of different ways to display Core Lint errors: * `lintPassResult` (which is the source of most Core Lint errors) renders Core Lint errors with a distinctive banner (e.g., `*** Core Lint errors : in result of ... ***`) that sets them apart from ordinary GHC error messages. * `lintAxioms`, in contrast, uses a completely different code path that displays Core Lint errors in a rather confusing manner. For example, the program in #18770 would give these results: ``` Bug.hs:1:1: error: Bug.hs:12:1: warning: Non-*-like kind when *-like expected: RuntimeRep when checking the body of forall: 'TupleRep '[r] In the coercion axiom Bug.N:T :: []. Bug.T ~_R Any Substitution: [TCvSubst In scope: InScope {r} Type env: [axl :-> r] Co env: []] | 1 | {-# LANGUAGE DataKinds #-} | ^ ``` * Further digging reveals that `GHC.IfaceToCore` displays Core Lint errors for iface unfoldings as though they were a GHC panic. See, for example, this excerpt from #17723: ``` ghc: panic! (the 'impossible' happened) (GHC version 8.8.2 for x86_64-unknown-linux): Iface Lint failure In interface for Lib ... ``` This patch makes all of these code paths display Core Lint errors and warnings consistently. I decided to adopt the conventions that `lintPassResult` currently uses, as they appear to have been around the longest (and look the best, in my subjective opinion). We now use the `displayLintResult` function for all three scenarios mentioned above. For example, here is what the Core Lint error for the program in #18770 looks like after this patch: ``` [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) *** Core Lint errors : in result of TcGblEnv axioms *** Bug.hs:12:1: warning: Non-*-like kind when *-like expected: RuntimeRep when checking the body of forall: 'TupleRep '[r_axn] In the coercion axiom N:T :: []. T ~_R Any Substitution: [TCvSubst In scope: InScope {r_axn} Type env: [axn :-> r_axn] Co env: []] *** Offending Program *** axiom N:T :: T = Any -- Defined at Bug.hs:12:1 *** End of Offense *** <no location info>: error: Compilation had errors ``` Fixes #18770. - - - - - a9e5f52c by Simon Peyton Jones at 2020-11-02T23:47:31-05:00 Expand type synonyms with :kind! The User's Guide claims that `:kind!` should expand type synonyms, but GHCi wasn't doing this in practice. Let's just update the implementation to match the specification in the User's Guide. Fixes #13795. Fixes #18828. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - 1370eda7 by Ben Gamari at 2020-11-02T23:48:06-05:00 hadrian: Don't capture RunTest output There are a few reasons why capturing the output of the RunTest builder is undesirable: * there is a large amount of output which then gets unnecessarily duplicated by Hadrian if the builder fails * the output may contain codepoints which are unrepresentable in the current codepage on Windows, causing Hadrian to crash * capturing the output causes the testsuite driver to disable its colorisation logic, making the output less legible. - - - - - 78f2767d by Matthew Pickering at 2020-11-03T17:39:53-05:00 Update inlining flags documentation - - - - - 14ce454f by Sylvain Henry at 2020-11-03T17:40:34-05:00 Linker: reorganize linker related code Move linker related code into GHC.Linker. Previously it was scattered into GHC.Unit.State, GHC.Driver.Pipeline, GHC.Runtime.Linker, etc. Add documentation in GHC.Linker - - - - - 616bec0d by Alan Zimmerman at 2020-11-03T17:41:10-05:00 Restrict Linear arrow %1 to exactly literal 1 only This disallows `a %001 -> b`, and makes sure the type literal is printed from its SourceText so it is clear why. Closes #18888 - - - - - 3486ebe6 by Sylvain Henry at 2020-11-03T17:41:48-05:00 Hadrian: don't fail if ghc-tarballs dir doesn't exist - - - - - 37f0434d by Sylvain Henry at 2020-11-03T17:42:26-05:00 Constant-folding: don't pass through GHC's Int/Word (fix #11704) Constant-folding rules for integerToWord/integerToInt were performing the following coercions at compilation time: integerToWord: target's Integer -> ghc's Word -> target's Word integerToInt : target's Integer -> ghc's Int -> target's Int 1) It was wrong for cross-compilers when GHC's word size is smaller than the target one. This patch avoids passing through GHC's word-sized types: integerToWord: target's Integer -> ghc's Integer -> target's Word integerToInt : target's Integer -> ghc's Integer -> target's Int 2) Additionally we didn't wrap the target word/int literal to make it fit into the target's range! This broke the invariant of literals only containing values in range. The existing code is wrong only with a 64-bit cross-compiling GHC, targeting a 32-bit platform, and performing constant folding on a literal that doesn't fit in a 32-bit word. If GHC was built with DEBUG, the assertion in GHC.Types.Literal.mkLitWord would fail. Otherwise the bad transformation would go unnoticed. - - - - - bff74de7 by Sylvain Henry at 2020-11-03T17:43:03-05:00 Bignum: make GMP's bignat_add not recursive bignat_add was a loopbreaker with an INLINE pragma (spotted by @mpickering). This patch makes it non recursive to avoid the issue. - - - - - bb100805 by Andreas Klebinger at 2020-11-04T16:47:24-05:00 NCG: Fix 64bit int comparisons on 32bit x86 We no compare these by doing 64bit subtraction and checking the resulting flags. We used to do this differently but the old approach was broken when the high bits compared equal and the comparison was one of >= or <=. The new approach should be both correct and faster. - - - - - b790b7f9 by Andreas Klebinger at 2020-11-04T16:47:59-05:00 Testsuite: Support for user supplied package dbs We can now supply additional package dbs to the testsuite. For make the package db can be supplied by passing PACKAGE_DB=/path/to/db. In the testsuite driver it's passed via the --test-package-db argument. - - - - - 81560981 by Sylvain Henry at 2020-11-04T16:48:42-05:00 Don't use LEA with 8-bit registers (#18614) - - - - - 17d5c518 by Viktor Dukhovni at 2020-11-05T00:50:23-05:00 Naming, value types and tests for Addr# atomics The atomic Exchange and CAS operations on integral types are updated to take and return more natural `Word#` rather than `Int#` values. These are bit-block not arithmetic operations, and the sign bit plays no special role. Standardises the names to `atomic<OpType><ValType>Addr#`, where `OpType` is one of `Cas` or `Exchange` and `ValType` is presently either `Word` or `Addr`. Eventually, variants for `Word32` and `Word64` can and should be added, once #11953 and related issues (e.g. #13825) are resolved. Adds tests for `Addr#` CAS that mirror existing tests for `MutableByteArray#`. - - - - - 2125b1d6 by Ryan Scott at 2020-11-05T00:51:01-05:00 Add a regression test for #18920 Commit f594a68a5500696d94ae36425bbf4d4073aca3b2 (`Use level numbers for generalisation`) ended up fixing #18920. Let's add a regression test to ensure that it stays fixed. Fixes #18920. - - - - - e07e383a by Ryan Scott at 2020-11-06T03:45:28-05:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * Working out the details led us to a substantial refactoring of the handling of explicit (user-written) and implicit type-variable bindings in `GHC.Tc.Gen.HsType`. Instead of a confusing family of higher order functions, we now have a local data type, `SkolemInfo`, that controls how these binders are kind-checked. It remains very fiddly, not fully satisfying. But it's better than it was. Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - c85f4928 by Sylvain Henry at 2020-11-06T03:46:08-05:00 Refactor -dynamic-too handling 1) Don't modify DynFlags (too much) for -dynamic-too: now when we generate dynamic outputs for "-dynamic-too", we only set "dynamicNow" boolean field in DynFlags instead of modifying several other fields. These fields now have accessors that take dynamicNow into account. 2) Use DynamicTooState ADT to represent -dynamic-too state. It's much clearer than the undocumented "DynamicTooConditional" that was used before. As a result, we can finally remove the hscs_iface_dflags field in HscRecomp. There was a comment on this field saying: "FIXME (osa): I don't understand why this is necessary, but I spent almost two days trying to figure this out and I couldn't .. perhaps someone who understands this code better will remove this later." I don't fully understand the details, but it was needed because of the changes made to the DynFlags for -dynamic-too. There is still something very dubious in GHC.Iface.Recomp: we have to disable the "dynamicNow" flag at some point for some Backpack's "heinous hack" to continue to work. It may be because interfaces for indefinite units are always non-dynamic, or because we mix and match dynamic and non-dynamic interfaces (#9176), or something else, who knows? - - - - - 2cb87909 by Moritz Angermann at 2020-11-06T03:46:44-05:00 [AArch64] Aarch64 Always PIC - - - - - b1d2c1f3 by Ben Gamari at 2020-11-06T03:47:19-05:00 rts/Sanity: Avoid nasty race in weak pointer sanity-checking See Note [Racing weak pointer evacuation] for all of the gory details. - - - - - 638f38c5 by Ben Gamari at 2020-11-08T09:29:16-05:00 Merge remote-tracking branch 'origin/wip/tsan/all' - - - - - 22888798 by Ben Gamari at 2020-11-08T12:08:40-05:00 Fix haddock submodule The previous merge mistakenly reverted it. - - - - - d445cf05 by Ben Gamari at 2020-11-10T10:26:20-05:00 rts/linker: Fix relocation overflow in PE linker Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB relocation failed to account for the signed nature of the value. Specifically, the overflow check was: uint64_t v; v = S + A; if (v >> 32) { ... } However, `v` ultimately needs to fit into 32-bits as a signed value. Consequently, values `v > 2^31` in fact overflow yet this is not caught by the existing overflow check. Here we rewrite the overflow check to rather ensure that `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases but I am leaving fixing this for future work. This bug was first noticed by @awson. Fixes #15808. - - - - - 4c407f6e by Sylvain Henry at 2020-11-10T10:27:00-05:00 Export SPEC from GHC.Exts (#13681) - - - - - 7814cd5b by David Eichmann at 2020-11-10T10:27:35-05:00 ghc-heap: expose decoding from heap representation Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - fa344d33 by Richard Eisenberg at 2020-11-10T10:28:10-05:00 Add test case for #17186. This got fixed sometime recently; not worth it trying to figure out which commit. - - - - - 2e63a0fb by David Eichmann at 2020-11-10T10:28:46-05:00 Add code comments for StgInfoTable and StgStack structs - - - - - fcfda909 by Ben Gamari at 2020-11-11T03:19:59-05:00 nativeGen: Make makeImportsDoc take an NCGConfig rather than DynFlags It appears this was an oversight as there is no reason the full DynFlags is necessary. - - - - - 6e23695e by Ben Gamari at 2020-11-11T03:19:59-05:00 Move this_module into NCGConfig In various places in the NCG we need the Module currently being compiled. Let's move this into the environment instead of chewing threw another register. - - - - - c6264a2d by Ben Gamari at 2020-11-11T03:20:00-05:00 codeGen: Produce local symbols for module-internal functions It turns out that some important native debugging/profiling tools (e.g. perf) rely only on symbol tables for function name resolution (as opposed to using DWARF DIEs). However, previously GHC would emit temporary symbols (e.g. `.La42b`) to identify module-internal entities. Such symbols are dropped during linking and therefore not visible to runtime tools (in addition to having rather un-helpful unique names). For instance, `perf report` would often end up attributing all cost to the libc `frame_dummy` symbol since Haskell code was no covered by any proper symbol (see #17605). We now rather follow the model of C compilers and emit descriptively-named local symbols for module internal things. Since this will increase object file size this behavior can be disabled with the `-fno-expose-internal-symbols` flag. With this `perf record` can finally be used against Haskell executables. Even more, with `-g3` `perf annotate` provides inline source code. - - - - - 584058dd by Ben Gamari at 2020-11-11T03:20:00-05:00 Enable -fexpose-internal-symbols when debug level >=2 This seems like a reasonable default as the object file size increases by around 5%. - - - - - c34a4b98 by Ömer Sinan Ağacan at 2020-11-11T03:20:35-05:00 Fix and enable object unloading in GHCi Fixes #16525 by tracking dependencies between object file symbols and marking symbol liveness during garbage collection See Note [Object unloading] in CheckUnload.c for details. - - - - - 2782487f by Ray Shih at 2020-11-11T03:20:35-05:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - 7a65f9e1 by GHC GitLab CI at 2020-11-11T03:20:35-05:00 rts: Introduce highMemDynamic - - - - - e9e1b2e7 by GHC GitLab CI at 2020-11-11T03:20:35-05:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 5506f134 by Krzysztof Gogolewski at 2020-11-11T03:21:14-05:00 Force argument in setIdMult (#18925) - - - - - 787e93ae by Ben Gamari at 2020-11-11T23:14:11-05:00 testsuite: Add testcase for #18733 - - - - - 5353fd50 by Ben Gamari at 2020-11-12T10:05:30-05:00 compiler: Fix recompilation checking In ticket #18733 we noticed a rather serious deficiency in the current fingerprinting logic for recursive groups. I have described the old fingerprinting story and its problems in Note [Fingerprinting recursive groups] and have reworked the story accordingly to avoid these issues. Fixes #18733. - - - - - 63fa3997 by Sebastian Graf at 2020-11-13T14:29:39-05:00 Arity: Rework `ArityType` to fix monotonicity (#18870) As we found out in #18870, `andArityType` is not monotone, with potentially severe consequences for termination of fixed-point iteration. That showed in an abundance of "Exciting arity" DEBUG messages that are emitted whenever we do more than one step in fixed-point iteration. The solution necessitates also recording `OneShotInfo` info for `ABot` arity type. Thus we get the following definition for `ArityType`: ``` data ArityType = AT [OneShotInfo] Divergence ``` The majority of changes in this patch are the result of refactoring use sites of `ArityType` to match the new definition. The regression test `T18870` asserts that we indeed don't emit any DEBUG output anymore for a function where we previously would have. Similarly, there's a regression test `T18937` for #18937, which we expect to be broken for now. Fixes #18870. - - - - - 197d59fa by Sebastian Graf at 2020-11-13T14:29:39-05:00 Arity: Emit "Exciting arity" warning only after second iteration (#18937) See Note [Exciting arity] why we emit the warning at all and why we only do after the second iteration now. Fixes #18937. - - - - - de7ec9dd by David Eichmann at 2020-11-13T14:30:16-05:00 Add rts_listThreads and rts_listMiscRoots to RtsAPI.h These are used to find the current roots of the garbage collector. Co-authored-by: Sven Tennie's avatarSven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering's avatarMatthew Pickering <matthewtpickering at gmail.com> Co-authored-by: default avatarBen Gamari <bgamari.foss at gmail.com> - - - - - 24a86f09 by Ben Gamari at 2020-11-13T14:30:51-05:00 gitlab-ci: Cache cabal store in linting job - - - - - 0a7e592c by Ben Gamari at 2020-11-15T03:35:45-05:00 nativeGen/dwarf: Fix procedure end addresses Previously the `.debug_aranges` and `.debug_info` (DIE) DWARF information would claim that procedures (represented with a `DW_TAG_subprogram` DIE) would only span the range covered by their entry block. This omitted all of the continuation blocks (represented by `DW_TAG_lexical_block` DIEs), confusing `perf`. Fix this by introducing a end-of-procedure label and using this as the `DW_AT_high_pc` of procedure `DW_TAG_subprogram` DIEs Fixes #17605. - - - - - 1e19183d by Ben Gamari at 2020-11-15T03:35:45-05:00 nativeGen/dwarf: Only produce DW_AT_source_note DIEs in -g3 Standard debugging tools don't know how to understand these so let's not produce them unless asked. - - - - - ad73370f by Ben Gamari at 2020-11-15T03:35:45-05:00 nativeGen/dwarf: Use DW_AT_linkage instead of DW_AT_MIPS_linkage - - - - - a2539650 by Ben Gamari at 2020-11-15T03:35:45-05:00 gitlab-ci: Add DWARF release jobs for Debian 10, Fedora27 - - - - - d61adb3d by Ryan Scott at 2020-11-15T03:36:21-05:00 Name (tc)SplitForAll- functions more consistently There is a zoo of `splitForAll-` functions in `GHC.Core.Type` (as well as `tcSplitForAll-` functions in `GHC.Tc.Utils.TcType`) that all do very similar things, but vary in the particular form of type variable that they return. To make things worse, the names of these functions are often quite misleading. Some particularly egregious examples: * `splitForAllTys` returns `TyCoVar`s, but `splitSomeForAllTys` returns `VarBndr`s. * `splitSomeForAllTys` returns `VarBndr`s, but `tcSplitSomeForAllTys` returns `TyVar`s. * `splitForAllTys` returns `TyCoVar`s, but `splitForAllTysInvis` returns `InvisTVBinder`s. (This in particular arose in the context of #18939, and this finally motivated me to bite the bullet and improve the status quo vis-à-vis how we name these functions.) In an attempt to bring some sanity to how these functions are named, I have opted to rename most of these functions en masse to use consistent suffixes that describe the particular form of type variable that each function returns. In concrete terms, this amounts to: * Functions that return a `TyVar` now use the suffix `-TyVar`. This caused the following functions to be renamed: * `splitTyVarForAllTys` -> `splitForAllTyVars` * `splitForAllTy_ty_maybe` -> `splitForAllTyVar_maybe` * `tcSplitForAllTys` -> `tcSplitForAllTyVars` * `tcSplitSomeForAllTys` -> `tcSplitSomeForAllTyVars` * Functions that return a `CoVar` now use the suffix `-CoVar`. This caused the following functions to be renamed: * `splitForAllTy_co_maybe` -> `splitForAllCoVar_maybe` * Functions that return a `TyCoVar` now use the suffix `-TyCoVar`. This caused the following functions to be renamed: * `splitForAllTy` -> `splitForAllTyCoVar` * `splitForAllTys` -> `splitForAllTyCoVars` * `splitForAllTys'` -> `splitForAllTyCoVars'` * `splitForAllTy_maybe` -> `splitForAllTyCoVar_maybe` * Functions that return a `VarBndr` now use the suffix corresponding to the most relevant type synonym. This caused the following functions to be renamed: * `splitForAllVarBndrs` -> `splitForAllTyCoVarBinders` * `splitForAllTysInvis` -> `splitForAllInvisTVBinders` * `splitForAllTysReq` -> `splitForAllReqTVBinders` * `splitSomeForAllTys` -> `splitSomeForAllTyCoVarBndrs` * `tcSplitForAllVarBndrs` -> `tcSplitForAllTyVarBinders` * `tcSplitForAllTysInvis` -> `tcSplitForAllInvisTVBinders` * `tcSplitForAllTysReq` -> `tcSplitForAllReqTVBinders` * `tcSplitForAllTy_maybe` -> `tcSplitForAllTyVarBinder_maybe` Note that I left the following functions alone: * Functions that split apart things besides `ForAllTy`s, such as `splitFunTys` or `splitPiTys`. Thankfully, there are far fewer of these functions than there are functions that split apart `ForAllTy`s, so there isn't much of a pressing need to apply the new naming convention elsewhere. * Functions that split apart `ForAllCo`s in `Coercion`s, such as `GHC.Core.Coercion.splitForAllCo_maybe`. We could theoretically apply the new naming convention here, but then we'd have to figure out how to disambiguate `Type`-splitting functions from `Coercion`-splitting functions. Ultimately, the `Coercion`-splitting functions aren't used nearly as much as the `Type`-splitting functions, so I decided to leave the former alone. This is purely refactoring and should cause no change in behavior. - - - - - 645444af by Ryan Scott at 2020-11-15T03:36:21-05:00 Use tcSplitForAllInvisTyVars (not tcSplitForAllTyVars) in more places The use of `tcSplitForAllTyVars` in `tcDataFamInstHeader` was the immediate cause of #18939, and replacing it with a new `tcSplitForAllInvisTyVars` function (which behaves like `tcSplitForAllTyVars` but only splits invisible type variables) fixes the issue. However, this led me to realize that _most_ uses of `tcSplitForAllTyVars` in GHC really ought to be `tcSplitForAllInvisTyVars` instead. While I was in town, I opted to replace most uses of `tcSplitForAllTys` with `tcSplitForAllTysInvis` to reduce the likelihood of such bugs in the future. I say "most uses" above since there is one notable place where we _do_ want to use `tcSplitForAllTyVars`: in `GHC.Tc.Validity.forAllTyErr`, which produces the "`Illegal polymorphic type`" error message if you try to use a higher-rank `forall` without having `RankNTypes` enabled. Here, we really do want to split all `forall`s, not just invisible ones, or we run the risk of giving an inaccurate error message in the newly added `T18939_Fail` test case. I debated at some length whether I wanted to name the new function `tcSplitForAllInvisTyVars` or `tcSplitForAllTyVarsInvisible`, but in the end, I decided that I liked the former better. For consistency's sake, I opted to rename the existing `splitPiTysInvisible` and `splitPiTysInvisibleN` functions to `splitInvisPiTys` and `splitPiTysInvisN`, respectively, so that they use the same naming convention. As a consequence, this ended up requiring a `haddock` submodule bump. Fixes #18939. - - - - - 8887102f by Moritz Angermann at 2020-11-15T03:36:56-05:00 AArch64/arm64 adjustments This addes the necessary logic to support aarch64 on elf, as well as aarch64 on mach-o, which Apple calls arm64. We change architecture name to AArch64, which is the official arm naming scheme. - - - - - fc644b1a by Ben Gamari at 2020-11-15T03:37:31-05:00 ghc-bin: Build with eventlogging by default We now have all sorts of great facilities using the eventlog which were previously unavailable without building a custom GHC. Fix this by linking with `-eventlog` by default. - - - - - 52114fa0 by Sylvain Henry at 2020-11-16T11:48:47+01:00 Add Addr# atomic primops (#17751) This reuses the codegen used for ByteArray#'s atomic primops. - - - - - 8150f654 by Sebastian Graf at 2020-11-18T23:38:40-05:00 PmCheck: Print types of uncovered patterns (#18932) In order to avoid confusion as in #18932, we display the type of the match variables in the non-exhaustiveness warning, e.g. ``` T18932.hs:14:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘g’: Patterns of type ‘T a’, ‘T a’, ‘T a’ not matched: (MkT2 _) (MkT1 _) (MkT1 _) (MkT2 _) (MkT1 _) (MkT2 _) (MkT2 _) (MkT2 _) (MkT1 _) (MkT2 _) (MkT2 _) (MkT2 _) ... | 14 | g (MkT1 x) (MkT1 _) (MkT1 _) = x | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` It also allows us to omit the type signature on wildcard matches which we previously showed in only some situations, particularly `-XEmptyCase`. Fixes #18932. - - - - - 165352a2 by Krzysztof Gogolewski at 2020-11-20T02:08:36-05:00 Export indexError from GHC.Ix (#18579) - - - - - b57845c3 by Kamil Dworakowski at 2020-11-20T02:09:16-05:00 Clarify interruptible FFI wrt masking state - - - - - 321d1bd8 by Sebastian Graf at 2020-11-20T02:09:51-05:00 Fix strictness signatures of `prefetchValue*#` primops Their strictness signatures said the primops are strict in their first argument, which is wrong: Handing it a thunk will prefetch the pointer to the thunk, but not evaluate it. Hence not strict. The regression test `T8256` actually tests for laziness in the first argument, so GHC apparently never exploited the strictness signature. See also https://gitlab.haskell.org/ghc/ghc/-/issues/8256#note_310867, where this came up. - - - - - 0aec78b6 by Sebastian Graf at 2020-11-20T02:09:51-05:00 Demand: Interleave usage and strictness demands (#18903) As outlined in #18903, interleaving usage and strictness demands not only means a more compact demand representation, but also allows us to express demands that we weren't easily able to express before. Call demands are *relative* in the sense that a call demand `Cn(cd)` on `g` says "`g` is called `n` times. *Whenever `g` is called*, the result is used according to `cd`". Example from #18903: ```hs h :: Int -> Int h m = let g :: Int -> (Int,Int) g 1 = (m, 0) g n = (2 * n, 2 `div` n) {-# NOINLINE g #-} in case m of 1 -> 0 2 -> snd (g m) _ -> uncurry (+) (g m) ``` Without the interleaved representation, we would just get `L` for the strictness demand on `g`. Now we are able to express that whenever `g` is called, its second component is used strictly in denoting `g` by `1C1(P(1P(U),SP(U)))`. This would allow Nested CPR to unbox the division, for example. Fixes #18903. While fixing regressions, I also discovered and fixed #18957. Metric Decrease: T13253-spj - - - - - 3a55b3a2 by Sebastian Graf at 2020-11-20T02:09:51-05:00 Update user's guide entry on demand analysis and worker/wrapper The demand signature notation has been undocumented for a long time. The only source to understand it, apart from reading the `Outputable` instance, has been an outdated wiki page. Since the previous commits have reworked the demand lattice, I took it as an opportunity to also write some documentation about notation. - - - - - fc963932 by Greg Steuck at 2020-11-20T02:10:31-05:00 Find hadrian location more reliably in cabal-install output Fix #18944 - - - - - 9f40cf6c by Ben Gamari at 2020-11-20T02:11:07-05:00 rts/linker: Align bssSize to page size when mapping symbol extras We place symbol_extras right after bss. We also need to ensure that symbol_extras can be mprotect'd independently from the rest of the image. To ensure this we round up the size of bss to a page boundary, thus ensuring that symbol_extras is also page-aligned. - - - - - b739c319 by Ben Gamari at 2020-11-20T02:11:43-05:00 gitlab-ci: Add usage message to ci.sh - - - - - 802e9180 by Ben Gamari at 2020-11-20T02:11:43-05:00 gitlab-ci: Add VERBOSE environment variable And change the make build system's default behavior to V=0, greatly reducing build log sizes. - - - - - 2a8a979c by Ben Gamari at 2020-11-21T01:13:26-05:00 users-guide: A bit of clean-up in profiling flag documentation - - - - - 56804e33 by Ben Gamari at 2020-11-21T01:13:26-05:00 testsuite: Refactor CountParserDeps - - - - - 53ad67ea by Ben Gamari at 2020-11-21T01:13:26-05:00 Introduce -fprof-callers flag This introducing a new compiler flag to provide a convenient way to introduce profiler cost-centers on all occurrences of the named identifier. Closes #18566. - - - - - ecfd0278 by Sylvain Henry at 2020-11-21T01:14:09-05:00 Move Plugins into HscEnv (#17957) Loaded plugins have nothing to do in DynFlags so this patch moves them into HscEnv (session state). "DynFlags plugins" become "Driver plugins" to still be able to register static plugins. Bump haddock submodule - - - - - 72f2257c by Sylvain Henry at 2020-11-21T01:14:09-05:00 Don't initialize plugins in the Core2Core pipeline Some plugins can be added via TH (cf addCorePlugin). Initialize them in the driver instead of in the Core2Core pipeline. - - - - - ddbeeb3c by Ryan Scott at 2020-11-21T01:14:44-05:00 Add regression test for #10504 This issue was fixed at some point between GHC 8.0 and 8.2. Let's add a regression test to ensure that it stays fixed. Fixes #10504. - - - - - a4a6dc2a by Ben Gamari at 2020-11-21T01:15:21-05:00 dwarf: Apply info table offset consistently Previously we failed to apply the info table offset to the aranges and DIEs, meaning that we often failed to unwind in gdb. For some reason this only seemed to manifest in the RTS's Cmm closures. Nevertheless, now we can unwind completely up to `main` - - - - - 69bfbc21 by Ben Gamari at 2020-11-21T01:15:56-05:00 hadrian: Disable stripping when debug information is enabled - - - - - 7e93ae8b by Ben Gamari at 2020-11-21T13:13:29-05:00 rts: Post ticky entry counts to the eventlog We currently only post the entry counters, not the other global counters as in my experience the former are more useful. We use the heap profiler's census period to decide when to dump. Also spruces up the documentation surrounding ticky-ticky a bit. - - - - - bc9c3916 by Ben Gamari at 2020-11-22T06:28:10-05:00 Implement -ddump-c-backend argument To dump output of the C backend. - - - - - 901bc220 by Ben Gamari at 2020-11-22T12:39:02-05:00 Bump time submodule to 1.11.1 Also bumps directory, Cabal, hpc, time, and unix submodules. Closes #18847. - - - - - 92c0afbf by Ben Gamari at 2020-11-22T12:39:38-05:00 hadrian: Dump STG when ticky is enabled This changes the "ticky" modifier to enable dumping of final STG as this is generally needed to make sense of the ticky profiles. - - - - - d23fef68 by Ben Gamari at 2020-11-22T12:39:38-05:00 hadrian: Introduce notion of flavour transformers This extends Hadrian's notion of "flavour", as described in #18942. - - - - - 179d0bec by Ben Gamari at 2020-11-22T12:39:38-05:00 hadrian: Add a viaLlvmBackend modifier Note that this also slightly changes the semantics of these flavours as we only use LLVM for >= stage1 builds. - - - - - d4d95e51 by Ben Gamari at 2020-11-22T12:39:38-05:00 hadrian: Add profiled_ghc and no_dynamic_ghc modifiers - - - - - 6815603f by Ben Gamari at 2020-11-22T12:39:38-05:00 hadrian: Drop redundant flavour definitions Drop the profiled, LLVM, and ThreadSanitizer flavour definitions as these can now be realized with flavour transformers. - - - - - f88f4339 by Ben Gamari at 2020-11-24T02:43:20-05:00 rts: Flush eventlog buffers from flushEventLog As noted in #18043, flushTrace failed flush anything beyond the writer. This means that a significant amount of data sitting in capability-local event buffers may never get flushed, despite the users' pleads for us to flush. Fix this by making flushEventLog flush all of the event buffers before flushing the writer. Fixes #18043. - - - - - 7c03cc50 by Ben Gamari at 2020-11-24T02:43:55-05:00 gitlab-ci: Run LLVM job on appropriately-labelled MRs Namely, those marked with the ~"LLVM backend" label - - - - - 9b95d815 by Ben Gamari at 2020-11-24T02:43:55-05:00 gitlab-ci: Run LLVM builds on Debian 10 The current Debian 9 image doesn't provide LLVM 7. - - - - - 2ed3e6c0 by Ben Gamari at 2020-11-24T02:43:55-05:00 CmmToLlvm: Declare signature for memcmp Otherwise `opt` fails with: error: use of undefined value '@memcmp$def' - - - - - be5d74ca by Moritz Angermann at 2020-11-26T16:00:32-05:00 [Sized Cmm] properly retain sizes. This replaces all Word<N> = W<N># Word# and Int<N> = I<N># Int# with Word<N> = W<N># Word<N># and Int<N> = I<N># Int<N>#, thus providing us with properly sized primitives in the codegenerator instead of pretending they are all full machine words. This came up when implementing darwinpcs for arm64. The darwinpcs reqires us to pack function argugments in excess of registers on the stack. While most procedure call standards (pcs) assume arguments are just passed in 8 byte slots; and thus the caller does not know the exact signature to make the call, darwinpcs requires us to adhere to the prototype, and thus have the correct sizes. If we specify CInt in the FFI call, it should correspond to the C int, and not just be Word sized, when it's only half the size. This does change the expected output of T16402 but the new result is no less correct as it eliminates the narrowing (instead of the `and` as was previously done). Bumps the array, bytestring, text, and binary submodules. Co-Authored-By: Ben Gamari <ben at well-typed.com> Metric Increase: T13701 T14697 - - - - - a84e53f9 by Andreas Klebinger at 2020-11-26T16:00:32-05:00 RTS: Fix failed inlining of copy_tag. On windows using gcc-10 gcc failed to inline copy_tag into evacuate. To fix this we now set the always_inline attribute for the various copy* functions in Evac.c. The main motivation here is not the overhead of the function call, but rather that this allows the code to "specialize" for the size of the closure we copy which is often known at compile time. An earlier commit also tried to avoid evacuate_large inlining. But didn't quite succeed. So I also marked evacuate_large as noinline. Fixes #12416 - - - - - cdbd16f5 by Sylvain Henry at 2020-11-26T16:00:33-05:00 Fix toArgRep to support 64-bit reps on all systems [This is @Ericson2314 writing a commit message for @hsyl20's patch.] (Progress towards #11953, #17377, #17375) `Int64Rep` and `Word64Rep` are currently broken on 64-bit systems. This is because they should use "native arg rep" but instead use "large arg rep" as they do on 32-bit systems, which is either a non-concept or a 128-bit rep depending on one's vantage point. Now, these reps currently aren't used during 64-bit compilation, so the brokenness isn't observed, but I don't think that constitutes reasons not to fix it. Firstly, the linked issues there is a clearly expressed desire to use explicit-bitwidth constructs in more places. Secondly, per [1], there are other bugs that *do* manifest from not threading explicit-bitwidth information all the way through the compilation pipeline. One can therefore view this as one piece of the larger effort to do that, improve ergnomics, and squash remaining bugs. Also, this is needed for !3658. I could just merge this as part of that, but I'm keen on merging fixes "as they are ready" so the fixes that aren't ready are isolated and easier to debug. [1]: https://mail.haskell.org/pipermail/ghc-devs/2020-October/019332.html - - - - - a9378e69 by Tim Barnes at 2020-11-26T16:00:34-05:00 Set dynamic users-guide TOC spacing (fixes #18554) - - - - - 86a59d93 by Ben Gamari at 2020-11-26T16:00:34-05:00 rts: Use RTS_LIKELY in CHECK Most compilers probably already infer that `barf` diverges but it nevertheless doesn't hurt to be explicit. - - - - - 5757e82b by Matthew Pickering at 2020-11-26T16:00:35-05:00 Remove special case for GHC.ByteCode.Instr This was added in https://github.com/nomeata/ghc-heap-view/commit/34935206e51b9c86902481d84d2f368a6fd93423 GHC.ByteCode.Instr.BreakInfo no longer exists so the special case is dead code. Any check like this can be easily dealt with in client code. - - - - - d9c8b5b4 by Matthew Pickering at 2020-11-26T16:00:35-05:00 Split Up getClosureDataFromHeapRep Motivation 1. Don't enforce the repeated decoding of an info table, when the client can cache it (ghc-debug) 2. Allow the constructor information decoding to be overridden, this casues segfaults in ghc-debug - - - - - 3e3555cc by Andreas Klebinger at 2020-11-26T16:00:35-05:00 RegAlloc: Add missing raPlatformfield to RegAllocStatsSpill Fixes #18994 Co-Author: Benjamin Maurer <maurer.benjamin at gmail.com> - - - - - a1a75aa9 by Ben Gamari at 2020-11-27T06:20:41-05:00 rts: Allocate MBlocks with MAP_TOP_DOWN on Windows As noted in #18991, we would previously allocate heap in low memory. Due to this the linker, which typically *needs* low memory, would end up competing with the heap. In longer builds we end up running out of low memory entirely, leading to linking failures. - - - - - 75fc1ed5 by Sylvain Henry at 2020-11-28T15:40:23-05:00 Hadrian: fix detection of ghc-pkg for cross-compilers - - - - - 7cb5df96 by Sylvain Henry at 2020-11-28T15:40:23-05:00 hadrian: fix ghc-pkg uses (#17601) Make sure ghc-pkg doesn't read the compiler "settings" file by passing --no-user-package-db. - - - - - e3fd4226 by Ben Gamari at 2020-11-28T15:40:23-05:00 gitlab-ci: Introduce a nightly cross-compilation job This adds a job to test cross-compilation from x86-64 to AArch64 with Hadrian. Fixes #18234 - - - - - 698d3d96 by Ben Gamari at 2020-11-28T15:41:00-05:00 gitlab-ci: Only deploy GitLab Pages in ghc/ghc> The deployments are quite large and yet are currently only served for the ghc/ghc> project. - - - - - 625726f9 by David Eichmann at 2020-11-28T15:41:37-05:00 ghc-heap: partial TSO/STACK decoding Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 22ea9c29 by Andreas Klebinger at 2020-11-28T15:42:13-05:00 Small optimization to CmmSink. Inside `regsUsedIn` we can avoid some thunks by specializing the recursion. In particular we avoid the thunk for `(f e z)` in the MachOp/Load branches, where we know this will evaluate to z. Reduces allocations for T3294 by ~1%. - - - - - bba42c62 by John Ericson at 2020-11-28T15:42:49-05:00 Make primop handler indentation more consistent - - - - - c82bc8e9 by John Ericson at 2020-11-28T15:42:49-05:00 Cleanup some primop constructor names Harmonize the internal (big sum type) names of the native vs fixed-sized number primops a bit. (Mainly by renaming the former.) No user-facing names are changed. - - - - - ae14f160 by Ben Gamari at 2020-11-28T15:43:25-05:00 testsuite: Mark T14702 as fragile on Windows Due to #18953. - - - - - 1bc104b0 by Ben Gamari at 2020-11-29T15:33:18-05:00 withTimings: Emit allocations counter This will allow us to back out the allocations per compiler pass from the eventlog. Note that we dump the allocation counter rather than the difference since this will allow us to determine how much work is done *between* `withTiming` blocks. - - - - - e992ea84 by GHC GitLab CI at 2020-11-29T15:33:54-05:00 ThreadPaused: Don't zero slop until free vars are pushed When threadPaused blackholes a thunk it calls `OVERWRITING_CLOSURE` to zero the slop for the benefit of the sanity checker. Previously this was done *before* pushing the thunk's free variables to the update remembered set. Consequently we would pull zero'd pointers to the update remembered set. - - - - - e82cd140 by GHC GitLab CI at 2020-11-29T15:33:54-05:00 nonmoving: Fix regression from TSAN work The TSAN rework (specifically aad1f803) introduced a subtle regression in GC.c, swapping `g0` in place of `gen`. Whoops! Fixes #18997. - - - - - 35a5207e by GHC GitLab CI at 2020-11-29T15:33:54-05:00 rts/Messages: Add missing write barrier in THROWTO message update After a THROWTO message has been handle the message closure is overwritten by a NULL message. We must ensure that the original closure's pointers continue to be visible to the nonmoving GC. - - - - - 0120829f by GHC GitLab CI at 2020-11-29T15:33:54-05:00 nonmoving: Add missing write barrier in shrinkSmallByteArray - - - - - 8a4d8fb6 by GHC GitLab CI at 2020-11-29T15:33:54-05:00 Updates: Don't zero slop until closure has been pushed Ensure that the the free variables have been pushed to the update remembered set before we zero the slop. - - - - - 2793cfdc by GHC GitLab CI at 2020-11-29T15:33:54-05:00 OSThreads: Fix error code checking pthread_join returns its error code and apparently doesn't set errno. - - - - - e391a16f by GHC GitLab CI at 2020-11-29T15:33:54-05:00 nonmoving: Don't join to mark_thread on shutdown The mark thread is not joinable as we detach from it on creation. - - - - - 60d088ab by Ben Gamari at 2020-11-29T15:33:54-05:00 nonmoving: Add reference to Ueno 2016 - - - - - 3aa60362 by GHC GitLab CI at 2020-11-29T15:33:54-05:00 nonmoving: Ensure that evacuated large objects are marked See Note [Non-moving GC: Marking evacuated objects]. - - - - - 8d304a99 by Ben Gamari at 2020-11-30T10:15:22-05:00 rts/m32: Refactor handling of allocator seeding Previously, in an attempt to reduce fragmentation, each new allocator would map a region of M32_MAX_PAGES fresh pages to seed itself. However, this ends up being extremely wasteful since it turns out that we often use fewer than this. Consequently, these pages end up getting freed which, ends up fragmenting our address space more than than we would have if we had naively allocated pages on-demand. Here we refactor m32 to avoid this waste while achieving the fragmentation mitigation previously desired. In particular, we move all page allocation into the global m32_alloc_page, which will pull a page from the free page pool. If the free page pool is empty we then refill it by allocating a region of M32_MAP_PAGES and adding them to the pool. Furthermore, we do away with the initial seeding entirely. That is, the allocator starts with no active pages: pages are rather allocated on an as-needed basis. On the whole this ends up being a pleasingly simple change, simultaneously making m32 more efficient, more robust, and simpler. Fixes #18980. - - - - - b6629289 by Ben Gamari at 2020-11-30T10:15:58-05:00 rts: Use CHECK instead of assert Use the GHC wrappers instead of <assert.h>. - - - - - 9f4efa6a by Ben Gamari at 2020-11-30T10:15:58-05:00 rts/linker: Replace some ASSERTs with CHECK In the past some people have confused ASSERT, which is for checking internal invariants, which CHECK, which should be used when checking things that might fail due to bad input (and therefore should be enabled even in the release compiler). Change some of these cases in the linker to use CHECK. - - - - - 0f8a4655 by Ryan Scott at 2020-11-30T10:16:34-05:00 Allow deploy:pages job to fail See #18973. - - - - - 49ebe369 by chessai at 2020-11-30T19:47:40-05:00 Optimisations in Data.Foldable (T17867) This PR concerns the following functions from `Data.Foldable`: * minimum * maximum * sum * product * minimumBy * maximumBy - Default implementations of these functions now use `foldl'` or `foldMap'`. - All have been marked with INLINEABLE to make room for further optimisations. - - - - - 4d79ef65 by chessai at 2020-11-30T19:47:40-05:00 Apply suggestion to libraries/base/Data/Foldable.hs - - - - - 6af074ce by chessai at 2020-11-30T19:47:40-05:00 Apply suggestion to libraries/base/Data/Foldable.hs - - - - - ab334262 by Viktor Dukhovni at 2020-11-30T19:48:17-05:00 dirty MVAR after mutating TSO queue head While the original head and tail of the TSO queue may be in the same generation as the MVAR, interior elements of the queue could be younger after a GC run and may then be exposed by putMVar operation that updates the queue head. Resolves #18919 - - - - - 5eb163f3 by Ben Gamari at 2020-11-30T19:48:53-05:00 rts/linker: Don't allow shared libraries to be loaded multiple times - - - - - 490aa14d by Ben Gamari at 2020-11-30T19:48:53-05:00 rts/linker: Initialise CCSs from native shared objects - - - - - 6ac3db5f by Ben Gamari at 2020-11-30T19:48:53-05:00 rts/linker: Move shared library loading logic into Elf.c - - - - - b6698d73 by GHC GitLab CI at 2020-11-30T19:48:53-05:00 rts/linker: Don't declare dynamic objects with image_mapped This previously resulted in warnings due to spurious unmap failures. - - - - - b94a65af by jneira at 2020-11-30T19:49:31-05:00 Include tried paths in findToolDir error - - - - - 72a87fbc by Richard Eisenberg at 2020-12-01T19:57:41-05:00 Move core flattening algorithm to Core.Unify This sets the stage for a later change, where this algorithm will be needed from GHC.Core.InstEnv. This commit also splits GHC.Core.Map into GHC.Core.Map.Type and GHC.Core.Map.Expr, in order to avoid module import cycles with GHC.Core. - - - - - 0dd45d0a by Richard Eisenberg at 2020-12-01T19:57:41-05:00 Bump the # of commits searched for perf baseline The previous value of 75 meant that a feature branch with more than 75 commits would get spurious CI passes. This affects #18692, but does not fix that ticket, because if a baseline cannot be found, we should fail, not succeed. - - - - - 8bb52d91 by Richard Eisenberg at 2020-12-01T19:57:41-05:00 Remove flattening variables This patch redesigns the flattener to simplify type family applications directly instead of using flattening meta-variables and skolems. The key new innovation is the CanEqLHS type and the new CEqCan constraint (Ct). A CanEqLHS is either a type variable or exactly-saturated type family application; either can now be rewritten using a CEqCan constraint in the inert set. Because the flattener no longer reduces all type family applications to variables, there was some performance degradation if a lengthy type family application is now flattened over and over (not making progress). To compensate, this patch contains some extra optimizations in the flattener, leading to a number of performance improvements. Close #18875. Close #18910. There are many extra parts of the compiler that had to be affected in writing this patch: * The family-application cache (formerly the flat-cache) sometimes stores coercions built from Given inerts. When these inerts get kicked out, we must kick out from the cache as well. (This was, I believe, true previously, but somehow never caused trouble.) Kicking out from the cache requires adding a filterTM function to TrieMap. * This patch obviates the need to distinguish "blocking" coercion holes from non-blocking ones (which, previously, arose from CFunEqCans). There is thus some simplification around coercion holes. * Extra commentary throughout parts of the code I read through, to preserve the knowledge I gained while working. * A change in the pure unifier around unifying skolems with other types. Unifying a skolem now leads to SurelyApart, not MaybeApart, as documented in Note [Binding when looking up instances] in GHC.Core.InstEnv. * Some more use of MCoercion where appropriate. * Previously, class-instance lookup automatically noticed that e.g. C Int was a "unifier" to a target [W] C (F Bool), because the F Bool was flattened to a variable. Now, a little more care must be taken around checking for unifying instances. * Previously, tcSplitTyConApp_maybe would split (Eq a => a). This is silly, because (=>) is not a tycon in Haskell. Fixed now, but there are some knock-on changes in e.g. TrieMap code and in the canonicaliser. * New function anyFreeVarsOf{Type,Co} to check whether a free variable satisfies a certain predicate. * Type synonyms now remember whether or not they are "forgetful"; a forgetful synonym drops at least one argument. This is useful when flattening; see flattenView. * The pattern-match completeness checker invokes the solver. This invocation might need to look through newtypes when checking representational equality. Thus, the desugarer needs to keep track of the in-scope variables to know what newtype constructors are in scope. I bet this bug was around before but never noticed. * Extra-constraints wildcards are no longer simplified before printing. See Note [Do not simplify ConstraintHoles] in GHC.Tc.Solver. * Whether or not there are Given equalities has become slightly subtler. See the new HasGivenEqs datatype. * Note [Type variable cycles in Givens] in GHC.Tc.Solver.Canonical explains a significant new wrinkle in the new approach. * See Note [What might match later?] in GHC.Tc.Solver.Interact, which explains the fix to #18910. * The inert_count field of InertCans wasn't actually used, so I removed it. Though I (Richard) did the implementation, Simon PJ was very involved in design and review. This updates the Haddock submodule to avoid #18932 by adding a type signature. ------------------------- Metric Decrease: T12227 T5030 T9872a T9872b T9872c Metric Increase: T9872d ------------------------- - - - - - d66660ba by Richard Eisenberg at 2020-12-01T19:57:41-05:00 Rename the flattener to become the rewriter. Now that flattening doesn't produce flattening variables, it's not really flattening anything: it's rewriting. This change also means that the rewriter can no longer be confused the core flattener (in GHC.Core.Unify), which is sometimes used during type-checking. - - - - - add0aeae by Ben Gamari at 2020-12-01T19:58:17-05:00 rts: Introduce mmapAnonForLinker Previously most of the uses of mmapForLinker were mapping anonymous memory, resulting in a great deal of unnecessary repetition. Factor this out into a new helper. Also fixes a few places where error checking was missing or suboptimal. - - - - - 97d71646 by Ben Gamari at 2020-12-01T19:58:17-05:00 rts/linker: Introduce munmapForLinker Consolidates munmap calls to ensure consistent error handling. - - - - - d8872af0 by Ben Gamari at 2020-12-01T19:58:18-05:00 rts/Linker: Introduce Windows implementations for mmapForLinker, et al. - - - - - c35d0e03 by Ben Gamari at 2020-12-01T19:58:18-05:00 rts/m32: Introduce NEEDS_M32 macro Instead of relying on RTS_LINKER_USE_MMAP - - - - - 41c64eb5 by Ben Gamari at 2020-12-01T19:58:18-05:00 rts/linker: Use m32 to allocate symbol extras in PEi386 - - - - - e0b08c5f by Ben Gamari at 2020-12-03T13:01:47-05:00 gitlab-ci: Fix copy-paste error Also be more consistent in quoting. - - - - - 33ec3a06 by Ben Gamari at 2020-12-03T23:11:31-05:00 gitlab-ci: Run linters through ci.sh Ensuring that the right toolchain is used. - - - - - 4a437bc1 by Shayne Fletcher at 2020-12-05T09:06:38-05:00 Fix bad span calculations of post qualified imports - - - - - 8fac4b93 by Ben Gamari at 2020-12-05T09:07:13-05:00 testsuite: Add a test for #18923 - - - - - 62ed6957 by Simon Peyton Jones at 2020-12-08T15:31:41-05:00 Fix kind inference for data types. Again. This patch fixes several aspects of kind inference for data type declarations, especially data /instance/ declarations Specifically 1. In kcConDecls/kcConDecl make it clear that the tc_res_kind argument is only used in the H98 case; and in that case there is no result kind signature; and hence no need for the disgusting splitPiTys in kcConDecls (now thankfully gone). The GADT case is a bit different to before, and much nicer. This is what fixes #18891. See Note [kcConDecls: kind-checking data type decls] 2. Do not look at the constructor decls of a data/newtype instance in tcDataFamInstanceHeader. See GHC.Tc.TyCl.Instance Note [Kind inference for data family instances]. This was a new realisation that arose when doing (1) This causes a few knock-on effects in the tests suite, because we require more information than before in the instance /header/. New user-manual material about this in "Kind inference in data type declarations" and "Kind inference for data/newtype instance declarations". 3. Minor improvement in kcTyClDecl, combining GADT and H98 cases 4. Fix #14111 and #8707 by allowing the header of a data instance to affect kind inferece for the the data constructor signatures; as described at length in Note [GADT return types] in GHC.Tc.TyCl This led to a modest refactoring of the arguments (and argument order) of tcConDecl/tcConDecls. 5. Fix #19000 by inverting the sense of the test in new_locs in GHC.Tc.Solver.Canonical.canDecomposableTyConAppOK. - - - - - 0abe3ddf by Adam Sandberg Ericsson at 2020-12-08T15:32:19-05:00 hadrian: build the _l and _thr_l rts flavours in the develN flavours The ghc binary requires the eventlog rts since fc644b1a643128041cfec25db84e417851e28bab - - - - - 51e3bb6d by Andreas Klebinger at 2020-12-08T22:43:21-05:00 CodeGen: Make folds User/DefinerOfRegs INLINEABLE. Reduces allocation for the test case I was looking at by about 1.2%. Mostly from avoiding allocation of some folding functions which turn into let-no-escape bindings which just reuse their environment instead. We also force inlining in a few key places in CmmSink which helps a bit more. - - - - - 69ae10c3 by Andreas Klebinger at 2020-12-08T22:43:21-05:00 CmmSink: Force inlining of foldRegsDefd Helps avoid allocating the folding function. Improves perf for T3294 by about 1%. - - - - - 6e3da800 by Andreas Klebinger at 2020-12-08T22:43:21-05:00 Cmm: Make a few types and utility function slightly stricter. About 0.6% reduction in allocations for the code I was looking at. Not a huge difference but no need to throw away performance. - - - - - aef44d7f by Andreas Klebinger at 2020-12-08T22:43:21-05:00 Cmm.Sink: Optimize retaining of assignments, live sets. Sinking requires us to track live local regs after each cmm statement. We used to do this via "Set LocalReg". However we can replace this with a solution based on IntSet which is overall more efficient without losing much. The thing we lose is width of the variables, which isn't used by the sinking pass anyway. I also reworked how we keep assignments to regs mentioned in skipped assignments. I put the details into Note [Keeping assignemnts mentioned in skipped RHSs]. The gist of it is instead of keeping track of it via the use count which is a `IntMap Int` we now use the live regs set (IntSet) which is quite a bit faster. I think it also matches the semantics a lot better. The skipped (not discarded) assignment does in fact keep the regs on it's rhs alive so keeping track of this in the live set seems like the clearer solution as well. Improves allocations for T3294 by yet another 1%. - - - - - 59f2249b by Andreas Klebinger at 2020-12-08T22:43:21-05:00 GHC.Cmm.Opt: Be stricter in results. Optimization either returns Nothing if nothing is to be done or `Just <cmmExpr>` otherwise. There is no point in being lazy in `cmmExpr`. We usually inspect this element so the thunk gets forced not long after. We might eliminate it as dead code once in a blue moon but that's not a case worth optimizing for. Overall the impact of this is rather low. As Cmm.Opt doesn't allocate much (compared to the rest of GHC) to begin with. - - - - - 54b88eac by Andreas Klebinger at 2020-12-08T22:43:57-05:00 Bump time submodule. This should fix #19002. - - - - - 35e7b0c6 by Kirill Elagin at 2020-12-10T01:45:54-05:00 doc: Clarify the default for -fomit-yields “Yield points enabled” is confusing (and probably wrong? I am not 100% sure what it means). Change it to a simple “on”. Undo this change from 2c23fff2e03e77187dc4d01f325f5f43a0e7cad2. - - - - - 3551c554 by Kirill Elagin at 2020-12-10T01:45:54-05:00 doc: Extra-clarify -fomit-yields Be more clear on what this optimisation being on by default means in terms of yields. - - - - - 6484f0d7 by Sergei Trofimovich at 2020-12-10T01:46:33-05:00 rts/linker/Elf.c: add missing <dlfcn.h> include (musl support) The change fixes build failure on musl: ``` rts/linker/Elf.c:2031:3: error: warning: implicit declaration of function 'dlclose'; did you mean 'close'? [-Wimplicit-function-declaration] 2031 | dlclose(nc->dlopen_handle); | ^~~~~~~ | close ``` Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - ab24ed9b by Ben Gamari at 2020-12-11T03:55:51-05:00 users guide: Fix syntax errors Fixes errors introduced by 3a55b3a2574f913d046f3a6f82db48d7f6df32e3. - - - - - d3a24d31 by Ben Gamari at 2020-12-11T03:55:51-05:00 users guide: Describe GC lifecycle events Every time I am asked about how to interpret these events I need to figure it out from scratch. It's well past time that the users guide properly documents these. - - - - - 741309b9 by Ben Gamari at 2020-12-11T03:56:27-05:00 gitlab-ci: Fix incorrect Docker image for nightly cross job Also refactor the job definition to eliminate the bug by construction. - - - - - 19703bc8 by Ben Gamari at 2020-12-11T03:56:27-05:00 gitlab-ci: Fix name of flavour in ThreadSanitizer job It looks like I neglected to update this after introduce flavour transformers. - - - - - 381eb660 by Sylvain Henry at 2020-12-11T12:57:35-05:00 Display FFI labels (fix #18539) - - - - - 4548d1f8 by Aaron Allen at 2020-12-11T12:58:14-05:00 Elide extraneous messages for :doc command (#15784) Do not print `<has no documentation>` alongside a valid doc. Additionally, if two matching symbols lack documentation then the message will only be printed once. Hence, `<has no documentation>` will be printed at most once and only if all matching symbols are lacking docs. - - - - - 5eba91b6 by Aaron Allen at 2020-12-11T12:58:14-05:00 Add :doc test case for duplicate record fields Tests that the output of the `:doc` command is correct for duplicate record fields defined using -XDuplicateRecordFields. - - - - - 5feb9b2d by Ryan Scott at 2020-12-11T22:39:29-05:00 Delete outdated Note [Kind-checking tyvar binders for associated types] This Note has severely bitrotted, as it has no references anywhere in the codebase, and none of the functions that it mentions exist anymore. Let's just delete this. While I was in town, I deleted some outdated comments from `checkFamPatBinders` of a similar caliber. Fixes #19008. [ci skip] - - - - - f9f9f030 by Sylvain Henry at 2020-12-11T22:40:08-05:00 Arrows: correctly query arrow methods (#17423) Consider the following code: proc (C x y) -> ... Before this patch, the evidence binding for the Arrow dictionary was attached to the C pattern: proc (C x y) { $dArrow = ... } -> ... But then when we desugar this, we use arrow operations ("arr", ">>>"...) specialised for this arrow: let arr_xy = arr $dArrow -- <-- Not in scope! ... in arr_xy (\(C x y) { $dArrow = ... } -> ...) This patch allows arrow operations to be type-checked before the proc itself, avoiding this issue. Fix #17423 - - - - - aaa8f00f by Sylvain Henry at 2020-12-11T22:40:48-05:00 Validate script: fix configure command when using stack - - - - - b4a929a1 by Sylvain Henry at 2020-12-11T22:41:30-05:00 Hadrian: fix libffi tarball parsing Fix parsing of "libffi-3.3.tar.gz". NB: switch to a newer libffi isn't done in this patch - - - - - 690c8946 by Sylvain Henry at 2020-12-11T22:42:09-05:00 Parser: move parser utils into their own module Move code unrelated to runtime evaluation out of GHC.Runtime.Eval - - - - - 76be0e32 by Sylvain Henry at 2020-12-11T22:42:48-05:00 Move SizedSeq into ghc-boot - - - - - 3a16d764 by Sylvain Henry at 2020-12-11T22:42:48-05:00 ghci: don't compile unneeded modules - - - - - 2895fa60 by Sylvain Henry at 2020-12-11T22:42:48-05:00 ghci: reuse Arch from ghc-boot - - - - - 480a38d4 by Sylvain Henry at 2020-12-11T22:43:30-05:00 rts: don't use siginterrupt (#19019) - - - - - 4af6126d by Sylvain Henry at 2020-12-11T22:44:11-05:00 Use static array in zeroCount - - - - - 5bd71bfd by Sebastian Graf at 2020-12-12T04:45:09-05:00 DmdAnal: Annotate top-level function bindings with demands (#18894) It's useful to annotate a non-exported top-level function like `g` in ```hs module Lib (h) where g :: Int -> Int -> (Int,Int) g m 1 = (m, 0) g m n = (2 * m, 2 `div` n) {-# NOINLINE g #-} h :: Int -> Int h 1 = 0 h m | odd m = snd (g m 2) | otherwise = uncurry (+) (g 2 m) ``` with its demand `UCU(CS(P(1P(U),SP(U))`, which tells us that whenever `g` was called, the second component of the returned pair was evaluated strictly. Since #18903 we do so for local functions, where we can see all calls. For top-level functions, we can assume that all *exported* functions are demanded according to `topDmd` and thus get sound demands for non-exported top-level functions. The demand on `g` is crucial information for Nested CPR, which may the go on and unbox `g` for the second pair component. That is true even if that pair component may diverge, as is the case for the call site `g 13 0`, which throws a div-by-zero exception. In `T18894b`, you can even see the new demand annotation enabling us to eta-expand a function that we wouldn't be able to eta-expand without Call Arity. We only track bindings of function type in order not to risk huge compile-time regressions, see `isInterestingTopLevelFn`. There was a CoreLint check that rejected strict demand annotations on recursive or top-level bindings, which seems completely unjustified. All the cases I investigated were fine, so I removed it. Fixes #18894. - - - - - 3aae036e by Sebastian Graf at 2020-12-12T04:45:09-05:00 Demand: Simplify `CU(U)` to `U` (#19005) Both sub-demands encode the same information. This is a trivial change and already affects a few regression tests (e.g. `T5075`), so no separate regression test is necessary. - - - - - c6477639 by Adam Sandberg Ericsson at 2020-12-12T04:45:48-05:00 hadrian: correctly copy the docs dir into the bindist #18669 - - - - - e033dd05 by Adam Sandberg Ericsson at 2020-12-12T10:52:19+00:00 mkDocs: support hadrian bindists #18973 - - - - - 78580ba3 by John Ericson at 2020-12-13T07:14:50-05:00 Remove old .travis.yml - - - - - c696bb2f by Cale Gibbard at 2020-12-14T13:37:09-05:00 Implement type applications in patterns The haddock submodule is also updated so that it understands the changes to patterns. - - - - - 7e9debd4 by Ben Gamari at 2020-12-14T13:37:09-05:00 Optimise nullary type constructor usage During the compilation of programs GHC very frequently deals with the `Type` type, which is a synonym of `TYPE 'LiftedRep`. This patch teaches GHC to avoid expanding the `Type` synonym (and other nullary type synonyms) during type comparisons, saving a good amount of work. This optimisation is described in `Note [Comparing nullary type synonyms]`. To maximize the impact of this optimisation, we introduce a few special-cases to reduce `TYPE 'LiftedRep` to `Type`. See `Note [Prefer Type over TYPE 'LiftedPtrRep]`. Closes #17958. Metric Decrease: T18698b T1969 T12227 T12545 T12707 T14683 T3064 T5631 T5642 T9020 T9630 T9872a T13035 haddock.Cabal haddock.base - - - - - 92377c27 by Ben Gamari at 2020-12-14T13:41:58-05:00 Revert "Optimise nullary type constructor usage" This was inadvertently merged. This reverts commit 7e9debd4ceb068effe8ac81892d2cabcb8f55850. - - - - - d0e8c10d by Sylvain Henry at 2020-12-14T19:45:13+01:00 Move Unit related fields from DynFlags to HscEnv The unit database cache, the home unit and the unit state were stored in DynFlags while they ought to be stored in the compiler session state (HscEnv). This patch fixes this. It introduces a new UnitEnv type that should be used in the future to handle separate unit environments (especially host vs target units). Related to #17957 Bump haddock submodule - - - - - af855ac1 by Andreas Klebinger at 2020-12-14T15:22:13-05:00 Optimize dumping of consecutive whitespace. The naive way of putting out n characters of indent would be something like `hPutStr hdl (replicate n ' ')`. However this is quite inefficient as we allocate an absurd number of strings consisting of simply spaces as we don't cache them. To improve on this we now track if we can simply write ascii spaces via hPutBuf instead. This is the case when running with -ddump-to-file where we force the encoding to be UTF8. This avoids both the cost of going through encoding as well as avoiding allocation churn from all the white space. Instead we simply use hPutBuf on a preallocated unlifted string. When dumping stg like this: > nofib/spectral/simple/Main.hs -fforce-recomp -ddump-stg-final -ddump-to-file -c +RTS -s Allocations went from 1,778 MB to 1,702MB. About a 4% reduction of allocation! I did not measure the difference in runtime but expect it to be similar. Bumps the haddock submodule since the interface of GHC's Pretty slightly changed. ------------------------- Metric Decrease: T12227 ------------------------- - - - - - dad87210 by Ben Gamari at 2020-12-14T15:22:29-05:00 Optimise nullary type constructor usage During the compilation of programs GHC very frequently deals with the `Type` type, which is a synonym of `TYPE 'LiftedRep`. This patch teaches GHC to avoid expanding the `Type` synonym (and other nullary type synonyms) during type comparisons, saving a good amount of work. This optimisation is described in `Note [Comparing nullary type synonyms]`. To maximize the impact of this optimisation, we introduce a few special-cases to reduce `TYPE 'LiftedRep` to `Type`. See `Note [Prefer Type over TYPE 'LiftedPtrRep]`. Closes #17958. Metric Decrease: T18698b T1969 T12227 T12545 T12707 T14683 T3064 T5631 T5642 T9020 T9630 T9872a T13035 haddock.Cabal haddock.base - - - - - 6c2eb223 by Andrew Martin at 2020-12-14T18:48:51-05:00 Implement BoxedRep proposal This implements the BoxedRep proposal, refacoring the `RuntimeRep` hierarchy from: ```haskell data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ... ``` to ```haskell data RuntimeRep = BoxedRep Levity | ... data Levity = Lifted | Unlifted ``` Closes #17526. - - - - - 3ee696cc by Sebastian Graf at 2020-12-15T10:53:31-05:00 Add regression test for #19053 - - - - - 535dae66 by Ben Gamari at 2020-12-15T10:53:58-05:00 testsuite: Mark divbyzero, derefnull as fragile Due to #18548. - - - - - 331f5568 by Ben Gamari at 2020-12-15T11:21:06-05:00 Revert "Implement BoxedRep proposal" This was inadvertently merged. This reverts commit 6c2eb2232b39ff4720fda0a4a009fb6afbc9dcea. - - - - - 50fae07d by Ben Gamari at 2020-12-15T15:15:16-05:00 Roll-back broken haddock commit Updates haddock submodule to revert a commit that does not build. - - - - - e9b18a75 by Ben Gamari at 2020-12-15T15:55:38-05:00 Revert haddock submodule yet again - - - - - b58cb63a by GHC GitLab CI at 2020-12-16T03:46:31+00:00 Bump haddock submodule To adapt haddock for the nullary tyconapp optimisation patch. - - - - - 80df2edd by David Eichmann at 2020-12-17T13:55:21-05:00 User guide minor typo [ci skip] - - - - - 09f28390 by nineonine at 2020-12-17T13:55:59-05:00 Force module recompilation if '*' prefix was used to load modules in ghci (#8042) Usually pre-compiled code is preferred to be loaded in ghci if available, which means that if we try to load module with '*' prefix and compilation artifacts are available on disc (.o and .hi files) or the source code was untouched, the driver would think no recompilation is required. Therefore, we need to force recompilation so that desired byte-code is generated and loaded. Forcing in this case should be ok, since this is what happens for interpreted code anyways when reloading modules. - - - - - b1178cbc by Ryan Scott at 2020-12-17T13:56:35-05:00 Reject dodgy scoping in associated family instance RHSes Commit e63518f5d6a93be111f9108c0990a1162f88d615 tried to push all of the logic of detecting out-of-scope type variables on the RHSes of associated type family instances to `GHC.Tc.Validity` by deleting a similar check in the renamer. Unfortunately, this commit went a little too far, as there are some corner cases that `GHC.Tc.Validity` doesn't detect. Consider this example: ```hs class C a where data D a instance forall a. C Int where data instance D Int = MkD a ``` If this program isn't rejected by the time it reaches the typechecker, then GHC will believe the `a` in `MkD a` is existentially quantified and accept it. This is almost surely not what the user wants! The simplest way to reject programs like this is to restore the old validity check in the renamer (search for `improperly_scoped` in `rnFamEqn`). Note that this is technically a breaking change, since the program in the `polykinds/T9574` test case (which previously compiled) will now be rejected: ```hs instance Funct ('KProxy :: KProxy o) where type Codomain 'KProxy = NatTr (Proxy :: o -> *) ``` This is because the `o` on the RHS will now be rejected for being out of scope. Luckily, this is simple to repair: ```hs instance Funct ('KProxy :: KProxy o) where type Codomain ('KProxy @o) = NatTr (Proxy :: o -> *) ``` All of the discussion is now a part of the revamped `Note [Renaming associated types]` in `GHC.Rename.Module`. A different design would be to make associated type family instances have completely separate scoping from the parent instance declaration, much like how associated type family default declarations work today. See the discussion beginning at https://gitlab.haskell.org/ghc/ghc/-/issues/18021#note_265729 for more on this point. This, however, would break even more programs that are accepted today and likely warrants a GHC proposal before going forward. In the meantime, this patch fixes the issue described in #18021 in the least invasive way possible. There are programs that are accepted today that will no longer be accepted after this patch, but they are arguably pathological programs, and they are simple to repair. Fixes #18021. - - - - - cf8ab4a6 by Tom Ellis at 2020-12-17T13:57:12-05:00 submodule update: containers and stm Needed for https://gitlab.haskell.org/ghc/ghc/-/issues/15656 as it stops the packages triggering incomplete-uni-patterns and incomplete-record-updates - - - - - df7c7faa by Richard Eisenberg at 2020-12-17T13:57:48-05:00 Unfortunate dirty hack to overcome #18998. See commentary in tcCheckUsage. Close #18998. Test case: typecheck/should_compile/T18998 - - - - - 659fcb14 by Sylvain Henry at 2020-12-17T13:58:30-05:00 Fix project version for ProjectVersionMunged (fix #19058) - - - - - 7a93435b by Ryan Scott at 2020-12-18T05:50:33-05:00 Use HsOuterExplicit in instance sigs in deriving-generated code Issue #18914 revealed that `GeneralizedNewtypeDeriving` would generate code that mentions unbound type variables, which is dangerously fragile. The problem (and fix) is described in the new `Wrinkle: Use HsOuterExplicit` in `Note [GND and QuantifiedConstraints]`. The gist of it: make sure to put the top-level `forall`s in `deriving`-generated instance signatures in an `HsOuterExplicit` to ensure that they scope over the bodies of methods correctly. A side effect of this process is that it will expand any type synonyms in the instance signature, which will surface any `forall`s that are hidden underneath type synonyms (such as in the test case for #18914). While I was in town, I also performed some maintenance on `NewHsTypeX`, which powers `GeneralizedNewtypeDeriving`: * I renamed `NewHsTypeX` to `HsCoreTy`, which more accurately describes its intended purpose (#15706). I also made `HsCoreTy` a type synonym instead of a newtype, as making it a distinct data type wasn't buying us much. * To make sure that mistakes similar to #18914 do not occur later, I added an additional validity check when renaming `HsCoreTy`s that complains if an `HsCoreTy`s contains an out-of-scope type variable. See the new `Note [Renaming HsCoreTys]` in `GHC.Rename.HsType` for the details. Fixes #15706. Fixes #18914. Bumps the `haddock` submodule. - - - - - b4fcfd0f by Andreas Klebinger at 2020-12-18T05:51:09-05:00 OSMem.c: Use proper type for mbinds mask argument. StgWord has different widths on 32/64bit. So use the proper type instead. - - - - - 09edf5e5 by Andreas Klebinger at 2020-12-18T05:51:10-05:00 rts: EventLog.c: Properly cast (potential) 32bit pointers to uint64_t - - - - - ed22678a by Andreas Klebinger at 2020-12-18T05:51:10-05:00 Rts/elf-linker: Upcast to 64bit to satisfy format string. The elf size is 32bit on 32bit builds and 64 otherwise. We just upcast to 64bits before printing now. - - - - - 52498cfa by Alfredo Di Napoli at 2020-12-18T05:51:48-05:00 Split Driver.Env module This commit splits the GHC.Driver.Env module creating a separate GHC.Driver.Env.Types module where HscEnv and Hsc would live. This will pave the way to the structured error values by avoiding one boot module later down the line. - - - - - d66b4bcd by Alfredo Di Napoli at 2020-12-18T05:52:25-05:00 Rename parser Error and Warning types This commit renames parser's Error and Warning types (and their constructors) to have a 'Ps' prefix, so that this would play nicely when more errors and warnings for other phases of the pipeline will be added. This will make more explicit which is the particular type of error and warning we are dealing with, and will be more informative for users to see in the generated Haddock. - - - - - 29f77584 by Richard Eisenberg at 2020-12-18T05:53:01-05:00 Fix #19044 by tweaking unification in inst lookup See Note [Infinitary substitution in lookup] in GHC.Core.InstEnv and Note [Unification result] in GHC.Core.Unify. Test case: typecheck/should_compile/T190{44,52} Close #19044 Close #19052 - - - - - 0204b4aa by Ben Gamari at 2020-12-18T05:53:37-05:00 rts: Fix typo in macro name THREADED_RTS was previously misspelled as THREADEDED_RTS. Fixes #19057. - - - - - 3e9b7452 by Ben Gamari at 2020-12-18T05:54:21-05:00 primops: Document semantics of Float/Int conversions Fixes #18840. - - - - - c53b38dd by Ben Gamari at 2020-12-18T05:54:56-05:00 testsuite: Fix two shell quoting issues Fixes two ancient bugs in the testsuite driver makefiles due to insufficient quoting. I have no idea how these went unnoticed for so long. Thanks to @tomjaguarpaw for testing. - - - - - 59a07641 by Richard Eisenberg at 2020-12-18T05:55:33-05:00 Cite "Kind Inference for Datatypes" - - - - - c2430398 by Simon Peyton Jones at 2020-12-19T02:14:07-05:00 Quick Look: zonk result type Provoked by #18987, this patch adds a missing zonkQuickLook of app_res_rho in tcApp. Most of the time this zonk is unnecesary. In fact, I can't think of a concrete case where it is needed -- hence no test. But even if it isn't necessary, the reasoning that allows it to be omitted is very subtle. So I've put it in. However, adding this zonk does /not/ affect the emitted constraints, so the reported symptoms for #18987 remain, but harmlessly so, and now documented in a new Note [Instantiation variables are short lived] in GHC.Tc.Gen.App. No change in behaviour, no tests. - - - - - 173112ca by Simon Peyton Jones at 2020-12-19T02:14:42-05:00 Make noinline more reliable This patch makes the desugarer rewrite noinline (f d) --> noinline f d This makes 'noinline' much more reliable: see #18995 It's explained in the improved Note [noinlineId magic] in GHC.Types.Id.Make - - - - - df8e6e90 by Douglas Wilson at 2020-12-19T02:15:19-05:00 rts: Use weaker cas in WSDeque The algorithm described in the referenced paper uses this slightly weaker atomic op. This is the first "exotic" cas we're using. I've added a macro in the <ORDERING>_OP style to match existing ones. - - - - - 366b5885 by Tom Ellis at 2020-12-19T10:18:12+00:00 submodule update: haddock Ensure it is ready for -Wincomplete-uni-patterns and -Wincomplete-record-updates in -Wall - - - - - 32b6ebe8 by Tom Ellis at 2020-12-19T10:18:55+00:00 Add two warnings to -Wall * -Wincomplete-uni-patterns * -Wincomplete-record-updates See https://gitlab.haskell.org/ghc/ghc/-/issues/15656 - - - - - e84b02ab by Richard Eisenberg at 2020-12-20T14:14:11-05:00 Correct documentation around -XTypeOperators Close #19064 - - - - - 65721691 by Krzysztof Gogolewski at 2020-12-20T14:14:50-05:00 Improve inference with linear types This fixes test Linear14. The code in Unify.hs was always using multiplicity Many instead of a new metavariable. - - - - - 35fa0786 by Adam Sandberg Ericsson at 2020-12-20T20:45:55-05:00 rts: enable thread label table in all RTS flavours #17972 - - - - - 995a8f9d by Simon Peyton Jones at 2020-12-20T20:46:31-05:00 Kill floatEqualities completely This patch delivers on #17656, by entirel killing off the complex floatEqualities mechanism. Previously, floatEqualities would float an equality out of an implication, so that it could be solved at an outer level. But now we simply do unification in-place, without floating the constraint, relying on level numbers to determine untouchability. There are a number of important new Notes: * GHC.Tc.Utils.Unify Note [Unification preconditions] describes the preconditions for unification, including both skolem-escape and touchability. * GHC.Tc.Solver.Interact Note [Solve by unification] describes what we do when we do unify * GHC.Tc.Solver.Monad Note [The Unification Level Flag] describes how we control solver iteration under this new scheme * GHC.Tc.Solver.Monad Note [Tracking Given equalities] describes how we track when we have Given equalities * GHC.Tc.Types.Constraint Note [HasGivenEqs] is a new explanation of the ic_given_eqs field of an implication A big raft of subtle Notes in Solver, concerning floatEqualities, disappears. Main code changes: * GHC.Tc.Solver.floatEqualities disappears entirely * GHC.Tc.Solver.Monad: new fields in InertCans, inert_given_eq_lvl and inert_given_eq, updated by updateGivenEqs See Note [Tracking Given equalities]. * In exchange for updateGivenEqa, GHC.Tc.Solver.Monad.getHasGivenEqs is much simpler and more efficient * I found I could kill of metaTyVarUpdateOK entirely One test case T14683 showed a 5.1% decrease in compile-time allocation; and T5631 was down 2.2%. Other changes were small. Metric Decrease: T14683 T5631 - - - - - 5eb22fa2 by Krzysztof Gogolewski at 2020-12-20T20:47:11-05:00 Fix printing in -ddump-rule-rewrites (#18668) The unapplied arguments were not printed out. - - - - - b4508bd6 by Matthew Pickering at 2020-12-20T20:47:47-05:00 Fix Haddock parse error in GHC.Parser.PostProcess.Haddock - - - - - 19823708 by Ben Gamari at 2020-12-20T21:05:13-05:00 nonmoving: Fix small CPP bug Previously an incorrect semicolon meant that we would fail to call busy_wait_nop when spinning. - - - - - a5b2fded by GHC GitLab CI at 2020-12-20T21:05:13-05:00 nonmoving: Assert deadlock-gc promotion invariant When performing a deadlock-detection GC we must ensure that all objects end up in the non-moving generation. Assert this in scavenge. - - - - - cde74994 by GHC GitLab CI at 2020-12-20T21:05:13-05:00 nonmoving: Ensure deadlock detection promotion works Previously the deadlock-detection promotion logic in alloc_for_copy was just plain wrong: it failed to fire when gct->evac_gen_no != oldest_gen->gen_no. The fix is simple: move the - - - - - a13bd3f1 by GHC GitLab CI at 2020-12-20T21:05:13-05:00 nonmoving: Refactor alloc_for_copy Pull the cold non-moving allocation path out of alloc_for_copy. - - - - - a2731d49 by Ben Gamari at 2020-12-20T21:05:13-05:00 nonmoving: Don't push objects during deadlock detect GC Previously we would push large objects and compact regions to the mark queue during the deadlock detect GC, resulting in failure to detect deadlocks. - - - - - 65b702f1 by GHC GitLab CI at 2020-12-20T21:05:13-05:00 nonmoving: Add comments to nonmovingResurrectThreads - - - - - 13874a7b by Ben Gamari at 2020-12-21T16:35:36-05:00 gitlab-ci: Use gtar on FreeBSD - - - - - 3ef94d27 by Adam Sandberg Ericsson at 2020-12-22T01:26:44-05:00 hadrian: disable ghc package environments #18988 - - - - - f27a7144 by Adam Sandberg Ericsson at 2020-12-22T01:26:44-05:00 make: disable ghc package environments #18988 - - - - - 293100ad by Matthew Pickering at 2020-12-22T01:27:20-05:00 Fix another haddock parse error - - - - - 932ee6de by Joe Hermaszewski at 2020-12-22T10:38:24-05:00 Add Monoid instances for Product and Compose Semigroup too of course - - - - - 4c3fae47 by Ryan Scott at 2020-12-22T10:39:00-05:00 Require alex < 3.2.6 A workaround for #19099. - - - - - 553c59ca by Andreas Klebinger at 2020-12-22T22:10:06-05:00 Increase -A default to 4MB. This gives a small increase in performance under most circumstances. For single threaded GC the improvement is on the order of 1-2%. For multi threaded GC the results are quite noisy but seem to fall into the same ballpark. Fixes #16499 - - - - - 53fb345d by Adam Sandberg Ericsson at 2020-12-22T22:10:45-05:00 mkDocs: fix extraction of Win32 docs from hadrian bindist - - - - - 50236ed2 by Adam Sandberg Ericsson at 2020-12-22T22:10:45-05:00 mkDocs: address shellcheck issues - - - - - 56841432 by Sebastian Graf at 2020-12-23T10:21:56-05:00 DmdAnal: Keep alive RULE vars in LetUp (#18971) I also took the liberty to refactor the logic around `ruleFVs`. - - - - - f0ec06c7 by Sebastian Graf at 2020-12-23T10:21:56-05:00 WorkWrap: Unbox constructors with existentials (#18982) Consider ```hs data Ex where Ex :: e -> Int -> Ex f :: Ex -> Int f (Ex e n) = e `seq` n + 1 ``` Worker/wrapper should build the following worker for `f`: ```hs $wf :: forall e. e -> Int# -> Int# $wf e n = e `seq` n +# 1# ``` But previously it didn't, because `Ex` binds an existential. This patch lifts that condition. That entailed having to instantiate existential binders in `GHC.Core.Opt.WorkWrap.Utils.mkWWstr` via `GHC.Core.Utils.dataConRepFSInstPat`, requiring a bit of a refactoring around what is now `DataConPatContext`. CPR W/W still won't unbox DataCons with existentials. See `Note [Which types are unboxed?]` for details. I also refactored the various `tyCon*DataCon(s)_maybe` functions in `GHC.Core.TyCon`, deleting some of them which are no longer needed (`isDataProductType_maybe` and `isDataSumType_maybe`). I cleaned up a couple of call sites, some of which weren't very explicit about whether they cared for existentials or not. The test output of `T18013` changed, because we now unbox the `Rule` data type. Its constructor carries existential state and will be w/w'd now. In the particular example, the worker functions inlines right back into the wrapper, which then unnecessarily has a (quite big) stable unfolding. I think this kind of fallout is inevitable; see also Note [Don't w/w inline small non-loop-breaker things]. There's a new regression test case `T18982`. Fixes #18982. - - - - - f59c34b8 by Sylvain Henry at 2020-12-23T10:22:35-05:00 Support package qualifier in Prelude import Fix #19082, #17045 - - - - - cce1514a by Douglas Wilson at 2020-12-23T10:23:14-05:00 spelling: thead -> thread - - - - - 79d41f93 by Simon Peyton Jones at 2020-12-23T10:23:51-05:00 Document scoping of named wildcard type variables See `Note [Scoping of named wildcards]` in GHC.Hs.Type This lack of documentation came up in #19051. - - - - - e7d8e4ee by Simon Peyton Jones at 2020-12-24T06:41:07-05:00 Clone the binders of a SAKS where necessary Given a kind signature type T :: forall k. k -> forall k. k -> blah data T a b = ... where those k's have the same unique (which is possible; see #19093) we were giving the tyConBinders in tycon T the same unique, which caused chaos. Fix is simple: ensure uniqueness when decomposing the kind signature. See GHC.Tc.Gen.HsType.zipBinders - - - - - 98094744 by Ryan Scott at 2020-12-24T06:41:43-05:00 Require ScopedTypeVariables+TypeApplications to use type applications in patterns Fixes #19109. - - - - - 6f8bafb4 by Adam Gundry at 2020-12-24T16:34:49-05:00 Refactor renamer datastructures This patch significantly refactors key renamer datastructures (primarily Avail and GlobalRdrElt) in order to treat DuplicateRecordFields in a more robust way. In particular it allows the extension to be used with pattern synonyms (fixes where mangled record selector names could be printed instead of field labels (e.g. with -Wpartial-fields or hole fits, see new tests). The key idea is the introduction of a new type GreName for names that may represent either normal entities or field labels. This is then used in GlobalRdrElt and AvailInfo, in place of the old way of representing fields using FldParent (yuck) and an extra list in AvailTC. Updates the haddock submodule. - - - - - adaa6194 by John Ericson at 2020-12-24T16:35:25-05:00 Use `hscFrontendHook` again In eb629fab I accidentally got rid of it when inlining tons of helpers. Closes #19004 - - - - - 164887da by Richard Eisenberg at 2020-12-25T03:48:37-05:00 Use mutable update to defer out-of-scope errors Previously, we let-bound an identifier to use to carry the erroring evidence for an out-of-scope variable. But this failed for levity-polymorphic out-of-scope variables, leading to a panic (#17812). The new plan is to use a mutable update to just write the erroring expression directly where it needs to go. Close #17812. Test case: typecheck/should_compile/T17812 - - - - - cbc7c3dd by Richard Eisenberg at 2020-12-25T03:49:13-05:00 Test cases for #15772 and #17139. - - - - - 2113a1d6 by John Ericson at 2020-12-28T12:28:35-05:00 Put hole instantiation typechecking in the module graph and fix driver batch mode backpack edges Backpack instantiations need to be typechecked to make sure that the arguments fit the parameters. `tcRnInstantiateSignature` checks instantiations with concrete modules, while `tcRnCheckUnit` checks instantiations with free holes (signatures in the current modules). Before this change, it worked that `tcRnInstantiateSignature` was called after typechecking the argument module, see `HscMain.hsc_typecheck`, while `tcRnCheckUnit` was called in `unsweep'` where-bound in `GhcMake.upsweep`. `tcRnCheckUnit` was called once per each instantiation once all the argument sigs were processed. This was done with simple "to do" and "already done" accumulators in the fold. `parUpsweep` did not implement the change. With this change, `tcRnCheckUnit` instead is associated with its own node in the `ModuleGraph`. Nodes are now: ```haskell data ModuleGraphNode -- | Instantiation nodes track the instantiation of other units -- (backpack dependencies) with the holes (signatures) of the current package. = InstantiationNode InstantiatedUnit -- | There is a module summary node for each module, signature, and boot module being built. | ModuleNode ExtendedModSummary ``` instead of just `ModSummary`; the `InstantiationNode` case is the instantiation of a unit to be checked. The dependencies of such nodes are the same "free holes" as was checked with the accumulator before. Both versions of upsweep on such a node call `tcRnCheckUnit`. There previously was an `implicitRequirements` function which would crawl through every non-current-unit module dep to look for all free holes (signatures) to add as dependencies in `GHC.Driver.Make`. But this is no good: we shouldn't be looking for transitive anything when building the graph: the graph should only have immediate edges and the scheduler takes care that all transitive requirements are met. So `GHC.Driver.Make` stopped using `implicitRequirements`, and instead uses a new `implicitRequirementsShallow`, which just returns the outermost instantiation node (or module name if the immediate dependency is itself a signature). The signature dependencies are just treated like any other imported module, but the module ones then go in a list stored in the `ModuleNode` next to the `ModSummary` as the "extra backpack dependencies". When `downsweep` creates the mod summaries, it adds this information too. ------ There is one code quality, and possible correctness thing left: In addition to `implicitRequirements` there is `findExtraSigImports`, which says something like "if you are an instantiation argument (you are substituted or a signature), you need to import its things too". This is a little non-local so I am not quite sure how to get rid of it in `GHC.Driver.Make`, but we probably should eventually. First though, let's try to make a test case that observes that we don't do this, lest it actually be unneeded. Until then, I'm happy to leave it as is. ------ Beside the ability to use `-j`, the other major user-visibile side effect of this change is that that the --make progress log now includes "Instantiating" messages for these new nodes. Those also are numbered like module nodes and count towards the total. ------ Fixes #17188 Updates hackage submomdule Metric Increase: T12425 T13035 - - - - - 9b563330 by Cale Gibbard at 2020-12-31T13:05:42-05:00 INLINE pragma for patterns (#12178) Allow INLINE and NOINLINE pragmas to be used for patterns. Those are applied to both the builder and matcher (where applicable). - - - - - 85d899c8 by Sylvain Henry at 2021-01-02T07:32:12-05:00 Make proper fixed-width number literals (Progress towards #11953, #17377, #17375) Besides being nicer to use, this also will allow for better constant folding for the fixed-width types, on par with what `Int#` and `Word#` have today. - - - - - 77c4a15f by Artem Pelenitsyn at 2021-01-02T07:32:50-05:00 base: add Numeric.{readBin, showBin} (fix #19036) - - - - - 87bc458d by Ben Gamari at 2021-01-02T07:33:26-05:00 rts/Messages: Relax locked-closure assertion In general we are less careful about locking closures when running with only a single capability. Fixes #19075. - - - - - 5650c79e by Simon Peyton Jones at 2021-01-02T07:34:01-05:00 Establish invariant (GivenInv) This patch establishes invariant (GivenInv) from GHC.Tc.Utils.TcType Note [TcLevel invariants]. (GivenInv) says that unification variables from level 'n' should not appear in the Givens for level 'n'. See Note [GivenInv] in teh same module. This invariant was already very nearly true, but a dark corner of partial type signatures made it false. The patch re-jigs partial type signatures a bit to avoid the problem, and documents the invariant much more thorughly Fixes #18646 along the way: see Note [Extra-constraints wildcards] in GHC.Tc.Gen.Bind I also simplified the interface to tcSimplifyInfer slightly, so that it /emits/ the residual constraint, rather than /returning/ it. - - - - - c2a007c7 by Joachim Breitner at 2021-01-02T07:34:37-05:00 Docs: Remove reference to `type_applications` in `exts/patterns.rst` it is unclear why it is there, and it is _also_ linked from `exts/types.rst`. - - - - - d9788fd2 by Douglas Wilson at 2021-01-02T07:35:14-05:00 rts: update usage text for new -A default - - - - - bc383cb0 by Hécate at 2021-01-02T07:35:54-05:00 Upstream the strictness optimisation for GHC.List.{sum,product} - - - - - 4c178374 by Hécate at 2021-01-02T07:35:54-05:00 Upstream the strictness optimisation for GHC.List.{maximum,minimum} - - - - - aa17b84d by Oleg Grenrus at 2021-01-02T07:36:33-05:00 Correct doctests It's simpler to assume that base is NoImplicitPrelude, otherwise running doctest on `GHC.*` modules would be tricky. OTOH, most `GHC.List` (where the most name clashes are) examples could be changed to use `import qualified Data.List as L`. (GHC.List examples won't show for Foldable methods...). With these changes majority of doctest examples are GHCi-"faithful", my WIP GHC-independent doctest runner reports nice summary: Examples: 582; Tried: 546; Skipped: 34; Success: 515; Errors: 33; Property Failures 2 Most error cases are *Hangs forever*. I have yet to figure out how to demonstrate that in GHCi. Some of divergences are actually stack overflows, i.e. caught by runtime. Few errorful cases are examples of infinite output, e.g. >>> cycle [42] [42,42,42,42,42,42,42,42,42,42... while correct, they confuse doctest. Another erroneous cases are where expected output has line comment, like >>> fmap show (Just 1) -- (a -> b) -> f a -> f b Just "1" -- (Int -> String) -> Maybe Int -> Maybe String I think I just have to teach doctest to strip comments from expected output. This is a first patch in a series. There is plenty of stuff already. - - - - - cc87bda6 by Asad Saeeduddin at 2021-01-02T07:37:09-05:00 Use EmptyCase instead of undefined in Generics example Fixes #19124 - - - - - a8926e95 by Simon Peyton Jones at 2021-01-02T07:37:46-05:00 Don't use absentError thunks for strict constructor fields This patch fixes #19133 by using LitRubbish for strict constructor fields, even if they are of lifted types. Previously LitRubbish worked only for unlifted (but boxed) types. The change is very easy, although I needed a boolean field in LitRubbish to say whether or not it is lifted. (That seemed easier than giving it another type argument. This is preparing for Andreas's work on establishing the invariant that strict constructor fields are always tagged and evaluated (see #16970). Meanwhile, nothing was actually wrong before, so there are no tests. - - - - - ee1161d3 by Simon Peyton Jones at 2021-01-02T14:13:25+00:00 Add regression test for #18467 - - - - - c7e16936 by Hécate at 2021-01-03T05:23:39-05:00 Add the Data.Foldable strictness optimisations to base's changelog - - - - - 0a265624 by Viktor Dukhovni at 2021-01-03T13:55:10-05:00 Maintain invariant: MVars on mut_list are dirty The fix for 18919 was somewhat incomplete: while the MVars were correctly added to the mut_list via dirty_MVAR(), their info table remained "clean". While this is mostly harmless in non-debug builds, but trips an assertion in the debug build, and may result in the MVar being needlessly being added to the mut_list multiple times. Resolves: #19145 - - - - - 26a928b8 by John Ericson at 2021-01-03T13:55:45-05:00 Rename internal primpos ahead of !4492 I'm not sure how long the submodule dance is going to take, sadly, so I'd like to chip away at things in the meantime / avoid conflicts. - - - - - 6c771aaf by Sylvain Henry at 2021-01-05T15:02:58+01:00 Implement Unique supply with Addr# atomic primop Before this patch the compiler depended on the RTS way (threaded or not) to use atomic incrementation or not. This is wrong because the RTS is supposed to be switchable at link time, without recompilation. Now we always use atomic incrementation of the unique counter. - - - - - 3e2ea550 by Ben Gamari at 2021-01-07T00:10:15-05:00 rts: Break up census logic Move the logic for taking censuses of "normal" and pinned blocks to their own functions. - - - - - 66902230 by Ben Gamari at 2021-01-07T00:10:15-05:00 rts: Implement heap census support for pinned objects It turns out that this was fairly straightforward to implement since we are now pretty careful about zeroing slop. - - - - - fb81f2ed by Ben Gamari at 2021-01-07T00:10:15-05:00 Storage: Unconditionally enable zeroing of alignment slop This is necessary since the user may enable `+RTS -hT` at any time. - - - - - 30f7137d by Ben Gamari at 2021-01-07T00:10:15-05:00 rts: Zero shrunk array slop in vanilla RTS But only when profiling or DEBUG are enabled. Fixes #17572. - - - - - ced0d752 by Ben Gamari at 2021-01-07T00:10:16-05:00 rts: Enforce that mark-region isn't used with -h As noted in #9666, the mark-region GC is not compatible with heap profiling. Also add documentation for this flag. Closes #9666. - - - - - e981023e by Ben Gamari at 2021-01-07T00:10:52-05:00 users-guide: Remove space from -ol documentation This flag requires that there be no space between the filename and the argument. - - - - - 06982b6c by John Ericson at 2021-01-07T00:11:31-05:00 Make primops for `{Int,Word}32#` Progress towards #19026. The type was added before, but not its primops. We follow the conventions in 36fcf9edee31513db2ddbf716ee0aa79766cbe69 and 2c959a1894311e59cd2fd469c1967491c1e488f3 for names and testing. Along with the previous 8- and 16-bit primops, this will allow us to avoid many conversions for 8-, 16-, and 32-bit sized numeric types. Co-authored-by: Sylvain Henry <hsyl20 at gmail.com> - - - - - 1de2050e by Roland Senn at 2021-01-07T00:12:09-05:00 GHCi: Fill field `DynFlags.dumpPrefix`. (Fixes #17500) For interactive evaluations set the field `DynFlags.dumpPrefix` to the GHCi internal module name. The GHCi module name for an interactive evaluation is something like `Ghci9`. To avoid user confusion, don't dump any data for GHCi internal evaluations. Extend the comment for `DynFlags.dumpPrefix` and fix a little typo in a comment about the GHCi internal module names. - - - - - 10499f55 by Ben Gamari at 2021-01-07T00:12:46-05:00 compiler: Initialize ForeignExportsList.n_entries The refactoring in ed57c3a9eb9286faa222f98e484a9ef3432b2025 failed to initialize this field, resulting in no exports being registered. A very silly bug and yet somehow none of our tests caught it. See #18548. Fixes #19149. - - - - - 2f629beb by Ben Gamari at 2021-01-07T00:12:46-05:00 testsuite: Add test for #19149 - - - - - 3b3fcc71 by Ben Gamari at 2021-01-07T00:13:22-05:00 rts/Linker: Add noreturn to loadNativeObj on non-ELF platforms - - - - - e0e7d2bc by Ben Gamari at 2021-01-07T00:13:59-05:00 rts/Sanity: Allow DEAD_WEAKs in weak pointer list The weak pointer check in `checkGenWeakPtrList` previously failed to account for dead weak pointers. This caused `fptr01` to fail in the `sanity` way. Fixes #19162. - - - - - ad3d2364 by Ben Gamari at 2021-01-07T00:14:35-05:00 docs: Various release notes changes * Mention changed in profiler's treatment of PINNED closures * Fix formatting * Move plugins-relevant changes to GHC API section - - - - - bd877edd by Sylvain Henry at 2021-01-07T00:15:15-05:00 Hadrian: show default ghc-bignum backend (fix #18912) - - - - - 9a62ecfa by Alfredo Di Napoli at 2021-01-09T21:18:34-05:00 Remove errShortString, cleanup error-related functions This commit removes the errShortString field from the ErrMsg type, allowing us to cleanup a lot of dynflag-dependent error functions, and move them in a more specialised 'GHC.Driver.Errors' closer to the driver, where they are actually used. Metric Increase: T4801 T9961 - - - - - f88fb8c7 by Ben Gamari at 2021-01-09T21:19:10-05:00 hadrian: Add missing dependencies ghcconfig.h, which depends upon ghcautoconf.h, and is a runtime dependency of deriveConstants. This is essentially a continuation of #18290. - - - - - c8c63dde by Richard Eisenberg at 2021-01-09T21:19:45-05:00 Never Anyify during kind inference See Note [Error on unconstrained meta-variables] in TcMType. Close #17301 Close #17567 Close #17562 Close #15474 - - - - - 0670f387 by Viktor Dukhovni at 2021-01-09T21:20:23-05:00 New overview of Foldable class Also updated stale external URL in Traversable - - - - - a2f43e26 by Viktor Dukhovni at 2021-01-09T21:20:23-05:00 More truthful synopsis examples - - - - - f9605e1a by Viktor Dukhovni at 2021-01-09T21:20:23-05:00 Reconcile extant synopses with new overview prose - Renamed new "update function" to "operator" from synopses - More accurate divergence conditions. - Fewer references to the Tree structure in examples, which may not have the definition close-by in context in other modules, e.g. Prelude. - Improved description of foldlM and foldrM - More detail on Tree instance construction - Misc fixes - - - - - e07ba458 by Viktor Dukhovni at 2021-01-09T21:20:23-05:00 More tidy synopses, and new generative recursion - Further correction and reconcialation with new overview of the existing synopses. Restored some "Tree" examples. - New section on generative recursion via Church encoding of lists. - - - - - f49d6fb2 by Douglas Wilson at 2021-01-09T21:21:02-05:00 rts: stats: Some fixes to stats for sequential gcs Solves #19147. When n_capabilities > 1 we were not correctly accounting for gc time for sequential collections. In this case par_n_gcthreads == 1, however it is not guaranteed that the single gc thread is capability 0. A similar issue for copied is addressed as well. - - - - - 06beed68 by Douglas Wilson at 2021-01-09T21:21:02-05:00 rts: stats: Fix calculation for fragmentation - - - - - 3d15d8d0 by Ben Gamari at 2021-01-09T21:21:37-05:00 rts: Use relaxed load when checking for cap ownership This check is merely a service to the user; no reason to synchronize. - - - - - 83ac5594 by Ben Gamari at 2021-01-09T21:21:37-05:00 rts: Use SEQ_CST accesses when touching `wakeup` These are the two remaining non-atomic accesses to `wakeup` which were missed by the original TSAN patch. - - - - - d1b9d679 by Ben Gamari at 2021-01-09T21:21:38-05:00 rts/Capability: Use relaxed load in findSpark When checking n_returning_tasks. - - - - - f6b843cd by Ben Gamari at 2021-01-09T21:22:14-05:00 rts/PEi386: Fix reentrant lock usage Previously lookupSymbol_PEi386 would call lookupSymbol while holding linker_mutex. Fix this by rather calling `lookupDependentSymbol`. This is safe because lookupSymbol_PEi386 unconditionally holds linker_mutex. Happily, this un-breaks `T12771`, `T13082_good`, and `T14611`, which were previously marked as broken due to #18718. Closes #19155. - - - - - 73b5cc01 by Ben Gamari at 2021-01-09T21:22:51-05:00 gitlab-ci: Don't attempt to push perf notes in cross build We don't run the testsuite in cross-compiled builds so there is nothing to push. - - - - - a9ef2399 by Greg Steuck at 2021-01-09T21:23:27-05:00 intro.rst: remove duplication of release references and fix a link - - - - - 9163b3f1 by Greg Steuck at 2021-01-09T21:23:27-05:00 gone_wrong.rst: remove duplicate term - - - - - 27544196 by Sylvain Henry at 2021-01-09T21:24:06-05:00 Natural: fix left shift of 0 (fix #19170) - - - - - 78629c24 by Ben Gamari at 2021-01-09T21:24:42-05:00 testsuite: Increase delay in conc059 As noted in #19179, conc059 can sometimes fail due to too short of a delay in the its Haskell threads. Address this by increasing the delay by an order of magnitude to 5 seconds. While I'm in town I refactored the test to eliminate a great deal of unnecessary platform dependence, eliminate use of the deprecated usleep, and properly handle interruption by signals. Fixes #19179. - - - - - 4d1ea2c3 by Nick Erdmann at 2021-01-09T21:25:19-05:00 Fix calls to varargs C function fcntl The ccall calling convention doesn't support varargs functions, so switch to capi instead. See https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html#varargs-not-supported-by-ccall-calling-convention - - - - - a2567e99 by Oleg Grenrus at 2021-01-10T05:36:43-05:00 Correct more doctests - - - - - 4bb957de by John Ericson at 2021-01-10T05:37:19-05:00 Fix `not32Word#` -> `notWord32#` This is is correcting a mistake I unfortunately missed in !4698. But that is a recent PR so this fix is not a compatibility hazard with released versions of GHC. - - - - - 1a220bcf by Sebastian Graf at 2021-01-10T23:34:59-05:00 WorkWrap: Use SysLocal Name for Thunk Splitting (#19180) Since !4493 we annotate top-level bindings with demands, which leads to novel opportunities for thunk splitting absent top-level thunks. It turns out that thunk splitting wasn't quite equipped for that, because it re-used top-level, `External` Names for local helper Ids. That triggered a CoreLint error (#19180), reproducible with `T19180`. Fixed by adjusting the thunk splitting code to produce `SysLocal` names for the local bindings. Fixes #19180. Metric Decrease: T12227 T18282 - - - - - 2f933eb6 by Benjamin Maurer at 2021-01-10T23:35:35-05:00 Document flag -dasm-lint in debugging.rst - - - - - 0dba7841 by Benjamin Maurer at 2021-01-10T23:35:35-05:00 Update expected-undocumented-flags.txt - - - - - 9fa34289 by Hécate at 2021-01-13T19:21:40+01:00 Remove references to ApplicativeDo in the base haddocks - - - - - d930687a by Sylvain Henry at 2021-01-17T05:46:09-05:00 Show missing field types (#18869) - - - - - fe344da9 by Sylvain Henry at 2021-01-17T05:46:09-05:00 Missing fields: enhance error messages (#18869) This patch delays the detection of missing fields in record creation after type-checking. This gives us better error messages (see updated test outputs). - - - - - 23a545df by Sebastian Graf at 2021-01-17T05:46:45-05:00 PmCheck: Positive info doesn't imply there is an inhabitant (#18960) Consider `T18960`: ```hs pattern P :: a -> a pattern P x = x {-# COMPLETE P :: () #-} foo :: () foo = case () of P _ -> () ``` We know about the match variable of the case match that it is equal to `()`. After the match on `P`, we still know it's equal to `()` (positive info), but also that it can't be `P` (negative info). By the `COMPLETE` pragma, we know that implies that the refinement type of the match variable is empty after the `P` case. But in the PmCheck solver, we assumed that "has positive info" means "is not empty", thus assuming we could omit a costly inhabitation test. Which is wrong, as we saw above. A bit of a complication arises because the "has positive info" spared us from doing a lot of inhabitation tests in `T17836b`. So we keep that check, but give it a lower priority than the check for dirty variables that requires us doing an inhabitation test. Needless to say: This doesn't impact soundness of the checker at all, it just implements a better trade-off between efficiency and precision. Fixes #18960. Metric Decrease: T17836 - - - - - 9ab0f830 by Sebastian Graf at 2021-01-17T05:46:45-05:00 Accept (fixed) T14059b The `expect_broken` of `T14059b` expected outdated output. But #14059 has long been fixed, so we this commit accepts the new output and marks the test as unbroken. - - - - - 0ac5860e by Stefan Schulze Frielinghaus at 2021-01-17T05:47:24-05:00 CmmToLlvm: Sign/Zero extend parameters for foreign calls For some architectures the C calling convention is that any integer shorter than 64 bits is replaced by its 64 bits representation using sign or zero extension. Fixes #19023. - - - - - 66e281fb by Ben Gamari at 2021-01-17T05:48:01-05:00 rts/eventlog: Introduce event to demarcate new ticky sample - - - - - be3b6b57 by Ben Gamari at 2021-01-17T05:48:01-05:00 rts/eventlog: Reset ticky counters after dumping sample - - - - - 496bc4e8 by alexbiehl at 2021-01-17T05:48:39-05:00 Bump Haddock submodule Metric Decrease: haddock.base - - - - - 2facd1e9 by alexbiehl at 2021-01-17T05:48:39-05:00 Hadrian: Pass -jshakethreads to Haddock invocations - - - - - 971a88a7 by Hécate at 2021-01-17T05:49:17-05:00 Remove unused extension pragmas from the compiler code base - - - - - f395c2cb by Douglas Wilson at 2021-01-17T05:49:54-05:00 rts: gc: use mutex+condvar instead of sched_yield in gc main loop Here we remove the schedYield loop in scavenge_until_all_done+any_work, replacing it with a single mutex + condition variable. Previously any_work would check todo_large_objects, todo_q, todo_overflow of each gen for work. Comments explained that this was checking global work in any gen. However, these must have been out of date, because all of these locations are local to a gc thread. We've eliminated any_work entirely, instead simply looping back into scavenge_loop, which will quickly return if there is no work. shutdown_gc_threads is called slightly earlier than before. This ensures that n_gc_threads can never be observed to increase from 0 by a worker thread. startup_gc_threads is removed. It consisted of a single variable assignment, which is moved inline to it's single callsite. - - - - - f2d118c0 by Douglas Wilson at 2021-01-17T05:49:54-05:00 rts: remove no_work counter We are no longer busyish waiting, so this is no longer meaningful - - - - - 345ae06b by Douglas Wilson at 2021-01-17T05:49:54-05:00 rts: add max_n_todo_overflow internal counter I've never observed this counter taking a non-zero value, however I do think it's existence is justified by the comment in grab_local_todo_block. I've not added it to RTSStats in GHC.Stats, as it doesn't seem worth the api churn. - - - - - 33fc453f by Douglas Wilson at 2021-01-17T05:49:54-05:00 rts: add timedWaitCondition - - - - - d56fdad7 by Douglas Wilson at 2021-01-17T05:49:54-05:00 rts: gc: use mutex+condvar instead of spinlooks in gc entry/exit used timed wait on condition variable in waitForGcThreads fix dodgy timespec calculation - - - - - 3d3fd7d8 by Ben Gamari at 2021-01-17T05:50:31-05:00 rts/linker: Don't assume existence of dlinfo The native-code codepath uses dlinfo to identify memory regions owned by a loaded dynamic object, facilitating safe unload. Unfortunately, this interface is not always available. Add an autoconf check for it and introduce a safe fallback behavior. Fixes #19159. - - - - - 35cb5406 by Oleg Grenrus at 2021-01-17T05:51:10-05:00 Import fcntl with capi calling convention See https://gitlab.haskell.org/ghc/ghc/-/issues/18854 - - - - - 55a8f860 by Ben Gamari at 2021-01-17T05:51:46-05:00 base: Eliminate pinned allocations from IntTable This replaces the ForeignPtr used to track IntTable's pointer size with a single-entry mutable ByteArray#, eliminating the fragmentation noted in #19171. Fixes #19171. - - - - - 84dcb844 by Sylvain Henry at 2021-01-17T05:52:26-05:00 Revert "Remove SpecConstrAnnotation (#13681)" (#19168) This reverts commit 7bc3a65b467c4286377b9bded277d5a2f69160b3. NoSpecConstr is used in the wild (see #19168) - - - - - d159041b by Ben Gamari at 2021-01-17T05:53:02-05:00 rts: Initialize card table in newArray# Previously we would leave the card table of new arrays uninitialized. This wasn't a soundness issue: at worst we would end up doing unnecessary scavenging during GC, after which the card table would be reset. That being said, it seems worth initializing this properly to avoid both unnecessary work and non-determinism. Fixes #19143. - - - - - 66414bdf by Sylvain Henry at 2021-01-17T05:53:42-05:00 configure: fix the use of some obsolete macros (#19189) - - - - - 62cac31c by Krzysztof Gogolewski at 2021-01-17T05:54:19-05:00 Fix unsoundness for linear guards (#19120) - - - - - 907f1e4a by Oleg Grenrus at 2021-01-17T05:54:58-05:00 Third pass on doctest corrections. With `-K500K` rts option stack overflows are more deterministic - - - - - 6f9a817f by Sylvain Henry at 2021-01-17T05:55:37-05:00 Bignum: fix for Integer/Natural Ord instances * allow `integerCompare` to inline into `integerLe#`, etc. * use `naturalSubThrow` to implement Natural's `(-)` * use `naturalNegate` to implement Natural's `negate` * implement and use `integerToNaturalThrow` to implement Natural's `fromInteger` Thanks to @christiaanb for reporting these - - - - - 5ae73f69 by Sylvain Henry at 2021-01-17T05:56:17-05:00 Add regression test for #16577 - - - - - d2b10eac by Moritz Angermann at 2021-01-17T05:56:56-05:00 Bump gmp submodule, now with arm64 support - - - - - e516ef7e by Sylvain Henry at 2021-01-17T05:57:35-05:00 Hadrian: fix flavour parser Hadrian was silently using the "quick" flavour when "quick-debug" or "quick-validate" was used. This patch fixes the parser and ensures that the whole input is consumed. - - - - - 2ac28e4c by Simon Peyton Jones at 2021-01-17T05:58:12-05:00 Use captureTopConstraints at top level Missing this caused #19197. Easily fixed. - - - - - 98e0d08f by Ben Gamari at 2021-01-17T05:58:48-05:00 hadrian: Introduce no_profiled_libs flavour transformer Per request of @AndreasK. - - - - - b1cafb82 by Hécate at 2021-01-17T05:59:26-05:00 Add some additional information to the fail message based on exit code - - - - - 29c9eb3f by Oleg Grenrus at 2021-01-18T07:19:34-05:00 Add Eq1, Show1, Read1 Complex instances - - - - - 5c312e23 by Oleg Grenrus at 2021-01-18T07:19:34-05:00 Add lifted instances for 3 and 4 tuples - - - - - 5f1d8be0 by Oleg Grenrus at 2021-01-18T07:19:34-05:00 Add examples for Complex, (,,) and (,,,) Eq2 etc instances - - - - - 9cc50a0f by Hécate at 2021-01-18T07:20:12-05:00 Rectify Haddock typos for the Functor class - - - - - 6cfdca9f by Cheng Shao at 2021-01-19T12:52:57+00:00 Correct documentation in System.Mem.Weak [ci skip] Since #13167 is closed, exceptions thrown in finalizers are ignored and doesn't affect other finalizers in the same batch. This MR updates the documentation in System.Mem.Weak to reflect that. - - - - - 1ff61314 by Sylvain Henry at 2021-01-22T14:57:36-05:00 Fix wrong comment about UnitState [CI skip] - - - - - 092f0532 by Andreas Klebinger at 2021-01-22T14:58:14-05:00 When deriving Eq always use tag based comparisons for nullary constructors Instead of producing auxiliary con2tag bindings we now rely on dataToTag#, eliminating a fair bit of generated code. Co-Authored-By: Ben Gamari <ben at well-typed.com> - - - - - 2ed96c68 by Ben Gamari at 2021-01-22T14:58:14-05:00 Use pointer tag in dataToTag# While looking at !2873 I noticed that dataToTag# previously didn't look at a pointer's tag to determine its constructor. To be fair, there is a bit of a trade-off here: using the pointer tag requires a bit more code and another branch. On the other hand, it allows us to eliminate looking at the info table in many cases (especially now since we tag large constructor families; see #14373). - - - - - b4b2be61 by Ben Gamari at 2021-01-22T14:58:14-05:00 dataToTag#: Avoid unnecessary entry When the pointer is already tagged we can avoid entering the closure. - - - - - 01ea56a2 by Sylvain Henry at 2021-01-22T14:58:53-05:00 Arrows: collect evidence binders Evidence binders were not collected by GHC.HsToCore.Arrows.collectStmtBinders, hence bindings for dictionaries were not taken into account while computing local variables in statements. As a consequence we had a transformation similar to this: data Point a where Point :: RealFloat a => a -> Point a do p -< ... returnA -< ... (Point 0) ===> { Type-checking } do let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat p -< ... returnA -< ... (Point $dRealFloat_xyz 0) ===> { Arrows HsToCore } first ... >>> arr (\(p, ()) -> case p of ... -> let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat in case .. of () -> ()) >>> \((),()) -> ... (Point $dRealFloat_xyz 0) -- dictionary not in scope Now evidences are passed in the environment if necessary and we get: ===> { Arrows HsToCore } first ... >>> arr (\(p, ()) -> case p of ... -> let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat in case .. of () -> $dRealFloat_xyz) >>> \(ds,()) -> let $dRealFloat_xyz = ds in ... (Point $dRealFloat_xyz 0) -- dictionary in scope Note that collectStmtBinders has been copy-pasted from GHC.Hs.Utils. This ought to be factorized but Note [Dictionary binders in ConPatOut] claims that: Do *not* gather (a) dictionary and (b) dictionary bindings as binders of a ConPatOut pattern. For most calls it doesn't matter, because it's pre-typechecker and there are no ConPatOuts. But it does matter more in the desugarer; for example, GHC.HsToCore.Utils.mkSelectorBinds uses collectPatBinders. In a lazy pattern, for example f ~(C x y) = ..., we want to generate bindings for x,y but not for dictionaries bound by C. (The type checker ensures they would not be used.) Desugaring of arrow case expressions needs these bindings (see GHC.HsToCore.Arrows and arrowcase1), but SPJ (Jan 2007) says it's safer for it to use its own pat-binder-collector: Accordingly to the last sentence, this patch doesn't make any attempt at factorizing both codes. Fix #18950 - - - - - 29173f88 by Sylvain Henry at 2021-01-22T14:58:53-05:00 Factorize and document binder collect functions Parameterize collect*Binders functions with a flag indicating if evidence binders should be collected. The related note in GHC.Hs.Utils has been updated. Bump haddock submodule - - - - - a255b4e3 by Matthew Pickering at 2021-01-22T14:59:30-05:00 ghc-heap: Allow more control about decoding CCS fields We have to be careful not to decode too much, too eagerly, as in ghc-debug this will lead to references to memory locations outside of the currently copied closure. Fixes #19038 - - - - - 34950fb8 by Simon Peyton Jones at 2021-01-22T15:00:07-05:00 Fix error recovery in solveEqualities As #19142 showed, with -fdefer-type-errors we were allowing compilation to proceed despite a fatal kind error. This patch fixes it, as described in the new note in GHC.Tc.Solver, Note [Wrapping failing kind equalities] Also fixes #19158 Also when checking default( ty1, ty2, ... ) only consider a possible default (C ty2) if ty2 is kind-compatible with C. Previously we could form kind-incompatible constraints, with who knows what kind of chaos resulting. (Actually, no chaos results, but that's only by accident. It's plain wrong to form the constraint (Num Either) for example.) I just happened to notice this during fixing #19142. - - - - - a64f21e9 by Alfredo Di Napoli at 2021-01-22T15:00:47-05:00 Parameterise Messages over e This commit paves the way to a richer and more structured representation of GHC error messages, as per GHC proposal #306. More specifically 'Messages' from 'GHC.Types.Error' now gains an extra type parameter, that we instantiate to 'ErrDoc' for now. Later, this will allow us to replace ErrDoc with something more structure (for example messages coming from the parser, the typechecker etc). - - - - - c36a4f63 by Alfredo Di Napoli at 2021-01-22T15:00:47-05:00 Fix tests relying on same-line diagnostic ordering This commit fixes 19 tests which were failing due to the use of `consBag` / `snocBag`, which have been now replaced by `addMessage`. This means that now GHC would output things in different order but only for /diagnostics on the same line/, so this is just reflecting that. The "normal" order of messages is still guaranteed. - - - - - 2267d42a by John Ericson at 2021-01-22T15:01:24-05:00 Add 32-bit ops to T file I forgot to add before - - - - - 22d01924 by John Ericson at 2021-01-22T15:01:24-05:00 C-- shift amount is always native size, not shiftee size This isn't a bug yet, because we only shift native-sized types, but I hope to change that. - - - - - faf164db by John Ericson at 2021-01-22T15:01:25-05:00 Cleanup primop constant folding rules in a few ways - `leftZero`, `rightZero` and `zeroElem` could all be written using `isZeroLit` - "modulo 1" rules could be written with `nonOneLit 1 $> Lit zero<type>` All are due to @hsyl20; thanks! - - - - - 0eaf63b6 by John Ericson at 2021-01-22T15:01:25-05:00 Add missing fixed-sized primops and constant folding - `inversePrimOp` is renamed to `semiInversePrimOp` to indicate the given primop is only a right inverse, not left inverse (and contra-wise for the primop which we are giving rules for). This explains why are new usage is not incorrect. - The removed `subsumedByPrimOp` calls were actually dead as the match on ill-typed code. @hsyl20 pointed this out in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4390#note_311912, Metric Decrease: T13701 - - - - - 6fbfde95 by John Ericson at 2021-01-22T15:01:25-05:00 Test constant folding for sized types - - - - - 887eb6ec by Sylvain Henry at 2021-01-22T15:02:05-05:00 Enhance Data instance generation Use `mkConstrTag` to explicitly pass the constructor tag instead of using `mkConstr` which queries the tag at runtime by querying the index of the constructor name (a string) in the list of constructor names. Perf improvement: T16577(normal) ghc/alloc 11325573876.0 9249786992.0 -18.3% GOOD Thanks to @sgraf812 for suggesting an additional list fusion fix during reviews. Metric Decrease: T16577 - - - - - 957b5376 by Sylvain Henry at 2021-01-22T15:02:45-05:00 Core: introduce Alt/AnnAlt/IfaceAlt datatypes Alt, AnnAlt and IfaceAlt were using triples. This patch makes them use dedicated types so that we can try to make some fields strict (for example) in the future. - - - - - db16302c by Sylvain Henry at 2021-01-22T15:03:25-05:00 LLVM: fix sized shift primops (#19215) Ensure that shift amount parameter has the same type as the parameter to shift. - - - - - fcbf21aa by Ben Gamari at 2021-01-22T15:04:02-05:00 gitlab-ci: Fix perf metric pushing Previously we would inexplicably append the key to id_rsa. Fixes #19225. - - - - - 4bb9a349 by Oleg Grenrus at 2021-01-22T15:04:42-05:00 Change replicateM doctest example - - - - - 637ae302 by Stefan Schulze Frielinghaus at 2021-01-22T15:05:21-05:00 CmmToC: Fix translation of Cmm literals to word sized literals For big-endian machines remove the byte swap in the non-recursive call of goSubWord since the integer is already in proper format. - - - - - 532337cb by Cheng Shao at 2021-01-22T15:06:00-05:00 Optimize some rts_mk/rts_get functions in RtsAPI.c - All rts_mk functions return the tagged closure address - rts_mkChar/rts_mkInt avoid allocation when the argument is within the CHARLIKE/INTLIKE range - rts_getBool avoids a memory load by checking the closure tag - In rts_mkInt64/rts_mkWord64, allocated closure payload size is either 1 or 2 words depending on target architecture word size - - - - - 13d876ba by Sylvain Henry at 2021-01-22T15:06:39-05:00 Enhance nested TransCo pretty-printing Nested TransCo were printed with a lot of indentation, e.g.: `cast` (Sub (Sym (Foo.D:R:Index[0] <Bool>_N <'[]>_N)) ; ((Index (Sym (SubDef (<1>_N, <1>_N))) <'[Bool]>_N)_R ; ... With this patch we print them as follows: `cast` (Sub (Sym (Foo.D:R:Index[0] <Bool>_N <'[]>_N)) ; (Index (Sym (SubDef (<1>_N, <1>_N))) <'[Bool]>_N)_R ; Sub (Sym (Foo.D:R:Index[1] <1>_N <Int>_N <'[Bool]>_N)) ; (Index (Sym (SubDef (<2>_N, <1>_N))) <'[Int, Bool]>_N)_R - - - - - 5836efd7 by Andreas Klebinger at 2021-01-22T15:07:16-05:00 Force inlining of deRefStablePtr to silence warnings - - - - - 7b6bb480 by Andreas Klebinger at 2021-01-22T15:07:53-05:00 Make DmdAnalOpts a newtype - - - - - 420ef55a by Cheng Shao at 2021-01-22T15:08:33-05:00 Remove legacy comment in validate script The validate flavour is already defined and used in hadrian, so this legacy comment should be removed. - - - - - 8fd855f0 by Richard Eisenberg at 2021-01-23T15:29:58-05:00 Make matchableGivens more reliably correct. This has two fixes: 1. Take TyVarTvs into account in matchableGivens. This fixes #19106. 2. Don't allow unifying alpha ~ Maybe alpha. This fixes #19107. This patch also removes a redundant Note and redirects references to a better replacement. Also some refactoring/improvements around the BindFun in the pure unifier, which now can take the RHS type into account. Close #19106. Close #19107. Test case: partial-sigs/should_compile/T19106, typecheck/should_compile/T19107 - - - - - 8f610e52 by Koz Ross at 2021-01-23T15:30:37-05:00 Implement #15993 - - - - - 28ef8a8a by Koz Ross at 2021-01-23T15:30:37-05:00 Add @since annotations for And, Ior, Xor, Iff type class instances - - - - - 1a3f3247 by Koz Ross at 2021-01-23T15:30:37-05:00 Add headers for Data.Bits documentation - - - - - 97208613 by Koz Ross at 2021-01-23T15:30:37-05:00 FiniteBits for some newtype instances, notes on why - - - - - 773e2828 by Sylvain Henry at 2021-01-23T15:31:20-05:00 Bignum: add Natural constant folding rules (#15821) * Implement constant folding rules for Natural (similar to Integer ones) * Add mkCoreUbxSum helper in GHC.Core.Make * Remove naturalTo/FromInt We now only provide `naturalTo/FromWord` as the semantics is clear (truncate/zero-extend). For Int we have to deal with negative numbers (throw an exception? convert to Word beforehand?) so we leave the decision about what to do to the caller. Moreover, now that we have sized types (Int8#, Int16#, ..., Word8#, etc.) there is no reason to bless `Int#` more than `Int8#` or `Word8#` (for example). * Replaced a few `()` with `(# #)` - - - - - e6e1cf74 by Cheng Shao at 2021-01-23T21:32:43-05:00 Add _validatebuild to .gitignore [ci skip] - - - - - 81f06655 by John Ericson at 2021-01-23T21:32:47-05:00 Separate AST from GhcPass (#18936) ---------------- What: There are two splits. The first spit is: - `Language.Haskell.Syntax.Extension` - `GHC.Hs.Extension` where the former now just contains helpers like `NoExtCon` and all the families, and the latter is everything having to do with `GhcPass`. The second split is: - `Language.Haskell.Syntax.<mod>` - `GHC.Hs.<mod>` Where the former contains all the data definitions, and the few helpers that don't use `GhcPass`, and the latter contains everything else. The second modules also reexport the former. ---------------- Why: See the issue for more details, but in short answer is we're trying to grasp at the modularity TTG is supposed to offer, after a long time of mainly just getting the safety benefits of more complete pattern matching on the AST. Now, we have an AST datatype which, without `GhcPass` is decently stripped of GHC-specific concerns. Whereas before, not was it GHC-specific, it was aware of all the GHC phases despite the parameterization, with the instances and parametric data structure side-by-side. For what it's worth there are also some smaller, imminent benefits: - The latter change also splits a strongly connected component in two, since none of the `Language.Haskell.Syntax.*` modules import the older ones. - A few TTG violations (Using GhcPass directly in the AST) in `Expr` are now more explicitly accounted for with new type families to provide the necessary indirection. ----------------- Future work: - I don't see why all the type families should live in `Language.Haskell.Syntax.Extension`. That seems anti-modular for little benefit. All the ones used just once can be moved next to the AST type they serve as an extension point for. - Decide what to do with the `Outputable` instances. Some of these are no orphans because they referred to `GhcPass`, and had to be moved. I think the types could be generalized so they don't refer to `GhcPass` and therefore can be moved back, but having gotten flak for increasing the size and complexity types when generalizing before, I did *not* want to do this. - We should triage the remaining contents of `GHC.Hs.<mod>`. The renaming helpers are somewhat odd for needing `GhcPass`. We might consider if they are a) in fact only needed by one phase b) can be generalized to be non-GhcPass-specific (e.g. take a callback rather than GADT-match with `IsPass`) and then they can live in `Language.Haskell.Syntax.<mod>`. For more details, see https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow Bumps Haddock submodule - - - - - 8ec6d62a by John Ericson at 2021-01-23T21:32:47-05:00 Track the dependencies of `GHC.Hs.Expr.Types` Thery is still, in my view, far too numerous, but I believe this won't be too hard to improve upon. At the very lease, we can always add more extension points! - - - - - b18d9e97 by Sebastian Graf at 2021-01-23T21:32:47-05:00 CoreToStg.Prep: Speculative evaluation >From `Note [Speculative evaluation]`: Since call-by-value is much cheaper than call-by-need, we case-bind arguments that are either 1. Strictly evaluated anyway, according to the StrictSig of the callee, or 2. ok-for-spec, according to 'exprOkForSpeculation' While (1) is a no-brainer and always beneficial, (2) is a bit more subtle, as the careful haddock for 'exprOkForSpeculation' points out. Still, by case-binding the argument we don't need to allocate a thunk for it, whose closure must be retained as long as the callee might evaluate it. And if it is evaluated on most code paths anyway, we get to turn the unknown eval in the callee into a known call at the call site. NoFib Results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- ansi -9.4% -10.4% maillist -0.1% -0.1% paraffins -0.7% -0.5% scc -0.0% +0.1% treejoin -0.0% -0.1% -------------------------------------------------------------------------------- Min -9.4% -10.4% Max 0.0% +0.1% Geometric Mean -0.1% -0.1% ``` Fixes #19224. - - - - - 083d7aeb by Duncan Coutts at 2021-01-25T05:11:14-05:00 Move win32/IOManager to win32/MIOManager It is only for MIO, and we want to use the generic name IOManager for the name of the common parts of the interface and dispatch. - - - - - 8bdbfdd8 by Duncan Coutts at 2021-01-25T05:11:14-05:00 Rename includes/rts/IOManager.h to IOInterface.h Naming is hard. Where we want to get to is to have a clear internal and external API for the IO manager within the RTS. What we have right now is just the external API (used in base for the Haskell side of the threaded IO manager impls) living in includes/rts/IOManager.h. We want to add a clear RTS internal API, which really ought to live in rts/IOManager.h. Several people think it's too confusing to have both: * includes/rts/IOManager.h for the external API * rts/IOManager.h for the internal API So the plan is to add rts/IOManager.{h,c} as the internal parts, and rename the external part to be includes/rts/IOInterface.h. It is admittidly not great to have .h files in includes/rts/ called "interface" since by definition, every .h fle under includes/ is an interface! Alternative naming scheme suggestions welcome! - - - - - 54946e4f by Duncan Coutts at 2021-01-25T05:11:14-05:00 Start to centralise the I/O manager hooks from other bits of the RTS It is currently rather difficult to understand or work with the various I/O manager implementations. This is for a few reasons: 1. They do not have a clear or common API. There are some common function names, but a lot of things just get called directly. 2. They have hooks into many other parts of the RTS where they get called from. 3. There is a _lot_ of CPP involved, both THREADED_RTS vs !THREADED_RTS and also mingw32_HOST_OS vs !mingw32_HOST_OS. This doesn't really identify the I/O manager implementation. 4. They have data structures with unclear ownership, or that are co-owned with other components like the scheduler. Some data structures are used by multiple I/O managers. One thing that would help is if the interface between the I/O managers and the rest of the RTS was clearer, even if it was not completely uniform. Centralising it would make it easier to see how to reduce any unnecessary diversity in the interfaces. This patch makes a start by creating a new IOManager.{h,c} module. It is initially empty, but we will move things into it in subsequent patches. - - - - - 455ad48b by Duncan Coutts at 2021-01-25T05:11:14-05:00 Move setIOManagerControlFd from Capability.c to IOManager.c This is a better home for it. It is not really an aspect of capabilities. It is specific to one of the I/O manager impls. - - - - - e93384e8 by Duncan Coutts at 2021-01-25T05:11:14-05:00 Move ioManager{Start,Wakeup,Die} to internal IOManager.h Move them from the external IOInterface.h to the internal IOManager.h. The functions are all in fact internal. They are not used from the base library at all. Remove ioManagerWakeup as an exported symbol. It is not used elsewhere. - - - - - 4ad726fc by Duncan Coutts at 2021-01-25T05:11:14-05:00 Move hooks for I/O manager startup / shutdown into IOManager.{c,h} - - - - - d345d3be by Duncan Coutts at 2021-01-25T05:11:14-05:00 Replace a direct call to ioManagerStartCap with a new hook Replace a direct call to ioManagerStartCap in the forkProcess in Schedule.c with a new hook initIOManagerAfterFork in IOManager. This replaces a direct hook in the scheduler from the a single I/O manager impl (the threaded unix one) with a generic hook. Add some commentrary on opportunities for future rationalisation. - - - - - 9a7d19ba by Duncan Coutts at 2021-01-25T05:11:14-05:00 Replace a ioManagerDie call with stopIOManager The latter is the proper hook defined in IOManager.h. The former is part of a specific I/O manager implementation (the threaded unix one). - - - - - e3564e38 by Duncan Coutts at 2021-01-25T05:11:14-05:00 Add a common wakeupIOManager hook Use in the scheduler in threaded mode. Replaces the direct call to ioManagerWakeup which are part of specific I/O manager implementations. - - - - - 34a8a0e4 by Duncan Coutts at 2021-01-25T05:11:14-05:00 Remove ioManager{Start,Die,Wakeup} from IOManager.h They are not part of the IOManager interface used within the rest of the RTS. They are the part of the interface of specific I/O manager implementations. They are no longer called directly elsewhere in the RTS, and are now only called by the dispatch functions in IOManager.c - - - - - 92573883 by Matthew Pickering at 2021-01-27T17:38:32-05:00 Deprecate -h flag It is confusing that it defaults to two different things depending on whether we are in the profiling way or not. Use -hc if you have a profiling build Use -hT if you have a normal build Fixes #19031 - - - - - 93ae0e2a by Aaron Allen at 2021-01-27T17:39:11-05:00 Add additional context to :doc output (#19055) With this change, the type/kind of an object as well as it's category and definition site are added to the output of the :doc command for each object matching the argument string. - - - - - 5d6009a8 by Ben Gamari at 2021-01-27T17:39:49-05:00 Add instances for GHC.Tuple.Solo The `Applicative` instance is the most important one (for array/vector/sequence indexing purposes), but it deserves all the usual ones. T12545 does silly 1% wibbles both ways, it seems, maybe depending on architecture. Metric Increase: T12545 Metric Decrease: T12545 - - - - - 08fba093 by Hécate at 2021-01-27T17:40:32-05:00 Remove -XMonadFailDesugaring references - - - - - e71ed07d by Hécate at 2021-01-27T17:40:32-05:00 Add a section about failable patterns in the GHC user's guide - - - - - 2f689a8b by Adam Gundry at 2021-01-27T17:41:08-05:00 Add regression test for #11228 - - - - - 189efc39 by Richard Eisenberg at 2021-01-27T17:41:44-05:00 Remove some redundant validity checks. This commit also consolidates documentation in the user manual around UndecidableSuperClasses, UndecidableInstances, and FlexibleContexts. Close #19186. Close #19187. Test case: typecheck/should_compile/T19186, typecheck/should_fail/T19187{,a} - - - - - 614cb069 by Sebastian Graf at 2021-01-27T17:42:21-05:00 hadrian: Fix `lookupInPath` on Windows (#19249) By querying the PATH variable explicitly via `getSearchPath`, we can work around the special behavior of `findExecutable` on Windows, where it also searches in System32. Fixes #19249. - - - - - 9c87f97e by Sylvain Henry at 2021-01-27T17:43:05-05:00 Fix spurious failures of T16916 on CI (#16966) * disable idle GC which has a big impact on time measures * use average measures (before and after event registration) * use warmup measures (for some reason the first measure of a batch seems to be often quite different from the others) * drop the division by monotonic clock time: this clock is impacted by the load of the runner. We only want to measure the time spent in the RTS while the mutator is idle so I don't understand why it was used. - - - - - 831ba0fb by Oleg Grenrus at 2021-01-27T17:43:49-05:00 Fix doctest examples in Data.Bits - - - - - 0da1f19e by Cheng Shao at 2021-01-27T17:44:27-05:00 Respect $AR in configure script Previously, the configure script doesn't respect $AR. This causes the nixpkgs GHC to capture "ar" instead of the absolute nix store path of ar in the global config. The original patch comes from https://github.com/input-output-hk/haskell.nix/blob/master/overlays/patches/ghc/respect-ar-path.patch. - - - - - 7b0b133d by Koz Ross at 2021-01-27T17:45:06-05:00 Implement #18519 - - - - - 644e80fe by Andreas Klebinger at 2021-01-28T14:36:48-05:00 rts: sm/GC.c: make num_idle unsigned We compare it to n_gc_idle_threads which is unsigned as well. So make both signed to avoid a warning. - - - - - b5d0a136 by Andreas Klebinger at 2021-01-28T14:36:48-05:00 Use validate flavour for all CI builds. This also means we compile GHC with -O1 instead of -O2 for some platforms for CI. As a result a lot of test metrics got worse which we now have to accept. ------------------------- Metric Increase: ManyAlternatives ManyConstructors MultiLayerModules Naperian T10421 T12150 T12227 T12234 T12425 T12545 T12707 T13035 T13253 T13253-spj T13701 T13379 T13719 T14697 T16577 T18282 T18698a T18698b T1969 T3064 T3294 T4801 T5205 T5321FD T5321Fun T5631 T6048 T783 T9020 T9203 T9233 T9630 T9872a T9872b T9872c T9872d T9961 haddock.Cabal haddock.base haddock.compiler parsing001 T5642 WWRec T14683 T15164 T18304 T18923 ------------------------- - - - - - b3b4d3c1 by Andreas Klebinger at 2021-01-28T14:37:25-05:00 SimplM: Create uniques via IO instead of threading - - - - - 2e44165f by Matthew Pickering at 2021-01-28T14:38:02-05:00 Reduce default test verbosity - - - - - 38adba6b by Joachim Breitner at 2021-01-28T14:38:39-05:00 Bump haddock submodule to get this commit: commit 0952d94a2e30a3e7cddbede811b15fa70f7b9462 (HEAD) Author: Joachim Breitner <mail at joachim-breitner.de> Date: Tue Jan 19 11:39:38 2021 +0100 Make haddock more robust to changes to the `Language` data type With the introduction of GHC2021, the `Languages` data type in GHC will grow. In preparation of that (and to avoid changing haddock with each new language), this change makes the code handle extensions to that data type gracefully. (cherry picked from commit c341dd7c9c3fc5ebc83a2d577c5a726f3eb152a5) This can go in as preparation for !4853 - - - - - 20fbb7c6 by Denis Frezzato at 2021-01-28T14:39:17-05:00 Fix code formatting in `HasCallStack` section - - - - - 0249974e by Sylvain Henry at 2021-01-28T14:39:59-05:00 Fix strictness in TyCo.Tidy (#14738) Metric Decrease: T12545 T14683 T16577 T5321Fun T5642 - - - - - 7105cda8 by Ben Gamari at 2021-01-29T04:01:52-05:00 typecheck: Account for -XStrict in irrefutability check When -XStrict is enabled the rules for irrefutability are slightly modified. Specifically, the pattern in a program like do ~(Just hi) <- expr cannot be considered irrefutable. The ~ here merely disables the bang that -XStrict would usually apply, rendering the program equivalent to the following without -XStrict do Just hi <- expr To achieve make this pattern irrefutable with -XStrict the user would rather need to write do ~(~(Just hi)) <- expr Failing to account for this resulted in #19027. To fix this isIrrefutableHsPat takes care to check for two the irrefutability of the inner pattern when it encounters a LazyPat and -XStrict is enabled. - - - - - 37378a0b by Leif Metcalf at 2021-01-29T04:02:41-05:00 Remove StgLam StgLam is used exclusively in the work of CoreToStg, but there's nothing in the type of StgExpr that indicates this, so we're forced throughout the Stg.* codebase to handle cases like: case expr of ... StgLam lam -> panic "Unexpected StgLam" ... This patch removes the StgLam constructor from the base StgExpr so these cases no longer need to be handled. Instead, we use a new intermediate type in CoreToStg, PreStgRhs, to represent the RHS expression of a binding. - - - - - 6fc92084 by Oleg Grenrus at 2021-01-29T04:03:22-05:00 Add explicit import lists to Data.List imports Related to a future change in Data.List, https://downloads.haskell.org/ghc/8.10.3/docs/html/users_guide/using-warnings.html?highlight=wcompat#ghc-flag--Wcompat-unqualified-imports Companion pull&merge requests: - https://github.com/judah/haskeline/pull/153 - https://github.com/haskell/containers/pull/762 - https://gitlab.haskell.org/ghc/packages/hpc/-/merge_requests/9 After these the actual change in Data.List should be easy to do. - - - - - 18e106a8 by Sylvain Henry at 2021-01-29T04:04:12-05:00 Add missing .hi-boot dependencies with ghc -M (#14482) - - - - - 75accd54 by Leif Metcalf at 2021-01-29T04:04:48-05:00 Warn about using quick with profiling - - - - - ae8379ab by Sylvain Henry at 2021-01-29T04:05:27-05:00 Ppr: compute length of string literals at compile time (#19266) SDoc string literals created for example with `text "xyz"` are converted into `PtrString` (`Addr#` + size in bytes) with a rewrite rule to avoid allocating a String. Before this patch, the size in bytes was still computed at runtime. For every literal, we obtained the following pseudo STG: x :: Addr# x = "xzy"# s :: PtrString s = \u [] case ffi:strlen [x realWorld#] of (# _, sz #) -> PtrString [x sz] But since GHC 9.0, we can use `cstringLength#` instead to get: x :: Addr# x = "xzy"# s :: PtrString s = PtrString! [x 3#] Literals become statically known constructor applications. Allocations seem to decrease a little in perf tests (between -0.1% and -0.7% on CI). - - - - - 5140841c by Krzysztof Gogolewski at 2021-01-29T04:06:03-05:00 Fix check-uniques script It was checking the old path compiler/prelude/*, outdated with the new module hierarchy. I added a sanity check to avoid this in the future. - - - - - 3b823533 by Simon Peyton Jones at 2021-01-29T23:09:58-05:00 Make PatSyn immutable Provoked by #19074, this patch makes GHC.Core.PatSyn.PatSyn immutable, by recording only the *Name* of the matcher and builder rather than (as currently) the *Id*. See Note [Keep Ids out of PatSyn] in GHC.Core.PatSyn. Updates haddock submodule. - - - - - bd0b2726 by Krzysztof Gogolewski at 2021-01-29T23:10:35-05:00 Fix parsing of -fstg-lift-lams-non-rec -fstg-lift-lams-rec-* and -fstg-lift-lams-non-rec-* were setting the same field. Fix manual: -fstg-lift-lams-non-rec-args is disabled by -fstg-lift-lams-non-rec-args-any, there's no -fno-stg-lift-*. - - - - - f5d62eb2 by Ben Gamari at 2021-01-30T14:11:48-05:00 ghci: Take editor from VISUAL environment variable Following the example of `git`, as noted in #19030. Fixes #19030. - - - - - 621d8cf7 by Ben Gamari at 2021-01-30T14:12:24-05:00 configure: Break up AC_CONFIG_FILES list - - - - - 55ef3bdc by Ben Gamari at 2021-01-30T14:12:24-05:00 hadrian: Introduce ghci-wrapper package This wraps the existing GHCi wrapper script (driver/ghci/ghci.c) in a cabal file and adds the package to Hadrian. - - - - - 73fa75f5 by GHC GitLab CI at 2021-01-30T14:12:24-05:00 compare-flags: Strip whitespace from flags read from --show-options Otherwise we end up with terminating \r characters on Windows. - - - - - 69cab37a by Simon Peyton Jones at 2021-01-30T14:13:00-05:00 Zonk the returned kind in tcFamTyPats The motivation is given in Note [tcFamTyPats: zonking the result kind]. Fixes #19250 -- the fix is easy. - - - - - a3d995fa by Sylvain Henry at 2021-01-30T14:13:41-05:00 Fix -dynamic-too with wired-in modules (#19264) See T19264 for a tricky corner case when explicitly importing GHC.Num.BigNat and another module. With -dynamic-too, the FinderCache contains paths for non-dynamic interfaces so they must be loaded first, which is usually the case, except for some interfaces loaded in the backend (e.g. in CorePrep). So we must run the backend for the non-dynamic way first for -dynamic-too to work as it is but I broke this invariant in c85f4928d4dbb2eb2cf906d08bfe7620d6f04ca5 by mistakenly making the backend run for the dynamic way first. - - - - - eb90d239 by Benjamin Maurer at 2021-01-30T14:14:17-05:00 Fix description of -fregs-graph (not implied by -O2, linked issue was closed) - - - - - 14c4f701 by Krzysztof Gogolewski at 2021-01-30T21:11:21+01:00 Documentation fixes - Add missing :since: for NondecreasingIndentation and OverlappingInstances - Remove duplicated descriptions for Safe Haskell flags and UndecidableInstances. Instead, the sections contain a link. - compare-flags: Also check for options supported by ghci. This uncovered two more that are not documented. The flag -smp was removed. - Formatting fixes - Remove the warning about -XNoImplicitPrelude - it was written in 1996, the extension is no longer dangerous. - Fix misspelled :reverse: flags Fixes #18958. - - - - - d4bcd37f by Ryan Scott at 2021-02-01T03:12:07-05:00 Fix accidental unsoundness in Data.Typeable.Internal.mkTypeLitFromString An accidental use of `tcSymbol` instead of `tcNat` in the `TypeLitNat` case of `mkTypeLitFromString` meant that it was possible to unsafely equate `Nat` with `Symbol`. A consequence of this is that you could write `unsafeCoerce`, as observed in #19288. This is fixed easily enough, thankfully. Fixes #19288. - - - - - 5464845a by Ryan Scott at 2021-02-01T14:05:31-05:00 Add driver/ghci/ghci-wrapper.cabal to .gitignore After commit 55ef3bdc28681a22ceccf207707c49229f9b7559, running `./configure` now generates a `driver/ghci/ghci-wrapper.cabal` file from `driver/ghci/ghci-wrapper.cabal.in`, which pollutes the `git` tree: ``` $ git status On branch master Your branch is up to date with 'origin/master'. Untracked files: (use "git add <file>..." to include in what will be committed) driver/ghci/ghci-wrapper.cabal nothing added to commit but untracked files present (use "git add" to track) ``` Since `driver/ghci/ghci-wrapper.cabal` is autogenerated, the sensible thing to do is to add it to `.gitignore`. While I was in town, I also added the standard `*.in` file disclaimer to `driver/ghci/ghci-wrapper.cabal.in`. [ci skip] - - - - - ddc2a759 by Alfredo Di Napoli at 2021-02-01T14:06:11-05:00 Remove ErrDoc and MsgDoc This commit boldly removes the ErrDoc and the MsgDoc from the codebase. The former was introduced with the only purpose of classifying errors according to their importance, but a similar result can be obtained just by having a simple [SDoc], and placing bullets after each of them. On top of that I have taken the perhaps controversial decision to also banish MsgDoc, as it was merely a type alias over an SDoc and as such it wasn't offering any extra type safety. Granted, it was perhaps making type signatures slightly more "focused", but at the expense of cognitive burden: if it's really just an SDoc, let's call it with its proper name. - - - - - b1a17507 by Alfredo Di Napoli at 2021-02-01T14:06:11-05:00 Rename ErrMsg into MsgEnvelope Updates Haddock submodule - - - - - c0709c1d by Alfredo Di Napoli at 2021-02-01T14:06:11-05:00 Introduce the DecoratedSDoc type This commit introduces a DecoratedSDoc type which replaces the old ErrDoc, and hopefully better reflects the intent. - - - - - 7d910fd8 by Ben Gamari at 2021-02-02T12:24:11-05:00 typecheck: Eliminate allocations in tc_eq_type Previously tc_eq_type would allocate a number of closures due to the two boolean "mode" flags, despite the fact that these were always statically known. To avoid this we force tc_eq_type to inline into its call sites, allowing the simplifier to eliminate both some runtime branches and the closure allocations. - - - - - ddbdec41 by Matthew Pickering at 2021-02-02T12:24:47-05:00 Add missing instances to ghc-heap types These instances are useful so that a `GenClosure` form `ghc-heap` can be used as a key in a `Map`. Therefore the order itself is not important but just the fact that there is one. - - - - - 6085cfb5 by wygulmage at 2021-02-05T19:08:50-05:00 Remove misleading 'lazy' pattern matches from 'head' and 'tail' in Data.List.NonEmpty - - - - - a5a5c7e0 by Ben Gamari at 2021-02-05T19:09:27-05:00 CallArity: Various comment fixes - - - - - 441724e3 by Ben Gamari at 2021-02-05T19:09:27-05:00 UnVarGraph: Use foldl' rather than foldr in unionUnVarSets This is avoids pushing the entire list to the stack before we can begin computing the result. - - - - - c7922ced by Matthew Pickering at 2021-02-05T19:10:04-05:00 Hadrian: Add support for packages with C++ files - - - - - c5ace760 by Andreas Klebinger at 2021-02-05T19:10:41-05:00 Try eta expanding FCode (See #18202) Also updates the note with the case of multi-argument lambdas. Seems slightly beneficial based on the Cabal test: -O0: -1MB allocations (out of 50GB) -O : -1MB allocations (out of ~200GB) - - - - - 003df39c by Stefan Schulze Frielinghaus at 2021-02-05T19:11:18-05:00 rts: Use properly sized pointers in e.g. rts_mkInt8 Since commit be5d74caab the payload of a closure of Int<N> or Word<N> is not extended anymore to the machines word size. Instead, only the first N bits of a payload are written. This patch ensures that only those bits are read/written independent of the machines endianness. - - - - - fe789978 by Sylvain Henry at 2021-02-05T19:12:01-05:00 IntVar: fix allocation size As found by @phadej in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4740/diffs#note_327510 Also fix FastMutInt which allocating the size in bits instead of bytes. - - - - - 792191e4 by Stefan Schulze Frielinghaus at 2021-02-05T19:12:39-05:00 FFI: Revisit fix pass small ints in foreign call wrappers Since commit be5d74ca small ints/words are passed according to their natural size which obsoletes fix from commit 01f7052cc1. Reverted 01f7052cc1 but kept the introduced test case. - - - - - d4618aeb by Sebastian Graf at 2021-02-05T19:13:15-05:00 Mark both parameters of SimplM one-shot (#19302) Just marking the `SimplTopEnv` parameter as one-shot was not enough to eta-expand `simplExpr`. Fixes #19302. - - - - - 97a8fe7b by Stefan Schulze Frielinghaus at 2021-02-05T19:13:52-05:00 rts: Fix arguments for foreign calls of interpreter Function arguments passed to the interpreter are extended to whole words. However, foreign function interface expects correctly typed argument pointers. Accordingly, we have to adjust argument pointers in case of a big-endian architecture. In contrast to function arguments where subwords are passed in the low bytes of a word, the return value is expected to reside in the high bytes of a word. - - - - - a9b89d5a by Andreas Klebinger at 2021-02-05T19:14:29-05:00 validate: Enable tarball autodownload by default. Fixes #19307 - - - - - 640a3ece by Basile Henry at 2021-02-05T19:15:06-05:00 Fix typo in qualified_do.rst - - - - - 7f3524ef by Daniel Rogozin at 2021-02-06T09:26:51-05:00 The Char kind (#11342) Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Implement GHC Proposal #387 * Parse char literals 'x' at the type level * New built-in type families CmpChar, ConsSymbol, UnconsSymbol * New KnownChar class (cf. KnownSymbol and KnownNat) * New SomeChar type (cf. SomeSymbol and SomeNat) * CharTyLit support in template-haskell Updated submodules: binary, haddock. Metric Decrease: T5205 haddock.base Metric Increase: Naperian T13035 - - - - - 18313374 by Simon Peyton Jones at 2021-02-06T09:27:28-05:00 Fix buglet in expandSynTyCon_maybe The fix for #17958, implemented in MR !2952, introduced a small bug in GHC.Core.TyCon.expandSynTyCon_maybe, in the case of under-saturated type synonyms. This MR fixes the bug, very easy. Fixes #19279 - - - - - b8d8f31e by Andreas Klebinger at 2021-02-06T09:28:04-05:00 Make unsafeDupablePerformIO have a lazy demand When a user writes code like: unsafePerformIO $ do let x = f x writeIORef ref x return x We might expect that the write happens before we evaluate `f x`. Sadly this wasn't to case for reasons detailed in #19181. We fix this by avoiding the strict demand by turning: unsafeDupablePerformIO (IO m) = case runRW# m of (# _, a #) -> a into unsafeDupablePerformIO (IO m) = case runRW# m of (# _, a #) -> lazy a This makes the above code lazy in x. And ensures the side effect of the write happens before the evaluation of `f x`. If a user *wants* the code to be strict on the returned value he can simply use `return $! x`. This fixes #19181 - - - - - d93d7fc6 by Simon Peyton Jones at 2021-02-06T09:28:41-05:00 Make pattern synonyms play with CallStack This small patch makes pattern synonyms play nicely with CallStack constraints, using logic explained in GHC.Tc.Gen.Pat Note [Call-stack tracing of pattern synonyms] Fixes #19289 - - - - - 4e6bb326 by Krzysztof Gogolewski at 2021-02-06T09:29:17-05:00 Add a test for #18736 Commit 65721691ce9c (Improve inference with linear types, !4632) fixed the bug. Closes #18736. - - - - - 9b7dcd80 by Simon Jakobi at 2021-02-06T09:29:55-05:00 base: Fix since-annotation for Data.List.singleton - - - - - 3da472f0 by Brian Wignall at 2021-02-06T09:30:34-05:00 Fix typos - - - - - ab5fd982 by Ben Gamari at 2021-02-06T12:01:52-05:00 Bump Haddock submodule Merged ghc-8.10 into ghc-head. - - - - - 891a791f by Simon Peyton Jones at 2021-02-09T16:21:40-05:00 Reduce inlining in deeply-nested cases This adds a new heuristic, controllable via two new flags to better tune inlining behaviour. The new flags are -funfolding-case-threshold and -funfolding-case-scaling which are document both in the user guide and in Note [Avoid inlining into deeply nested cases]. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - be423178 by Krzysztof Gogolewski at 2021-02-09T16:22:17-05:00 Fix pretty-printing of invisible arguments for FUN 'Many (#19310) - - - - - 17a89b1b by Simon Peyton Jones at 2021-02-09T16:22:52-05:00 Fix a long standing bug in constraint solving When combining Inert: [W] C ty1 ty2 Work item: [D] C ty1 ty2 we were simply discarding the Derived one. Not good! We should turn the inert back into [WD] or keep both. E.g. fundeps work only on Derived (see isImprovable). This little patch fixes it. The bug is hard to tickle, but #19315 did so. The fix is a little messy (see Note [KeepBoth] plus the change in addDictCt), but I am disinclined to refine it further because it'll all be swept away when we Kill Deriveds. - - - - - 3d27bc30 by Masahiro Sakai at 2021-02-10T14:30:11-05:00 Fix example code of "Making a Haskell library that can be called from foreign code" section "+RTS" in argv[0] is interpreted as a program name and does not work as an indicator of RTS options. - - - - - 40983d23 by Fendor at 2021-02-10T14:30:54-05:00 Add -Wsafe to flags not enabled by -Wall - - - - - 8e2f85f6 by Sylvain Henry at 2021-02-13T21:27:34-05:00 Refactor Logger Before this patch, the only way to override GHC's default logging behavior was to set `log_action`, `dump_action` and `trace_action` fields in DynFlags. This patch introduces a new Logger abstraction and stores it in HscEnv instead. This is part of #17957 (avoid storing state in DynFlags). DynFlags are duplicated and updated per-module (because of OPTIONS_GHC pragma), so we shouldn't store global state in them. This patch also fixes a race in parallel "--make" mode which updated the `generatedDumps` IORef concurrently. Bump haddock submodule The increase in MultilayerModules is tracked in #19293. Metric Increase: MultiLayerModules - - - - - 4b068fc3 by Marcin Szamotulski at 2021-02-13T21:28:13-05:00 Improve bracket documentation - - - - - 448fd22d by Marcin Szamotulski at 2021-02-13T21:28:13-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - f1362008 by Joachim Breitner at 2021-02-13T21:28:49-05:00 Always set `safeInferred`, not only when it turns `False` previously, `safeFlagCheck` would be happy to switch the `safeFlag` to `False`, but not the other way around. This meant that after :set -XGeneralizedNewtypeDeriving :set -XNoGeneralizedNewtypeDeriving in GHCi all loaded files would be still be infered as unsafe. This fixes #19243. This is a corner case, but somewhat relevant once ghci by default starts with `GeneralizedNewtypeDeriving` on (due to GHC2021). - - - - - 793dcb3d by Roland Senn at 2021-02-13T21:29:30-05:00 GHCi :complete command for operators: Fix spaceless cases of #10576. When separating operators from identifiers in a `:complete` command take advantage from the different character sets of the two items: * operators contain only specialSymbol characters. * Identifiers don't contain specialSymbol characters, with the exception of dots. - - - - - 83ace021 by Marcin Szamotulski at 2021-02-13T21:30:09-05:00 Make closeFdWith uninterrupitble closeFdWith is accessing shared TMVar - the IO manager callbak table var. It might be concurrently used by different threads: either becuase it contains information about different file descriptors or a single file descriptor is accessed from different threads. For this reason `takeMVar` might block, although for a very short time as all the IO operations are using epoll (or its equivalent). This change makes hClose and Network.Socket.close safe in presence of asynchronous exceptions. This is especailly important in the context of `bracket` which expects uninterruptible close handler. - - - - - a5ec3515 by Marcin Szamotulski at 2021-02-13T21:30:09-05:00 closeFd: improve documentation I think it is worth to say that closeFd is interruptible by asynchronous exceptions. And also fix indentation of closeFd_. - - - - - a6c3ddfe by Simon Jakobi at 2021-02-13T21:30:45-05:00 Remove Data.Semigroup.Option Bumps the binary and deepseq submodules. Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/15028. - - - - - 18e53386 by Krzysztof Gogolewski at 2021-02-13T21:31:22-05:00 Add tests for solved arrow tickets #5777 #15175 Merge requests !4464 and !4474 fixed the Lint problems. Closes #5777. Closes #15175. - - - - - dcc4b2de by Krzysztof Gogolewski at 2021-02-13T21:31:59-05:00 Remove deprecated -XGenerics and -XMonoPatBinds They have no effect since 2011 (GHC 7.2/7.4), commits cb698570b2b and 49dbe60558. - - - - - be3c0d62 by Simon Peyton Jones at 2021-02-13T21:32:38-05:00 Fix a serious bug in roughMatchTcs The roughMatchTcs function enables a quick definitely-no-match test in lookupInstEnv. Unfortunately, it didn't account for type families. This didn't matter when type families were flattened away, but now they aren't flattened it matters a lot. The fix is very easy. See INVARIANT in GHC.Core.InstEnv Note [ClsInst laziness and the rough-match fields] Fixes #19336 The change makes compiler perf worse on two very-type-family-heavy benchmarks, T9872{a,d}: T9872a(normal) ghc/alloc 2172536442.7 2216337648.0 +2.0% T9872d(normal) ghc/alloc 614584024.0 621081384.0 +1.1% (Everything else is 0.0% or at most 0.1%.) I think we just have to put up with this. Some cases were being wrongly filtered out by roughMatchTcs that might actually match, which could lead to false apartness checks. And it only affects these very type-family-heavy cases. Metric Increase: T9872a T9872d - - - - - 3331b3ad by songzh at 2021-02-13T21:33:17-05:00 Fix example code in Deriving via. - - - - - 5e71dd33 by Sylvain Henry at 2021-02-13T21:33:56-05:00 Bignum: fix bogus rewrite rule (#19345) Fix the following rule: "fromIntegral/Int->Natural" fromIntegral = naturalFromWord . fromIntegral Its type wasn't constrained to Int hence #19345. - - - - - a699389f by Ben Gamari at 2021-02-14T03:35:07-05:00 base: Add unsafeWithForeignPtr - - - - - c81996a4 by Ben Gamari at 2021-02-14T03:35:07-05:00 GHC.Utils.Binary: Eliminate allocating withForeignPtr uses - - - - - 6d3d79af by Ben Gamari at 2021-02-14T03:35:07-05:00 base: Eliminate allocating withForeignPtrs from GHC.Event.Array - - - - - 3e22a935 by Ben Gamari at 2021-02-14T03:35:07-05:00 base: Use unsafeWithForeignPtr in GHC.IO.Buffer - - - - - eb9bbd38 by Ben Gamari at 2021-02-14T03:35:07-05:00 Bump bytestring submodule Teach it to use unsafeWithForeignPtr where appropriate. - - - - - 65d98c6e by Ben Gamari at 2021-02-14T03:35:07-05:00 StringBuffer: Use unsafeWithForeignPtr - - - - - 544329c8 by Ben Gamari at 2021-02-14T03:35:07-05:00 genprimopcode: Add a second levity-polymorphic tyvar This will be needed shortly. - - - - - 74fec146 by Ben Gamari at 2021-02-14T03:35:07-05:00 Introduce keepAlive primop - - - - - 2de81332 by Ben Gamari at 2021-02-14T03:35:07-05:00 base: Use keepAlive# in withForeignPtr - - - - - 267d31c1 by Ben Gamari at 2021-02-14T03:35:07-05:00 base: Use keepAlive# in Foreign.Marshal.Alloc - - - - - ee77148e by Ben Gamari at 2021-02-14T03:35:07-05:00 ghc-compact: Use keepAlive# in GHC.Compact.Serialized - - - - - 72f23083 by Ben Gamari at 2021-02-14T03:35:44-05:00 ghc-in-ghci: Drop it isovector recently noticed that it is broken and regardless it is superceded by `hadrian/ghci`. - - - - - bc5cb5f9 by Ben Gamari at 2021-02-14T03:35:44-05:00 Drop GHC_LOADED_IN_GHCI This previously supported the ghc-in-ghci script which has been since dropped. Hadrian's ghci support does not need this macro (which disabled uses of UnboxedTuples) since it uses `-fno-code` rather than produce bytecode. - - - - - 4dc2002a by Simon Peyton Jones at 2021-02-14T03:36:20-05:00 Fix over-eager inlining in SimpleOpt In GHC.Core.SimpleOpt, I found that its inlining could duplicate an arbitary redex inside a lambda! Consider (\xyz. x+y). The occurrence-analysis treats the lamdda as a group, and says that both x and y occur once, even though the occur under the lambda-z. See Note [Occurrence analysis for lambda binders] in OccurAnal. When the lambda is under-applied in a call, the Simplifier is careful to zap the occ-info on x,y, because they appear under the \z. (See the call to zapLamBndrs in simplExprF1.) But SimpleOpt missed this test, resulting in #19347. So this patch * commons up the binder-zapping in GHC.Core.Utils.zapLamBndrs. * Calls this new function from GHC.Core.Opt.Simplify * Adds a call to zapLamBndrs to GHC.Core.SimpleOpt.simple_app This change makes test T12990 regress somewhat, but it was always very delicate, so I'm going to put up with that. In this voyage I also discovered a small, rather unrelated infelicity in the Simplifier: * In GHC.Core.Opt.Simplify.simplNonRecX we should apply isStrictId to the OutId not the InId. See Note [Dark corner with levity polymorphism] It may never "bite", because SimpleOpt should have inlined all the levity-polymorphic compulsory inlnings already, but somehow it bit me at one point and it's generally a more solid thing to do. Fixing the main bug increases runtime allocation in test perf/should_run/T12990, for (acceptable) reasons explained in a comement on Metric Increase: T12990 - - - - - b9fe4cd5 by Ben Gamari at 2021-02-14T03:36:57-05:00 validate: Fix copy-pasta Previously the Hadrian codepath of `validate` inverted the logic which decides whether the test build of `xhtml` should be built with `--enable-shared`. This resulted in validate failures on Windows, which does not support dynamic linkage of Haskell code. - - - - - 3deb1387 by Daniel Gröber at 2021-02-14T22:30:19+01:00 Fix non power-of-two Storable.alignment in Capi_Ctype tests Alignments passed to alloca and friends must be a power of two for the code in allocatePinned to work properly. Commit 41230e2601 ("Zero out pinned block alignment slop when profiling") introduced an ASSERT for this but this test was still violating it. - - - - - 363414c6 by Daniel Gröber at 2021-02-14T22:30:19+01:00 Improve ByteArray# documentation regarding alignment - - - - - 637d4f22 by Daniel Gröber at 2021-02-14T22:30:19+01:00 Document word-size rounding of ByteArray# memory (Fix #14731) - - - - - f422c12d by Daniel Gröber at 2021-02-14T22:59:01+01:00 Throw IOError when allocaBytesAligned gets non-power-of-two align - - - - - 2521b041 by Adam Gundry at 2021-02-16T04:34:43-05:00 Implement NoFieldSelectors extension (ghc-proposals 160) Fixes #5972. This adds an extension NoFieldSelectors to disable the generation of selector functions corresponding to record fields. When this extension is enabled, record field selectors are not accessible as functions, but users are still able to use them for record construction, pattern matching and updates. See Note [NoFieldSelectors] in GHC.Rename.Env for details. Defining the same field multiple times requires the DuplicateRecordFields extension to be enabled, even when NoFieldSelectors is in use. Along the way, this fixes the use of non-imported DuplicateRecordFields in GHCi with -fimplicit-import-qualified (fixes #18729). Moreover, it extends DisambiguateRecordFields to ignore non-fields when looking up fields in record updates (fixes #18999), as described by Note [DisambiguateRecordFields for updates]. Co-authored-by: Simon Hafner <hafnersimon at gmail.com> Co-authored-by: Fumiaki Kinoshita <fumiexcel at gmail.com> - - - - - 1109896c by Adam Gundry at 2021-02-16T04:34:43-05:00 Make sure HasField use counts for -Wunused-top-binds This is a small fix that depends on the previous commit, because it corrected the rnExpr free variable calculation for HsVars which refer to ambiguous fields. Fixes #19213. - - - - - a01e78cc by Sylvain Henry at 2021-02-16T04:35:22-05:00 Don't build extra object with -no-hs-main We don't need to compile/link an additional empty C file when it is not needed. This patch may also fix #18938 by avoiding trying to lookup the RTS unit when there is none (yet) in the unit database. - - - - - 42ab06f7 by Sylvain Henry at 2021-02-16T04:36:02-05:00 Replace more autotools obsolete macros (#19189) - - - - - 963e1e9a by Oleg Grenrus at 2021-02-16T04:36:40-05:00 Use explicit import list for Data.List - - - - - c6faa42b by Simon Peyton Jones at 2021-02-16T16:38:01-05:00 Avoid useless w/w split This patch is just a tidy-up for the post-strictness-analysis worker wrapper split. Consider f x = x Strictnesss analysis does not lead to a w/w split, so the obvious thing is to leave it 100% alone. But actually, because the RHS is small, we ended up adding a StableUnfolding for it. There is some reason to do this if we choose /not/ do to w/w on the grounds that the function is small. See Note [Don't w/w inline small non-loop-breaker things] But there is no reason if we would not have done w/w anyway. This patch just moves the conditional to later. Easy. This does move some -ddump-simpl printouts around a bit. I also discovered that the previous code was overwritten an InlineCompulsory with InlineStable, which is utterly wrong. That in turn meant that some default methods (marked InlineCompulsory) were getting their InlineCompulsory squashed. This patch fixes that bug --- but of course that does mean a bit more inlining! Metric Decrease: T9233 T9675 Metric Increase: T12707 T11374 T3064 T4029 T9872b T9872d haddock.Cabal - - - - - c2029001 by Andrzej Rybczak at 2021-02-16T16:38:39-05:00 Add Generic tuple instances up to 15 - - - - - 7686f9f8 by Adam Gundry at 2021-02-16T16:39:14-05:00 Avoid false redundant import warning with DisambiguateRecordFields Fixes #17853. We mustn't discard the result of pickGREs, because doing so might lead to incorrect redundant import warnings. - - - - - a04179e7 by Ryan Scott at 2021-02-16T16:39:51-05:00 Parse symbolic names in ANN type correctly with otycon This adds a new `otycon` production to the parser that allows for type constructor names that are either alphanumeric (`tycon`) or symbolic (`tyconsym`), where the latter must be parenthesized appropriately. `otycon` is much like the existing `oqtycon` production, except that it does not permit qualified names. The parser now uses `otycon` to parse type constructor names in `ANN type` declarations, which fixes #19374. To make sure that all of this works, I added three test cases: * `should_compile/T19374a`: the original test case from #19374 * `should_fail/T19374b`: a test that makes sure that an `ANN` with a qualified name fails to parse * `should_fail/T19374c`: a test that makes sure that an `ANN type` with a qualified name fails to parse - - - - - 044a53b8 by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Rename traversePushClosure to traversePushRoot - - - - - c3e8dd5f by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Increase lifetime of stackElements This modifies the lifetime of stackElements such that they stay on the stack until processing of all child closures is complete. Currently the stackElement representing a set of child closures will be removed as soon as processing of the last closure _starts_. We will use this in a future commit to allow storing information on the stack which should be accumulated in a bottom-up manner along the closure parent-child relationship. Note that the lifetime increase does not apply to 'type == posTypeFresh' stack elements. This is because they will always be pushed right back onto the stack as regular stack elements anyways. - - - - - fd48d8b0 by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Link parent stackElements on the stack The new 'sep' field links a stackElement to it's "parent". That is the stackElement containing it's parent closure. Currently not all closure types create long lived elements on the stack so this does not cover all parents along the path to the root but that is about to change in a future commit. - - - - - c4ad9150 by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Introduce callback for subtree completion The callback 'return_cb' allows users to be perform additional accounting when the traversal of a subtree is completed. This is needed for example to determine the number or total size of closures reachable from a given closure. This commit also makes the lifetime increase of stackElements from commit "rts: TraverseHeap: Increase lifetime of stackElements" optional based on 'return_cb' being set enabled or not. Note that our definition of "subtree" here includes leaf nodes. So the invariant is that return_cb is called for all nodes in the traversal exactly once. - - - - - 7bca0e54 by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Update some comments data_out was renamed to child_data at some point - - - - - eecdb053 by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Simplify profiling header Having a union in the closure profiling header really just complicates things so get back to basics, we just have a single StgWord there for now. - - - - - d7bbaf5d by Daniel Gröber at 2021-02-17T11:21:10-05:00 rts: TraverseHeap: Make trav. data macros into functions This allows the global 'flip' variable not to be exported. This allows a future commit to also make it part of the traversalState struct. - - - - - 30c01e42 by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Move "flip" bit into traverseState struct - - - - - 937feda3 by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Make "flip" bit flip into it's own function - - - - - c0907fef by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Move stackElement to header The point of this is to let user code call traversePushClosure directly instead of going through traversePushRoot. This in turn allows specifying a stackElement to be used when the traversal returns from a top-level (root) closure. - - - - - 79bb81fe by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Add a basic test For now this just tests that the order of the callbacks is what we expect for a couple of synthetic heap graphs. - - - - - fc4bd556 by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Allow visit_cb to be NULL - - - - - 3eac10ae by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: ProfHeap: Merge some redundant ifdefs - - - - - e640f611 by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: ProfHeap: Move definitions for Census to new header - - - - - 77d71160 by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Fix failed to inline warnings GCC warns that varadic functions simply cannot be inlined. - - - - - bf95dd2c by Daniel Gröber at 2021-02-17T11:21:11-05:00 rts: TraverseHeap: Update resetStaticObjectForProfiling docs Simon's concern in the old comment, specifically: So all of the calls to traverseMaybeInitClosureData() here are initialising retainer sets with the wrong flip. Is actually exactly what the code was intended to do. It makes the closure data valid, then at the beginning of the traversal the flip bit is flipped resetting all closures across the heap to invalid. Now it used to be that the profiling code using the traversal has it's own sense of valid vs. invalid beyond what the traversal code does and indeed the retainer profiler still does this, there a getClosureData of NULL is considered an invalid retainer set. So in effect there wasn't any difference in invalidating closure data rather than just resetting it to a valid zero, which might be what confused Simon at the time. As the code is now it actually uses the value of the valid/invalid bit in the form of the 'first_visit' argument to the 'visit' callback so there is a difference. - - - - - 53677c96 by Peter Trommler at 2021-02-17T11:21:47-05:00 PPC NCG: print procedure end label for debug Fixes #19118 - - - - - fb94d102 by Ben Gamari at 2021-02-17T11:22:23-05:00 CallArity: Small optimisations and strictness - - - - - a70bab97 by Ben Gamari at 2021-02-17T11:22:23-05:00 UnVarGraph: Improve asymptotics This is a redesign of the UnVarGraph data structure used by the call arity analysis to avoid the pathologically-poor performance observed in issue #18789. Specifically, deletions were previously O(n) in the case of graphs consisting of many complete (bipartite) sub-graphs. Together with the nature of call arity this would produce quadratic behavior. We now encode deletions specifically, taking care to do some light normalization of empty structures. In the case of the `Network.AWS.EC2.Types.Sum` module from #19203, this brings the runtime of the call-arity analysis from over 50 seconds down to less than 2 seconds. Metric Decrease: T15164 WWRec - - - - - dbf8f6fe by Ryan Scott at 2021-02-17T11:22:58-05:00 Fix #19377 by using lookupLOcc when desugaring TH-quoted ANNs Previously, the desugarer was looking up names referenced in TH-quoted `ANN`s by using `globalVar`, which would allocate a fresh TH `Name`. In effect, this would prevent quoted `ANN`s from ever referencing the correct identifier `Name`, leading to #19377. The fix is simple: instead of `globalVar`, use `lookupLOcc`, which properly looks up the name of the in-scope identifier. Fixes #19377. - - - - - 2adfb404 by Sebastian Graf at 2021-02-18T13:45:41-05:00 Document how bottom CPR and dead-ending Divergence are related [skip ci] In a new `Note [Bottom CPR iff Dead-Ending Divergence]`. Fixes #18086. - - - - - 763d2855 by Gauvain 'GovanifY' Roussel-Tarbouriech at 2021-02-18T13:46:19-05:00 directory: ensure xdg compliance (Fix #6077) - - - - - 4dc2bcca by Matthew Pickering at 2021-02-18T13:46:56-05:00 rts: Add generic block traversal function, listAllBlocks This function is exposed in the RtsAPI.h so that external users have a blessed way to traverse all the different `bdescr`s which are known by the RTS. The main motivation is to use this function in ghc-debug but avoid having to expose the internal structure of a Capability in the API. - - - - - b5db3457 by Ben Gamari at 2021-02-18T13:47:32-05:00 Extend nullary TyConApp optimisation to all TyCons See Note [Sharing nullary TyConApps] in GHC.Core.TyCon. Closes #19367. Metric Decrease: T9872a T9872b T9872c - - - - - a4c53e3b by Ben Gamari at 2021-02-18T13:47:32-05:00 TypeMap: Use mkTyConTy instead of TyConApp constructor This allows TypeMap to benefit from the nullary TyConApp sharing optimisation described in Note [Sharing nullary TyConApps] in GHC.Core.TyCon. - - - - - 60ed2a65 by Simon Peyton Jones at 2021-02-18T13:48:09-05:00 Improve specialisation for imported functions At a SPECIALSE pragma for an imported Id, we used to check that it was marked INLINABLE. But that turns out to interact badly with worker/wrapper: see Note [Worker-wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. So this small patch instead simply tests that we have an unfolding for the function; see Note [SPECIALISE pragmas for imported Ids] in GHC.Tc.Gen.Sig. Fixes #19246 - - - - - 94bbc45d by Sylvain Henry at 2021-02-18T13:48:51-05:00 Use target Int/Word when detecting literal overflows (#17336) And also for empty enumeration detection. - - - - - 766b11ea by Andreas Klebinger at 2021-02-18T13:49:31-05:00 Remove leftover trace messages from the keepAlive# work. - - - - - ecf967c2 by Hécate Moonlight at 2021-02-18T13:50:10-05:00 Rectify the haddock markup surrounding symbols for foldl' and foldMap' closes #19365 - - - - - a1126bac by Ben Gamari at 2021-02-18T13:50:46-05:00 base: Fix order of infix declarations in Data.Functor As pointed in #19284, previously the order was a bit confusing. This didn't affect the meaning but nevertheless it's much clearer now. Closes #19284. - - - - - 6863b196 by Ben Gamari at 2021-02-18T13:51:22-05:00 users guide: Mention that -e can be given multiple times Fixes #19122. - - - - - f78f001c by Matthew Pickering at 2021-02-18T13:51:59-05:00 Test Driver: Tweak interval of test reporting Rather than just display every 100 tests, work out how many to display based on the total number of tests. This improves the experience when running a small number of tests. For [0..100] - Report every test [100..1000] - Report every 10 tests [1000..10000] - Report every 100 tests and so on.. - - - - - 4196969c by Simon Peyton Jones at 2021-02-19T11:03:46-05:00 Improve handling of overloaded labels, literals, lists etc When implementing Quick Look I'd failed to remember that overloaded labels, like #foo, should be treated as a "head", so that they can be instantiated with Visible Type Application. This caused #19154. A very similar ticket covers overloaded literals: #19167. This patch fixes both problems, but (annoyingly, albeit temporarily) in two different ways. Overloaded labels I dealt with overloaded labels by buying fully into the Rebindable Syntax approach described in GHC.Hs.Expr Note [Rebindable syntax and HsExpansion]. There is a good overview in GHC.Rename.Expr Note [Handling overloaded and rebindable constructs]. That module contains much of the payload for this patch. Specifically: * Overloaded labels are expanded in the renamer, fixing #19154. See Note [Overloaded labels] in GHC.Rename.Expr. * Left and right sections used to have special code paths in the typechecker and desugarer. Now we just expand them in the renamer. This is harder than it sounds. See GHC.Rename.Expr Note [Left and right sections]. * Infix operator applications are expanded in the typechecker, specifically in GHC.Tc.Gen.App.splitHsApps. See Note [Desugar OpApp in the typechecker] in that module * ExplicitLists are expanded in the renamer, when (and only when) OverloadedLists is on. * HsIf is expanded in the renamer when (and only when) RebindableSyntax is on. Reason: the coverage checker treats HsIf specially. Maybe we could instead expand it unconditionally, and fix up the coverage checker, but I did not attempt that. Overloaded literals Overloaded literals, like numbers (3, 4.2) and strings with OverloadedStrings, were not working correctly with explicit type applications (see #19167). Ideally I'd also expand them in the renamer, like the stuff above, but I drew back on that because they can occur in HsPat as well, and I did not want to to do the HsExpanded thing for patterns. But they *can* now be the "head" of an application in the typechecker, and hence something like ("foo" @T) works now. See GHC.Tc.Gen.Head.tcInferOverLit. It's also done a bit more elegantly, rather than by constructing a new HsExpr and re-invoking the typechecker. There is some refactoring around tcShortCutLit. Ultimately there is more to do here, following the Rebindable Syntax story. There are a lot of knock-on effects: * HsOverLabel and ExplicitList no longer need funny (Maybe SyntaxExpr) fields to support rebindable syntax -- good! * HsOverLabel, OpApp, SectionL, SectionR all become impossible in the output of the typecheker, GhcTc; so we set their extension fields to Void. See GHC.Hs.Expr Note [Constructor cannot occur] * Template Haskell quotes for HsExpanded is a bit tricky. See Note [Quotation and rebindable syntax] in GHC.HsToCore.Quote. * In GHC.HsToCore.Match.viewLExprEq, which groups equal HsExprs for the purpose of pattern-match overlap checking, I found that dictionary evidence for the same type could have two different names. Easily fixed by comparing types not names. * I did quite a bit of annoying fiddling around in GHC.Tc.Gen.Head and GHC.Tc.Gen.App to get error message locations and contexts right, esp in splitHsApps, and the HsExprArg type. Tiresome and not very illuminating. But at least the tricky, higher order, Rebuilder function is gone. * Some refactoring in GHC.Tc.Utils.Monad around contexts and locations for rebindable syntax. * Incidentally fixes #19346, because we now print renamed, rather than typechecked, syntax in error mesages about applications. The commit removes the vestigial module GHC.Builtin.RebindableNames, and thus triggers a 2.4% metric decrease for test MultiLayerModules (#19293). Metric Decrease: MultiLayerModules T12545 - - - - - f90487ca by David Feuer at 2021-02-22T18:26:50-05:00 Make openFile exception safe * `openFile` could sometimes leak file descriptors if it received an asynchronous exception (#19114, #19115). Fix this on POSIX. * `openFile` and more importantly `openFileBlocking` could not be interrupted effectively during the `open` system call (#17912). Fix this on POSIX. * Implement `readFile'` using `withFile` to ensure the file is closed promptly on exception. * Avoid `bracket` in `withFile`, reducing the duration of masking. Closes #19130. Addresses #17912, #19114, and #19115 on POSIX systems, but not on Windows. - - - - - e1f133bf by Michiel de Bruijne at 2021-02-22T18:26:52-05:00 Prefer -Wmissing-signatures over -Wmissing-exported-signatures (#14794) - - - - - b068103d by alexbiehl at 2021-02-22T18:26:53-05:00 Ensure tcg_env is up-to-date when running typechecker plugins - - - - - 22ef7ab1 by Leif Metcalf at 2021-02-22T18:26:54-05:00 GHCi: Always show fixity We used to only show the fixity of an operator if it wasn't the default fixity. Usually this was when the fixity was undeclared, but it could also arise if one declared the fixity of an operator as infixl 9, the default fixity. This commit makes it so that :i always shows the fixity of an operator, even if it is unset. We may want in the future to keep track of whether an operator's fixity is defined, so that we can print a comment like infixl 9 # -- Assumed, since no fixity is declared. for operators with no specified fixity, and so that we can print fixity of a term with a non-symbolic term when its fixity has been manually specified as infixl 9. Implements #19200. - - - - - ece20229 by Hécate at 2021-02-22T18:26:55-05:00 Add the docspec:base rule to Hadrian - - - - - fd0945b7 by Sylvain Henry at 2021-02-22T18:27:00-05:00 Move Hooks into HscEnv - - - - - a1c85db1 by Dylan Yudaken at 2021-02-22T18:27:02-05:00 Do not cas on slowpath of SpinLock unnecessarily This is a well known technique to reduce inter-CPU bus traffic while waiting for the lock by reducing the number of writes. - - - - - 8bc9df52 by Matthew Pickering at 2021-02-22T18:27:05-05:00 Force gcp in assignArgumentsPos I observed this accumulating in the T3294 test only to be eventually forced (by a -hi profile). As it is only word big, forcing it saves quite a bit of allocation. - - - - - d1ceadc7 by Matthew Pickering at 2021-02-22T18:27:05-05:00 Make Width field in CmmType strict This value is eventually forced so don't build up thunks. Observed with T3294 and -hi profile. - - - - - db74c8f4 by Matthew Pickering at 2021-02-22T18:27:05-05:00 Make CmmType field of LocalReg strict This was observed to build up thunks which were forced by using a `-hi` profile and T3294 as a test. - - - - - 6d7086a3 by Ole Krüger at 2021-02-22T18:27:06-05:00 Fix TemplateHaskell pretty printer for CompleteP (#19270) The COMPLETE pragma was not properly terminated with a '#-}'. - - - - - 58897e24 by Ole Krüger at 2021-02-22T18:27:06-05:00 Add test case for CompleteP pretty-printer (#19270) - - - - - c7e80199 by Sergei Trofimovich at 2021-02-22T18:27:08-05:00 ModuleOrigin: print details of module conflict Before the change the error did not show details of involved module: ``` haddock: panic! (the 'impossible' happened) (GHC version 8.10.3: ModOrigin: hidden module redefined ``` After the change modile details are shown: ``` ghc-stage1: panic! (the 'impossible' happened) (GHC version 9.1.20210206: ModOrigin: package both exposed/hidden x: exposed package y: reexport by ghc-boot-9.1 ``` Fixes #19330 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 37fd1a6c by Ben Gamari at 2021-02-22T18:27:09-05:00 testsuite: Mark foreignInterruptible as fragile in GHCi As noted in #18391, foreignInterruptible fails pretty regularly under GHCi. - - - - - f78f4597 by Ben Gamari at 2021-02-22T18:27:10-05:00 testsuite: Add broken tests for #19244 - - - - - 847b0a69 by Andreas Klebinger at 2021-02-22T18:27:10-05:00 Fix Storeable instances for the windows timeout executable. alignment clearly should be a power of two. This patch makes it so. We do so by using the #alignment directive instead of using the size of the type. - - - - - 3aceea90 by Sylvain Henry at 2021-02-22T18:27:12-05:00 Don't pass homeUnitId at ExternalPackageState creation time (#10827) It makes the external package state independent of the home unit which is needed to make several home units share the EPS. - - - - - 54ba8d8a by Tamar Christina at 2021-02-22T18:27:14-05:00 linker: Fix atexit handlers on PE - - - - - 4a9d856d by Ben Gamari at 2021-02-23T15:11:06-05:00 testsuite: Mark tests affected by - - - - - 5b187ab8 by Ben Gamari at 2021-02-24T09:09:40-05:00 Revert "testsuite: Mark tests affected by #19025" This reverts commit 4a9d856d21c67b3328e26aa68a071ec9a824a7bb. - - - - - 7151eaa3 by Ben Gamari at 2021-02-24T11:15:41-05:00 testsuite: Introduce flag to ignore performance failures Needed by #19025. - - - - - 003ea780 by Ben Gamari at 2021-02-24T11:15:41-05:00 hadrian: Introduce runtest.opts key-value setting - - - - - 559e4b2b by Ben Gamari at 2021-02-24T11:15:41-05:00 hadrian: Throw error on unknown key-value setting name - - - - - 10e115d3 by Ben Gamari at 2021-02-24T11:15:41-05:00 gitlab-ci: Ignore performance test failures on Darwin Due to #19025. - - - - - bc12e7ec by Utku Demir at 2021-02-25T19:26:50-05:00 Minor fix to QualifiedDo docs about the ApplicativeDo desugaring When desugaring ApplicativeDo, GHC looks up the name `fmap`, not `<$>` (see 'GHC.Builtin.Names.fmapName'). This commit fixes the misleading documentation; since exporting the name `<$>` instead of `fmap` causes a "not in scope" error when `QualifiedDo` and `ApplicativeDo` is combined. [skip ci] - - - - - 98cb9402 by Sebastian Graf at 2021-02-26T16:24:26-05:00 hadrian: ticky_ghc should build all things with -ticky (#19405) [skip ci] With this patch, everything built by the stage1 compiler (in a `ticky_ghc`-transformed flavour) will be built with `-ticky`. Fixes #19405. - - - - - 29e7f318 by Simon Peyton Jones at 2021-02-26T16:25:02-05:00 Update MonoLocalBinds documentation Update the documentation to specify that MonoLocalBinds is lifted by a partial type signature. This came up in #19396. [skip ci] - - - - - 80eda911 by Adam Gundry at 2021-02-26T16:25:39-05:00 Implement -Wambiguous-fields Fixes #18966. Adds a new warning -Wambiguous-fields for uses of field selectors or record updates that will be rejected in the future, when the DuplicateRecordFields extension is simplified per https://github.com/ghc-proposals/ghc-proposals/pull/366. - - - - - 8d1fb46d by Ryan Scott at 2021-02-26T16:26:13-05:00 Fix #19363 by using pprName' {Applied,Infix} in the right places It was revealed in #19363 that the Template Haskell pretty-printer implemented in `Language.Haskell.TH.Ppr` did not pretty-print infix names or symbolic names correctly in certain situations, such as in data constructor declarations or fixity declarations. Easily fixed by using `pprName' Applied` (which always parenthesizes symbolic names in prefix position) or `pprName' Infix` (which always surrounds alphanumeric names with backticks in infix position) in the right spots. Fixes #19363. - - - - - 24777bb3 by Matthew Pickering at 2021-02-26T16:26:49-05:00 Reimplement Stream in "yoneda" style for efficiency 'Stream' is implemented in the "yoneda" style for efficiency. By representing a stream in this manner 'fmap' and '>>=' operations are accumulated in the function parameters before being applied once when the stream is destroyed. In the old implementation each usage of 'mapM' and '>>=' would traverse the entire stream in order to apply the substitution at the leaves. It is well-known for free monads that this representation can improve performance, and the test results demonstrate this for GHC as well. The operation mapAccumL is not used in the compiler and can't be implemented efficiently because it requires destroying and rebuilding the stream. I removed one use of mapAccumL_ which has similar problems but the other use was difficult to remove. In the future it may be worth exploring whether the 'Stream' encoding could be modified further to capture the mapAccumL pattern, and likewise defer the passing of accumulation parameter until the stream is finally consumed. The >>= operation for 'Stream' was a hot-spot in the ticky profile for the "ManyConstructors" test which called the 'cg' function many times in "StgToCmm.hs" Metric Decrease: ManyConstructors - - - - - a9f23793 by Andreas Klebinger at 2021-02-26T16:27:26-05:00 Move absentError into ghc-prim. When using -fdicts-strict we generate references to absentError while compiling ghc-prim. However we always load ghc-prim before base so this caused linker errors. We simply solve this by moving absentError into ghc-prim. This does mean it's now a panic instead of an exception which can no longer be caught. But given that it should only be thrown if there is a compiler error that seems acceptable, and in fact we already do this for absentSumFieldError which has similar constraints. - - - - - 98dd09af by Ben Gamari at 2021-02-27T07:58:57-05:00 rts: Introduce --eventlog-flush-interval flag This introduces a flag, --eventlog-flush-interval, which can be used to set an upper bound on the amount of time for which an eventlog event will remain enqueued. This can be useful in real-time monitoring settings. - - - - - 966a768e by Matthew Pickering at 2021-02-27T07:59:33-05:00 Remove the -xt heap profiling option It should be left to tooling to perform the filtering to remove these specific closure types from the profile if desired. Fixes #16795 - - - - - 60bf4d7c by Andreas Klebinger at 2021-02-27T08:00:08-05:00 Fix typechecking time bug for large rationals (#15646) When desugaring large overloaded literals we now avoid computing the `Rational` value. Instead prefering to store the significant and exponent as given where reasonable and possible. See Note [FractionalLit representation] for details. - - - - - df6d42d0 by Zubin Duggal at 2021-02-27T08:00:46-05:00 Don't catch async exceptions when evaluating Template Haskell - - - - - 902ece87 by Zubin Duggal at 2021-02-27T08:00:46-05:00 switch to using forkIO to detect async exceptions - - - - - 629dd56d by Zubin Duggal at 2021-02-27T08:00:46-05:00 Remove unnecessary killThread - - - - - c703cb39 by Zubin Duggal at 2021-02-27T08:00:46-05:00 Explain uninterruptibleMask - - - - - 5b752b1d by Sylvain Henry at 2021-02-27T08:01:25-05:00 touchy: use a valid cabal-version - - - - - bcaa36c4 by Sylvain Henry at 2021-02-27T08:01:25-05:00 Fix Windows build with autoconf >=2.70 (#19189) - - - - - 31ee48dc by Sylvain Henry at 2021-02-27T08:02:03-05:00 CI: reduce xz compression for non release/nightly jobs Reduce XZ compression level for regular jobs (it is bumped to 9 for releases and nightly jobs). In my experiments I've got the following bindist size in the given time for each compression level (with the quick flavour): XZ_OPT Time Size -9 4m06s 112 MB -8 4m00s 114 MB -7 3m50s 116 MB -6 (default) 3m40s 118 MB -5 2m47s 123 MB -4 1m57s 134 MB -3 1m03s 129 MB -2 49.73s 136 MB -1 37.72s 142 MB -0 34.40s 156 MB - - - - - 7d8f7d96 by Sebastian Graf at 2021-02-27T08:02:39-05:00 Include time.h in conc059_c (#19431) The test probably could have used `usleep` from `unistd.h` instead, but this seemed like the simplest solution. Fixes #19431. - - - - - 157fe938 by Ben Gamari at 2021-02-27T08:03:15-05:00 gitlab-ci: Fix TEST_ARGS/RUNTEST_ARGS inconsistency Finally fixes #19025. - - - - - 5680f8d4 by Ben Gamari at 2021-02-27T19:05:18-05:00 TcS: oneShot-ify Following the example of Note [The one-shot state monad trick]. c.f. #18202. Metric Decrease: T17836 T3064 T5321FD T9872a T9872b T9872c T9872d - - - - - 30500a4f by Ben Gamari at 2021-02-27T19:05:18-05:00 GHC.Tc.Solver.Rewrite: oneShot-ify Following the example of Note [The one-shot state monad trick]. c.f. #18202. - - - - - 382cd3b0 by Ben Gamari at 2021-02-27T19:05:18-05:00 Rewrite.split: Fix reboxing As noted in #19102, we would previously ended up reboxing the tuple result of `split`'s worker and then immediately take apart the boxed tuple to again unpack it into an unboxed result. Fixes #19102. - - - - - b8d40af1 by Krzysztof Gogolewski at 2021-02-27T19:05:54-05:00 Fix assertion error with linear types, #19400 The previous code using TyCoMapper could promote the same metavar twice. Use a set instead. - - - - - a3473323 by Ben Gamari at 2021-02-28T05:37:13-05:00 users guide: Update mathjax CDN URL Fixes #19423. [skip ci] - - - - - 0f2891f0 by Sylvain Henry at 2021-02-28T05:37:52-05:00 configure: avoid empty lines in AC_CONFIG_FILES Should fix failures on Windows: configure.ac:1511: error: ` ' is already registered with AC_CONFIG_FILES. - - - - - 980151aa by Alan Zimmerman at 2021-02-28T05:38:29-05:00 Add some utility functions to GHC.Types.SrcLoc pprUserSpan, isZeroWidthSpan, pprLocated, combineRealSrcSpans - - - - - 856929a5 by Sebastian Graf at 2021-02-28T05:39:05-05:00 Widen acceptance window of T12545 (#19414) This test flip-flops by +-1% in arbitrary changes in CI. While playing around with `-dunique-increment`, I could reproduce variations of 3% in compiler allocations, so I set the acceptance window accordingly. Fixes #19414. - - - - - 035d983d by Matthew Pickering at 2021-02-28T05:39:41-05:00 Fix two places where TcGblEnv was retained Found with ghc-debug on the ManyConstructors test - - - - - c3ff35bb by Sebastian Graf at 2021-02-28T06:10:38-05:00 Mark divModInt and friends as INLINE (#19267) So that we don't get a silly worker `$wdivModInt` and risk inlining `divModInt#` into `divModInt` or `$wdivModInt`, making both unlikely to inline at call sites. Fixes #19267. There's a spurious metric decrease (was an *increase*) in T12545. That seems entirely due to shifts in Unique distribution (+5% more `IntMap.$winsert` calls). The inappropriateness of the acceptance window is tracked in #19414. Metric Decrease: T12545 Metric Increase: T12545 - - - - - df2eca94 by Sebastian Graf at 2021-02-28T06:10:39-05:00 CPR analysis: Use CPR of scrutinee for Case Binder CPR (#19232) For years we have lived in a supposedly sweet spot that gave case binders the CPR property, unconditionally. Which is an optimistic hack that is now described in `Historical Note [Optimistic case binder CPR]`. In #19232 the concern was raised that this might do more harm than good and that might be better off simply by taking the CPR property of the scrutinee for the CPR type of the case binder. And indeed that's what we do now. Since `Note [CPR in a DataAlt case alternative]` is now only about field binders, I renamed and garbage collected it into `Note [Optimistic field binder CPR]`. NoFib approves: ``` NoFib Results -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- anna +0.1% +0.1% nucleic2 -1.2% -0.6% sched 0.0% +0.9% transform -0.0% -0.1% -------------------------------------------------------------------------------- Min -1.2% -0.6% Max +0.1% +0.9% Geometric Mean -0.0% +0.0% ``` Fixes #19232. - - - - - 0a85502b by Daniel Gröber at 2021-02-28T06:10:40-05:00 CODEOWNERS: Use sections to allow multiple matching entries The CODEOWNERS documentation has this to say on the current matching behaviour: > The path definition order is significant: the last pattern matching a > given path is used to find the code owners. Take this as an example: /rts/ bgamari [...] /rts/win32/ Phyx (I'm omitting the '@' so as to not notification spam everyone) This means a change in a file under win23 would only have Phyx but not bgamari as approver. I don't think that's the behaviour we want. Using "sections" we can get additive behaviour instead, from the docs: > Additionally, the usual guidance that only the last pattern matching the > file is applied is expanded such that the last pattern matching for each > section is applied. [RTS] /rts/ bgamari [...] [WinIO] /rts/win32/ Phyx So now since those entries are in different sections both would be added to the approvers list. The sections feature was introduced in Gitlab 13.2, see "Version history" on [1] we're currently running 18.8 on gitlab.haskell.org, see [2]. [1]: https://docs.gitlab.com/13.8/ee/user/project/code_owners.html#code-owners-sections [2]: https://gitlab.haskell.org/help - - - - - d262edad by Daniel Gröber at 2021-02-28T06:10:40-05:00 CODEOWNERS: Add @DanielG as maintainer for RTS heap profiling code - - - - - 72c0e078 by Sylvain Henry at 2021-02-28T06:10:42-05:00 Make known names simple ConApps (#19386) While fixing #17336 we noticed that code like this: = if | tc == intTyConName -> ... | tc == int8TyConName -> ... | tc == int16TyConName -> ... | tc == int32TyConName -> ... | tc == int64TyConName -> ... | tc == wordTyConName -> ... | tc == word8TyConName -> ... | tc == word16TyConName -> ... | tc == word32TyConName -> ... | tc == word64TyConName -> ... | tc == naturalTyConName -> ... was not transformed into a single case expression on the Name's unique as I would have expected but as a linear search. Bindings for known names are not simple constructor applications because of their strict `n_occ :: !OccName` field that needs to allocate a `FastString`: this field needs to be forced before using the `n_unique` field. This patch partially reverses ccaf7b66fc79e464b4e26f4ae62cb92ef7ba4b0f by making `n_occ` lazy and by ensuring that helper functions used to declare known names are fully inlined. The code above is then optimised as expected. Baseline Test Metric value New value Change --------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 822810880.0 822104032.0 -0.1% ManyConstructors(normal) ghc/alloc 4551734924.0 4480621808.0 -1.6% MultiLayerModules(normal) ghc/alloc 6029108292.0 6016024464.0 -0.2% Naperian(optasm) ghc/alloc 57396600.0 56826184.0 -1.0% PmSeriesG(normal) ghc/alloc 55666656.0 54521840.0 -2.1% PmSeriesS(normal) ghc/alloc 70204344.0 69047328.0 -1.6% PmSeriesT(normal) ghc/alloc 102273172.0 101070016.0 -1.2% PmSeriesV(normal) ghc/alloc 69157156.0 68002176.0 -1.7% T10421(normal) ghc/alloc 129875476.0 128881544.0 -0.8% T10421a(normal) ghc/alloc 92031552.0 90982800.0 -1.1% T10547(normal) ghc/alloc 34399800.0 33016760.0 -4.0% GOOD T10858(normal) ghc/alloc 208316964.0 207318616.0 -0.5% T11195(normal) ghc/alloc 304100548.0 302797040.0 -0.4% T11276(normal) ghc/alloc 140586764.0 139469832.0 -0.8% T11303b(normal) ghc/alloc 52118960.0 51120248.0 -1.9% T11374(normal) ghc/alloc 241325868.0 240692752.0 -0.3% T11822(normal) ghc/alloc 150612036.0 149582736.0 -0.7% T12150(optasm) ghc/alloc 92738452.0 91897224.0 -0.9% T12227(normal) ghc/alloc 494236296.0 493086728.0 -0.2% T12234(optasm) ghc/alloc 66786816.0 65966096.0 -1.2% T12425(optasm) ghc/alloc 112396704.0 111471016.0 -0.8% T12545(normal) ghc/alloc 1832733768.0 1828021072.0 -0.3% T12707(normal) ghc/alloc 1054991144.0 1053359696.0 -0.2% T13035(normal) ghc/alloc 116173180.0 115112072.0 -0.9% T13056(optasm) ghc/alloc 391749192.0 390687864.0 -0.3% T13253(normal) ghc/alloc 382785700.0 381550592.0 -0.3% T13253-spj(normal) ghc/alloc 168806064.0 167987192.0 -0.5% T13379(normal) ghc/alloc 403890296.0 402447920.0 -0.4% T13701(normal) ghc/alloc 2542828108.0 2534392736.0 -0.3% T13719(normal) ghc/alloc 4666717708.0 4659489416.0 -0.2% T14052(ghci) ghc/alloc 2181268580.0 2175320640.0 -0.3% T14683(normal) ghc/alloc 3094166824.0 3094524216.0 +0.0% T14697(normal) ghc/alloc 376323432.0 374024184.0 -0.6% T15164(normal) ghc/alloc 1896324828.0 1893236528.0 -0.2% T15630(normal) ghc/alloc 198932800.0 197783656.0 -0.6% T16190(normal) ghc/alloc 288186840.0 287250024.0 -0.3% T16577(normal) ghc/alloc 8324100940.0 8321580600.0 -0.0% T17096(normal) ghc/alloc 318264420.0 316961792.0 -0.4% T17516(normal) ghc/alloc 1332680768.0 1331635504.0 -0.1% T17836(normal) ghc/alloc 1296308168.0 1291098504.0 -0.4% T17836b(normal) ghc/alloc 62008340.0 60745256.0 -2.0% T17977(normal) ghc/alloc 52954564.0 51890248.0 -2.0% T17977b(normal) ghc/alloc 47824016.0 46683936.0 -2.4% T18140(normal) ghc/alloc 117408932.0 116353672.0 -0.9% T18223(normal) ghc/alloc 5603767896.0 5602037104.0 -0.0% T18282(normal) ghc/alloc 166456808.0 165396320.0 -0.6% T18304(normal) ghc/alloc 103694052.0 103513136.0 -0.2% T18478(normal) ghc/alloc 816819336.0 814459560.0 -0.3% T18698a(normal) ghc/alloc 438652404.0 437041784.0 -0.4% T18698b(normal) ghc/alloc 529448324.0 527666608.0 -0.3% T18923(normal) ghc/alloc 78360824.0 77315560.0 -1.3% T1969(normal) ghc/alloc 854223208.0 851303488.0 -0.3% T3064(normal) ghc/alloc 200655808.0 199368872.0 -0.6% T3294(normal) ghc/alloc 1791121792.0 1790033888.0 -0.1% T4801(normal) ghc/alloc 343749816.0 341760680.0 -0.6% T5030(normal) ghc/alloc 377520872.0 376492360.0 -0.3% T5321FD(normal) ghc/alloc 312680408.0 311618536.0 -0.3% T5321Fun(normal) ghc/alloc 355635656.0 354536264.0 -0.3% T5631(normal) ghc/alloc 629667068.0 629562192.0 -0.0% T5642(normal) ghc/alloc 540913864.0 539569952.0 -0.2% T5837(normal) ghc/alloc 43183652.0 42177928.0 -2.3% T6048(optasm) ghc/alloc 96395616.0 95397032.0 -1.0% T783(normal) ghc/alloc 427778908.0 426307760.0 -0.3% T9020(optasm) ghc/alloc 279523960.0 277010040.0 -0.9% T9233(normal) ghc/alloc 966717488.0 964594096.0 -0.2% T9630(normal) ghc/alloc 1585228636.0 1581428672.0 -0.2% T9675(optasm) ghc/alloc 594817892.0 591703040.0 -0.5% T9872a(normal) ghc/alloc 2216955420.0 2215648024.0 -0.1% T9872b(normal) ghc/alloc 2747814924.0 2746515472.0 -0.0% T9872c(normal) ghc/alloc 2271878772.0 2270554344.0 -0.1% T9872d(normal) ghc/alloc 623661168.0 621434064.0 -0.4% T9961(normal) ghc/alloc 409059124.0 406811120.0 -0.5% WWRec(normal) ghc/alloc 940563924.0 938008112.0 -0.3% hie002(normal) ghc/alloc 9801941116.0 9787675736.0 -0.1% parsing001(normal) ghc/alloc 494756632.0 493828512.0 -0.2% Metric Decrease: T10547 T13035 T12425 - - - - - 2454bb10 by Sebastian Graf at 2021-02-28T06:10:42-05:00 Make `Ord Literal` deterministic (#19438) Previously, non-determinism arising from a use of `uniqCompareFS` in `cmpLit` potentially crept into `CoreMap`, which we expect to behave deterministically. So we simply use `lexicalCompareFS` now. Fixes #19438. - - - - - 915daf51 by Sebastian Graf at 2021-02-28T06:10:42-05:00 Reduce code bloat in `Ord Literal` instance (#19443) Reduce code bloat by replacing a call to `(==)` (which is defined in terms of `compare`) and to `compare` by a single call to `compare`, utilising the `Semigroup Ordering` instance. The compiler was eliminate the code bloat before, so this is a rather cosmetical improvement. Fixes #19443. - - - - - 2628d61f by Ben Gamari at 2021-03-01T10:11:39-05:00 rts/eventlog: Ensure that all capability buffers are flushed The previous approach performed the flush in yieldCapability. However, as pointed out in #19435, this is wrong as it idle capabilities will not go through this codepath. The fix is simple: undo the optimisation, flushing in `flushEventLog` by calling `flushAllCapsEventsBufs` after acquiring all capabilities. Fixes #19435. - - - - - e18c430d by Ben Gamari at 2021-03-01T10:11:39-05:00 rts/eventlog: Flush MainCapability buffer in non-threaded RTS Previously flushEventLog failed to flush anything but the global event buffer in the non-threaded RTS. Fixes #19436. - - - - - f512f9e2 by Ben Gamari at 2021-03-01T10:11:39-05:00 testsuite: Accept allocations change in T10421 Metric Decrease: T10421 - - - - - 8c425bd8 by Sebastian Graf at 2021-03-01T17:29:44-05:00 Widen acceptance window of `MultiLayerModules` (#19293) [skip ci] As #19293 realises, this one keeps on flip flopping by 2.5% depending on how many modules there are within the GHC package. We should revert this once we figured out how to fix what's going on. - - - - - 7730713b by Simon Peyton Jones at 2021-03-01T17:30:21-05:00 Unify result type earlier to improve error messages Ticket #19364 helpfully points out that we do not currently take advantage of pushing the result type of an application into the arguments. This makes error messages notably less good. The fix is rather easy: move the result-type unification step earlier. It's even a bit more efficient; in the the checking case we now do one less zonk. See Note [Unify with expected type before typechecking arguments] in GHC.Tc.Gen.App This change generally improves error messages, but it made one worse: typecheck/should_fail/T16204c. That led me to the realisation that a good error can be replaced by a less-good one, which provoked me to change GHC.Tc.Solver.Interact.inertsCanDischarge. It's explained in the new Note [Combining equalities] One other refactoring: I discovered that KindEqOrigin didn't need a Maybe in its type -- a nice simplification. - - - - - 3b79e8b8 by Krzysztof Gogolewski at 2021-03-01T17:31:01-05:00 Infer multiplicity in case expressions This is a first step towards #18738. - - - - - 6429943b by Simon Peyton Jones at 2021-03-01T17:31:36-05:00 Fix terrible occurrence-analysis bug Ticket #19360 showed up a terrible bug in the occurrence analyser, in a situation like this Rec { f = g ; g = ..f... {-# RULE g .. = ...f... #-} } Then f was postInlineUnconditionally, but not in the RULE (which is simplified first), so we had a RULE mentioning a variable that was not in scope. This led me to review (again) the subtle loop-breaker stuff in the occurrence analyser. The actual changes are few, and are largely simplifications. I did a /lot/ of comment re-organising though. There was an unexpected amount of fallout. * Validation failed when compiling the stage2 compiler with profiling on. That turned to tickle a second latent bug in the same OccAnal code (at least I think it was always there), which led me to simplify still further; see Note [inl_fvs] in GHC.Core.Opt.OccurAnal. * But that in turn let me to some strange behaviour in CSE when ticks are in the picture, which I duly fixed. See Note [Dealing with ticks] in GHC.Core.Opt.CSE. * Then I got an ASSERT failure in CoreToStg, which again seems to be a latent bug. See Note [Ticks in applications] in GHC.CoreToStg * I also made one unforced change: I now simplify the RHS of a RULE in the same way as the RHS of a stable unfolding. This can allow a trivial binding to disappear sooner than otherwise, and I don't think it has any downsides. The change is in GHC.Core.Opt.Simplify.simplRules. - - - - - ce85cffc by Alan Zimmerman at 2021-03-01T17:32:12-05:00 Wrap LHsContext in Maybe in the GHC AST If the context is missing it is captured as Nothing, rather than putting a noLoc in the ParsedSource. Updates haddock submodule - - - - - 51828c6d by Sebastian Graf at 2021-03-01T17:32:48-05:00 Fix a bug causing loss of sharing in `UniqSDFM` While fixing #18610, I noticed that ```hs f :: Bool -> Int f x = case (x, x) of (True, True) -> 1 (False, False) -> 2 ``` was *not* detected as exhaustive. I tracked it down to `equateUSDFM`, where upon merging equality classes of `x` and `y`, we failed to atually indirect the *representative* `x'` of the equality class of `x` to the representative `y'` of `y`. The fixed code is much more naturally and would I should have written in the first place. I can confirm that the above example now is detected as exhaustive. The commit that fixes #18610 comes directly after and it has `f` above as a regression test, so I saw no need to open a ticket or commit a separate regression test. - - - - - e571eda7 by Sebastian Graf at 2021-03-01T17:32:48-05:00 Pmc: Implement `considerAccessible` (#18610) Consider (`T18610`): ```hs f :: Bool -> Int f x = case (x, x) of (True, True) -> 1 (False, False) -> 2 (True, False) -> 3 -- Warning: Redundant ``` The third clause will be flagged as redundant. Nevertheless, the programmer might intend to keep the clause in order to avoid bitrot. After this patch, the programmer can write ```hs g :: Bool -> Int g x = case (x, x) of (True, True) -> 1 (False, False) -> 2 (True, False) | GHC.Exts.considerAccessible -> 3 -- No warning ``` And won't be bothered any longer. See also `Note [considerAccessible]` and the updated entries in the user's guide. Fixes #18610 and #19228. - - - - - 5d7978df by Matthew Pickering at 2021-03-02T17:29:05-05:00 Define TRY_ACQUIRE_LOCK correctly when non-threaded - - - - - 8188adf0 by Ben Gamari at 2021-03-02T17:29:05-05:00 eventlog: Fix various races Previously the eventlog infrastructure had a couple of races that could pop up when using the startEventLog/endEventLog interfaces. In particular, stopping and then later restarting logging could result in data preceding the eventlog header, breaking the integrity of the stream. To fix this we rework the invariants regarding the eventlog and generally tighten up the concurrency control surrounding starting and stopping of logging. We also fix an unrelated bug, wherein log events from disabled capabilities could end up never flushed. - - - - - da351e44 by David Eichmann at 2021-03-02T17:29:05-05:00 Test start/endEventlogging: first header must be EVENT_HEADER_BEGIN - - - - - 507f8de2 by ARATA Mizuki at 2021-03-02T17:29:43-05:00 Add a test for the calling convention of "foreign import prim" on x86_64 and AArch64 - - - - - 38ebb9db by ARATA Mizuki at 2021-03-02T17:29:43-05:00 Support auto-detection of MAX_REAL_FLOAT_REG and MAX_REAL_DOUBLE_REG up to 6 Fixes #17953 - - - - - ede60537 by Ben Gamari at 2021-03-02T17:30:20-05:00 gitlab-ci: Disable utimensat in Darwin builds Fixes #17895. - - - - - 59e95bdf by Sebastian Graf at 2021-03-03T08:12:27-05:00 Fix typo in docs [skip ci] - - - - - eea96042 by Daniel Winograd-Cort at 2021-03-03T08:12:28-05:00 Add cmpNat, cmpSymbol, and cmpChar Add Data.Type.Ord Add and update tests Metric Increase: MultiLayerModules - - - - - d8dc0f96 by Sylvain Henry at 2021-03-03T08:12:29-05:00 Fix array and cleanup conversion primops (#19026) The first change makes the array ones use the proper fixed-size types, which also means that just like before, they can be used without explicit conversions with the boxed sized types. (Before, it was Int# / Word# on both sides, now it is fixed sized on both sides). For the second change, don't use "extend" or "narrow" in some of the user-facing primops names for conversions. - Names like `narrowInt32#` are misleading when `Int` is 32-bits. - Names like `extendInt64#` are flat-out wrong when `Int is 32-bits. - `narrow{Int,Word}<N>#` however map a type to itself, and so don't suffer from this problem. They are left as-is. These changes are batched together because Alex happend to use the array ops. We can only use released versions of Alex at this time, sadly, and I don't want to have to have a release thatwon't work for the final GHC 9.2. So by combining these we get all the changes for Alex done at once. Bump hackage state in a few places, and also make that workflow slightly easier for the future. Bump minimum Alex version Bump Cabal, array, bytestring, containers, text, and binary submodules - - - - - d89deeba by Matthew Pickering at 2021-03-03T08:12:29-05:00 Profiling: Allow heap profiling to be controlled dynamically. This patch exposes three new functions in `GHC.Profiling` which allow heap profiling to be enabled and disabled dynamically. 1. startHeapProfTimer - Starts heap profiling with the given RTS options 2. stopHeapProfTimer - Stops heap profiling 3. requestHeapCensus - Perform a heap census on the next context switch, regardless of whether the timer is enabled or not. - - - - - fe4202ce by Sylvain Henry at 2021-03-03T08:12:39-05:00 Always INLINE ($!) ($) is INLINE so there is no reason ($!) shouldn't. - - - - - 38748d5f by Sylvain Henry at 2021-03-03T08:12:39-05:00 Minor simplification for leak indicators Avoid returning a lazy panic value when leak indicators are disabled. - - - - - 8a433a3c by Sylvain Henry at 2021-03-03T08:12:39-05:00 Fix leaks of the HscEnv with quick flavour (#19356) Thanks @mpickering for finding them! - - - - - e81f2e4e by Ben Gamari at 2021-03-03T08:12:40-05:00 hadrian: Fix profiled flavour transformer Previously the profiled flavour transformer failed to add the profiled ways to the library and RTS ways lists, resulting in link failures. - - - - - 5c4dcc3e by Ben Gamari at 2021-03-03T08:12:40-05:00 ghc-heap: Fix profiled build Previously a255b4e38918065ac028789872e53239ac30ae1a failed to update the non-profiling codepath. - - - - - 3630b9ba by Sebastian Graf at 2021-03-03T08:12:40-05:00 DmdAnal: Better syntax for demand signatures (#19016) The update of the Outputable instance resulted in a slew of documentation changes within Notes that used the old syntax. The most important doc changes are to `Note [Demand notation]` and the user's guide. Fixes #19016. - - - - - 3f9af891 by Sylvain Henry at 2021-03-03T08:12:42-05:00 Add a flag to dump the FastString table - - - - - ad0c2073 by Andreas Klebinger at 2021-03-03T08:12:43-05:00 Build event logging rts in all flavours except GhcinGhci. This applies the fix for #19033 to all the other flavours as well. - - - - - df74e95a by Ryan Scott at 2021-03-03T08:12:43-05:00 User's Guide: document DefaultSignatures' interaction with subsumption As reported in #19432, the rules governing how `DefaultSignatures` are typechecked became stricter in GHC 9.0 due to simplified subsumption. However, this was far from obvious to me after reading the User's Guide section on `DefaultSignatures`. In this patch, I spruce up the documentation in that section so that it mentions these nuances. Resolves #19432. - - - - - 2f7e879b by Matthew Pickering at 2021-03-03T19:09:34+00:00 Revert "Remove GHC.Types.Unique.Map module" This reverts commit 1c7c6f1afc8e7f7ba5d256780bc9d5bb5f3e7601. - - - - - 8402ea95 by Matthew Pickering at 2021-03-03T19:09:34+00:00 Profiling by info table mode (-hi) This profiling mode creates bands by the address of the info table for each closure. This provides a much more fine-grained profiling output than any of the other profiling modes. The `-hi` profiling mode does not require a profiling build. - - - - - 4b297979 by Matthew Pickering at 2021-03-03T19:09:34+00:00 Add -finfo-table-map which maps info tables to source positions This new flag embeds a lookup table from the address of an info table to information about that info table. The main interface for consulting the map is the `lookupIPE` C function > InfoProvEnt * lookupIPE(StgInfoTable *info) The `InfoProvEnt` has the following structure: > typedef struct InfoProv_{ > char * table_name; > char * closure_desc; > char * ty_desc; > char * label; > char * module; > char * srcloc; > } InfoProv; > > typedef struct InfoProvEnt_ { > StgInfoTable * info; > InfoProv prov; > struct InfoProvEnt_ *link; > } InfoProvEnt; The source positions are approximated in a similar way to the source positions for DWARF debugging information. They are only approximate but in our experience provide a good enough hint about where the problem might be. It is therefore recommended to use this flag in conjunction with `-g<n>` for more accurate locations. The lookup table is also emitted into the eventlog when it is available as it is intended to be used with the `-hi` profiling mode. Using this flag will significantly increase the size of the resulting object file but only by a factor of 2-3x in our experience. - - - - - a7aac008 by Matthew Pickering at 2021-03-03T19:09:34+00:00 Add option to give each usage of a data constructor its own info table The `-fdistinct-constructor-tables` flag will generate a fresh info table for the usage of any data constructor. This is useful for debugging as now by inspecting the info table, you can determine which usage of a constructor caused that allocation rather than the old situation where the info table always mapped to the definition site of the data constructor which is useless. In conjunction with `-hi` and `-finfo-table-map` this gives a more fine grained understanding of where constructor allocations arise from in a program. - - - - - 9087899e by Matthew Pickering at 2021-03-03T19:09:34+00:00 Add whereFrom and whereFrom# primop The `whereFrom` function provides a Haskell interface for using the information created by `-finfo-table-map`. Given a Haskell value, the info table address will be passed to the `lookupIPE` function in order to attempt to find the source location information for that particular closure. At the moment it's not possible to distinguish the absense of the map and a failed lookup. - - - - - db80a5cc by Matthew Pickering at 2021-03-03T19:10:47+00:00 Add test for whereFrom# - - - - - 91d09039 by Matthew Pickering at 2021-03-03T19:11:06+00:00 Add release notes for -hi, -finfo-table-map and -fdistinct-constructor-tables - - - - - f121ffe4 by Matthew Pickering at 2021-03-03T19:11:08+00:00 Don't use FastString to convert string to UTF8 - - - - - 7b9767b8 by Matthew Pickering at 2021-03-03T19:11:08+00:00 Use a newtype for CHeader and CStub in ForeignStubs - - - - - f943edb0 by Matthew Pickering at 2021-03-03T19:11:08+00:00 IPE: Give all constructor and function tables locations During testing it was observed that quite a few info tables were not being given locations (due to not being assigned source locations, because they were not enclosed by a source note). We can at least give the module name and type for such closures even if no more accurate source information. Especially for constructors this helps find them in the STG dumps. - - - - - db898c8a by Krzysztof Gogolewski at 2021-03-04T23:14:01-05:00 Add a Template Haskell warning flag -Wimplicit-lift Part of #17804. - - - - - e679321e by Matthew Pickering at 2021-03-04T23:14:37-05:00 Hadrian: Enable -ticky-dyn-thunk in ticky_ghc transformer This produces much more detailed ticky profiles which include names of constructors. Related !3340 !2098 Fixes #19403 - - - - - c6ec7f48 by Ben Gamari at 2021-03-04T23:15:12-05:00 testsuite: Add test for #19413 This was fixed as a result of #19181. - - - - - f191fce7 by Ben Gamari at 2021-03-04T23:15:13-05:00 base: Add reference to #19413 to Note [unsafePerformIO and strictness] - - - - - 9de44e57 by Ben Gamari at 2021-03-04T23:15:48-05:00 rts: Make markLiveObject thread-safe markLiveObject is called by GC worker threads and therefore must be thread-safe. This was a rather egregious oversight which the testsuite missed. (cherry picked from commit fe28a062e47bd914a6879f2d01ff268983c075ad) - - - - - 1a52c53b by Ben Gamari at 2021-03-04T23:16:24-05:00 gitlab-ci: Build releases with hyperlinked sources Fixes #19455. - - - - - 4cdf8b5e by Cale Gibbard at 2021-03-04T23:17:00-05:00 Bring back COMPLETE sets filtered by result TyCon (#14422) Commit 2a94228 dramatically simplified the implementation and improved the performance of COMPLETE sets while making them applicable in more scenarios at the same time. But it turned out that there was a change in semantics that (to me unexpectedly) broke users' expectations (see #14422): They relied on the "type signature" of a COMPLETE pragma to restrict the scrutinee types of a pattern match for which they are applicable. This patch brings back that filtering, so the semantics is the same as it was in GHC 9.0. See the updated Note [Implementation of COMPLETE pragmas]. There are a few testsuite output changes (`completesig13`, `T14422`) which assert this change. Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu> - - - - - 6467a48e by Ben Gamari at 2021-03-04T23:17:36-05:00 testsuite: Prevent T16318 from picking up .ghci Previously this test did nothing to prevent GHC from reading .ghci due to the `-e` arguments. Consequently it could fail due to multiple reloadings of DynFlags while evaluating .ghci. - - - - - 4cd98bd2 by Krzysztof Gogolewski at 2021-03-05T04:48:39-05:00 Run linear Lint on the desugarer output (part of #19165) This addresses points (1a) and (1b) of #19165. - Move mkFailExpr to HsToCore/Utils, as it can be shared - Desugar incomplete patterns and holes to an empty case, as in Note [Incompleteness and linearity] - Enable linear linting of desugarer output - Mark MultConstructor as broken. It fails Lint, but I'd like to fix this separately. Metric Decrease: T6048 - - - - - b5155a6c by Harry Garrood harry at garrood.me at 2021-03-05T04:49:18-05:00 Add new driver test for use of outdated .o files This is something that's quite important for the correctness of the incremental build system and doesn't appear to be tested currently; this test fails on my hashing branch, whereas all of the other (non-perf) tests pass. - - - - - 6141aef4 by Andreas Klebinger at 2021-03-05T14:01:20-05:00 Update bounds/hadrian to fix bootstrapping with 9.0. This fixes #19484. In detail we: * Bump the index-state of hackage. * Require alex-3.2.6, as alex-3.2.5 doesn't build with 9.0. * Allow Cabal-3.4 as 3.2 doesn't build with ghc 9.0. * Allow a newer QuickCheck version that accepts the new base version. * Some code changes to account for Cabal changes. - - - - - 31e265c1 by Andreas Schwab at 2021-03-05T14:01:56-05:00 Implement riscv64 LLVM backend This enables a registerised build for the riscv64 architecture. - - - - - dd23bd74 by Sylvain Henry at 2021-03-06T02:33:32-05:00 Windows: fix crlf on checkout Using .gitatttributes, we don't require users to set git's core.autocrlf setting to false on Windows to be able to checkout a working tree. - - - - - 9e0c0c3a by Ben Gamari at 2021-03-06T02:34:08-05:00 hadrian: Pass -fno-use-rpaths to GHC while linking This mirrors the make build system and ensures that we don't end up with references to the build directory in the final executable. Fixes #19485. - - - - - cf65cf16 by Shayne Fletcher at 2021-03-06T19:27:04-05:00 Implement record dot syntax - - - - - 3e082f8f by Ben Gamari at 2021-03-07T17:01:40-05:00 Implement BoxedRep proposal This implements the BoxedRep proposal, refactoring the `RuntimeRep` hierarchy from: ```haskell data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ... ``` to ```haskell data RuntimeRep = BoxedRep Levity | ... data Levity = Lifted | Unlifted ``` Updates binary, haddock submodules. Closes #17526. Metric Increase: T12545 - - - - - 657b5538 by Peter Trommler at 2021-03-08T07:31:39-05:00 Hadrian: Add powerpc64[le] to supported arch list Fixes #19409 - - - - - 33a4fd99 by Matthew Pickering at 2021-03-08T07:32:15-05:00 eventlog: Add MEM_RETURN event to give information about fragmentation See #19357 The event reports the * Current number of megablocks allocated * The number that the RTS thinks it needs * The number is managed to return to the OS When current > need then the difference is returned to the OS, the successful number of returned mblocks is reported by 'returned'. In a fragmented heap current > need but returned < current - need. - - - - - ffc96439 by Matthew Pickering at 2021-03-08T07:32:15-05:00 eventlog: Add BLOCKS_SIZE event The BLOCKS_SIZE event reports the size of the currently allocated blocks in bytes. It is like the HEAP_SIZE event, but reports about the blocks rather than megablocks. You can work out the current heap fragmentation by looking at the difference between HEAP_SIZE and BLOCKS_SIZE. Fixes #19357 - - - - - e145e44c by Matthew Pickering at 2021-03-08T07:32:15-05:00 eventlog: Add changelog entry for BLOCKS_SIZE and MEM_RETURN - - - - - e483775c by Daniel Winograd-Cort at 2021-03-08T07:32:53-05:00 Update changelog and release notes for Data.Type.Ord change - - - - - daa6363f by Sylvain Henry at 2021-03-08T18:24:07-05:00 DynFlags: move temp file management into HscEnv (#17957) - - - - - 47d6acd3 by Matthew Pickering at 2021-03-08T18:24:42-05:00 rts: Use a separate free block list for allocatePinned The way in which allocatePinned took blocks out of the nursery was leading to horrible fragmentation in some workloads. The strategy now is that a separate free block list is reserved for each capability and blocks are taken from there. When it's empty the global SM lock is taken and a fresh block of size PINNED_EMPTY_SIZE is allocated. Fixes #19481 - - - - - bfa86250 by Matthew Pickering at 2021-03-08T18:25:19-05:00 eventlog: Repost initialisation events when eventlog restarts If startEventlog is called after the program has already started running then quite a few useful events are missing from the eventlog because they are only posted when the program starts. This patch adds a mechanism to declare that an event should be reposted everytime the startEventlog function is called. Now in EventLog.c there is a global list of functions called `eventlog_header_funcs` which stores a list of functions which should be called everytime the eventlog starts. When calling `postInitEvent`, the event will not only be immediately posted to the eventlog but also added to the global list. When startEventLog is called, the list is traversed and the events reposted. - - - - - 0a709dd9 by Ryan Scott at 2021-03-09T02:46:20-05:00 Require GHC 8.10 as the minimum compiler for bootstrapping Now that GHC 9.0.1 is released, it is time to drop support for bootstrapping with GHC 8.8, as we only support building with the previous two major GHC releases. As an added bonus, this allows us to remove several bits of CPP that are either always true or no longer reachable. - - - - - 376427ec by Ryan Scott at 2021-03-09T02:46:56-05:00 Document operator sections' interaction with subsumption This resolves #19457 by making a note of breaking changes (introduced in GHC 9.2) to the way that GHC typechecks operator sections where the operator has nested `forall`s or contexts in its type signature. - - - - - 7a728ca6 by Andreas Klebinger at 2021-03-09T02:47:31-05:00 Add a distclean command to hadrian. Hadrian should behave well and not delete files created by configure with the clean command. With this patch hadrian now deletes the fs/mingw tarballs only with distclean. This fixes #19320. The main impact being that validate won't have to redownload the tarballs when re-run. - - - - - aaa5fc21 by Vladislav Zavialov at 2021-03-09T18:51:55-05:00 Replace Ord TyLit with nonDetCmpTyLit (#19441) The Ord instance was non-deterministic, but it's easy assume that it is deterministic. In fact, haddock-api used to do exactly that before haddock/7e8c7c3491f3e769368b8e6c767c62a33e996c80 - - - - - 8fe274e2 by Simon Peyton Jones at 2021-03-09T18:52:32-05:00 Fixes to dealing with the export of main It's surprisingly tricky to deal with 'main' (#19397). This patch does quite bit of refactoring do to it right. Well, more-right anyway! The moving parts are documented in GHC.Tc.Module Note [Dealing with main] Some other oddments: * Rename tcRnExports to rnExports; no typechecking here! * rnExports now uses checkNoErrs rather than failIfErrsM; the former fails only if rnExports itself finds errors * Small improvements to tcTyThingCategory, which ultimately weren't important to the patch, but I've retained as a minor improvement. - - - - - e9189745 by Ryan Scott at 2021-03-09T18:53:07-05:00 Fix some warnings when bootstrapping with GHC 9.0 This fixes two classes of warnings that appear when bootstrapping with GHC 9.0: * `ghc-boot.cabal` was using `cabal-version: >=1.22`, which `cabal-install-3.4` now warns about, instead recommending the use of `cabal-version: 1.22`. * Several pattern matches were producing `Pattern match(es) are non-exhaustive` because of incorrect CPP. The pattern-match coverage checker _did_ become smarter in GHC 9.1, however, so I ended up needing to keep the CPP, adjusting them to use `#if __GLASGOW_HASKELL__ < 901` instead. - - - - - df8e8ba2 by Vladislav Zavialov at 2021-03-09T18:53:43-05:00 Location for tuple section pattern error (#19504) This fixes a regression that led to loss of location information in error messages about the use of tuple sections in patterns. - - - - - afc357d2 by Matthew Pickering at 2021-03-10T10:33:36-05:00 rts: Gradually return retained memory to the OS Related to #19381 #19359 #14702 After a spike in memory usage we have been conservative about returning allocated blocks to the OS in case we are still allocating a lot and would end up just reallocating them. The result of this was that up to 4 * live_bytes of blocks would be retained once they were allocated even if memory usage ended up a lot lower. For a heap of size ~1.5G, this would result in OS memory reporting 6G which is both misleading and worrying for users. In long-lived server applications this results in consistent high memory usage when the live data size is much more reasonable (for example ghcide) Therefore we have a new (2021) strategy which starts by retaining up to 4 * live_bytes of blocks before gradually returning uneeded memory back to the OS on subsequent major GCs which are NOT caused by a heap overflow. Each major GC which is NOT caused by heap overflow increases the consec_idle_gcs counter and the amount of memory which is retained is inversely proportional to this number. By default the excess memory retained is oldGenFactor (controlled by -F) / 2 ^ (consec_idle_gcs * returnDecayFactor) On a major GC caused by a heap overflow, the `consec_idle_gcs` variable is reset to 0 (as we could continue to allocate more, so retaining all the memory might make sense). Therefore setting bigger values for `-Fd` makes the rate at which memory is returned slower. Smaller values make it get returned faster. Setting `-Fd0` disables the memory return completely, which is the behaviour of older GHC versions. The default is `-Fd4` which results in the following scaling: > mapM print [(x, 1/ (2**(x / 4))) | x <- [1 :: Double ..20]] (1.0,0.8408964152537146) (2.0,0.7071067811865475) (3.0,0.5946035575013605) (4.0,0.5) (5.0,0.4204482076268573) (6.0,0.35355339059327373) (7.0,0.29730177875068026) (8.0,0.25) (9.0,0.21022410381342865) (10.0,0.17677669529663687) (11.0,0.14865088937534013) (12.0,0.125) (13.0,0.10511205190671433) (14.0,8.838834764831843e-2) (15.0,7.432544468767006e-2) (16.0,6.25e-2) (17.0,5.255602595335716e-2) (18.0,4.4194173824159216e-2) (19.0,3.716272234383503e-2) (20.0,3.125e-2) So after 13 consecutive GCs only 0.1 of the maximum memory used will be retained. Further to this decay factor, the amount of memory we attempt to retain is also influenced by the GC strategy for the oldest generation. If we are using a copying strategy then we will need at least 2 * live_bytes for copying to take place, so we always keep that much. If using compacting or nonmoving then we need a lower number, so we just retain at least `1.2 * live_bytes` for some protection. In future we might want to make this behaviour more aggressive, some relevant literature is > Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle time garbage collection scheduling. SIGPLAN Not. 51, 6 (June 2016), 570–583. DOI:https://doi.org/10.1145/2980983.2908106 which describes the "memory reducer" in the V8 javascript engine which on an idle collection immediately returns as much memory as possible. - - - - - d095954b by Adam Gundry at 2021-03-10T10:33:36-05:00 Do not remove shadowed record selectors from interactive context (fixes #19322) - - - - - 5581e7b4 by Adam Gundry at 2021-03-10T10:33:36-05:00 Simplify shadowing of DuplicateRecordFields in GHCi (fixes #19314) Previously, defining fields with DuplicateRecordFields in GHCi lead to strange shadowing behaviour, whereby fields would (accidentally) not shadow other fields. This simplifies things so that fields are shadowed in the same way whether or not DuplicateRecordFields is enabled. - - - - - 7d212b49 by Ben Gamari at 2021-03-10T13:18:17-05:00 FastMutInt: Drop FastMutPtr This appears to be unused. - - - - - e6c9b1e6 by Ben Gamari at 2021-03-10T13:20:49-05:00 FastMutInt: Ensure that newFastMutInt initializes value Updates haddock submodule. - - - - - 41b183d6 by Ben Gamari at 2021-03-10T13:20:55-05:00 FastMutInt: Introduce atomicFetchAddFastMutInt This will be needed by FastString. - - - - - aa9dc323 by Ben Gamari at 2021-03-10T13:20:55-05:00 FastString: Use FastMutInt instead of IORef Int This saves at least one I# allocation per FastString. - - - - - e687ba83 by Ben Gamari at 2021-03-10T15:55:09-05:00 Bump bytestring submodule to 0.11.1.0 - - - - - 8a59f49a by Luke Lau at 2021-03-10T15:55:09-05:00 template-haskell: Add putDoc, getDoc, withDecDoc and friends This adds two new methods to the Quasi class, putDoc and getDoc. They allow Haddock documentation to be added to declarations, module headers, function arguments and class/type family instances, as well as looked up. It works by building up a map of names to attach pieces of documentation to, which are then added in the extractDocs function in GHC.HsToCore.Docs. However because these template haskell names need to be resolved to GHC names at the time they are added, putDoc cannot directly add documentation to declarations that are currently being spliced. To remedy this, withDecDoc/withDecsDoc wraps the operation with addModFinalizer, and provides a more ergonomic interface for doing so. Similarly, the funD_doc, dataD_doc etc. combinators provide a more ergonomic interface for documenting functions and their arguments simultaneously. This also changes ArgDocMap to use an IntMap rather than an Map Int, for efficiency. Part of the work towards #5467 - - - - - 30ccf9ed by Joachim Breitner at 2021-03-10T16:57:59-05:00 Introduce GHC2021 language This adds support for -XGHC2021, as described in Proposal 0380 [1]. [1] https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0380-ghc2021.rst - - - - - 115cd3c8 by Joachim Breitner at 2021-03-10T16:58:50-05:00 Use GHC2021 as default language - - - - - fcfc66e5 by Roland Senn at 2021-03-10T16:59:05-05:00 Ignore breakpoint for a specified number of iterations. (#19157) * Implement new debugger command `:ignore` to set an `ignore count` for a specified breakpoint. * Allow new optional parameter on `:continue` command to set an `ignore count` for the current breakpoint. * In the Interpreter replace the current `Word8` BreakArray with an `Int` array. * Change semantics of values in `BreakArray` to: n < 0 : Breakpoint is disabled. n == 0 : Breakpoint is enabled. n > 0 : Breakpoint is enabled, but ignore next `n` iterations. * Rewrite `:enable`/`:disable` processing as a special case of `:ignore`. * Remove references to `BreakArray` from `ghc/UI.hs`. - - - - - d964d6fa by GHC GitLab CI at 2021-03-11T23:13:16-05:00 testsuite: Update Win32 test output for GHC2021 Fixes the Windows CI jobs. Requires update of the Win32 submodule. - - - - - 4fb704a5 by Tamar Christina at 2021-03-12T15:19:15-05:00 Update win32 submodule - - - - - edc9f7d4 by Moritz Angermann at 2021-03-13T01:09:03-05:00 Shorten the build pipeline - - - - - abe0f45b by Moritz Angermann at 2021-03-13T20:27:31+08:00 bump submodule nofib - - - - - ba601db4 by Moritz Angermann at 2021-03-13T23:29:03+08:00 Force eol=lf; to prevent windows breakage. - - - - - 96b3c66b by Moritz Angermann at 2021-03-14T11:52:56+08:00 Allow perf-nofib to fail - - - - - b73c9c5f by Sebastian Graf at 2021-03-14T12:54:29-04:00 Implement the UnliftedDatatypes extension GHC Proposal: 0265-unlifted-datatypes.rst Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/265 Issues: https://gitlab.haskell.org/ghc/ghc/-/issues/19523 Implementation Details: Note [Implementation of UnliftedDatatypes] This patch introduces the `UnliftedDatatypes` extension. When this extension is enabled, GHC relaxes the restrictions around what result kinds are allowed in data declarations. This allows data types for which an unlifted or levity-polymorphic result kind is inferred. The most significant changes are in `GHC.Tc.TyCl`, where `Note [Implementation of UnliftedDatatypes]` describes the details of the implementation. Fixes #19523. - - - - - cd793767 by Matthew Pickering at 2021-03-14T12:55:07-04:00 Correct module name in `-fprof-callers` documentation - - - - - 1793ca9d by Sebastian Graf at 2021-03-14T12:55:45-04:00 Pmc: Consider Required Constraints when guessing PatSyn arg types (#19475) This patch makes `guessConLikeUnivTyArgsFromResTy` consider required Thetas of PatSynCons, by treating them as Wanted constraints to be discharged with the constraints from the Nabla's TyState and saying "does not match the match type" if the Wanted constraints are unsoluble. It calls out into a new function `GHC.Tc.Solver.tcCheckWanteds` to do so. In pushing the failure logic around call sites of `initTcDsForSolver` inside it by panicking, I realised that there was a bunch of dead code surrounding `pmTopMoraliseType`: I was successfully able to delete the `NoChange` data constructor of `TopNormaliseTypeResult`. The details are in `Note [Matching against a ConLike result type]` and `Note [Instantiating a ConLike]. The regression test is in `T19475`. It's pretty much a fork of `T14422` at the moment. Co-authored-by: Cale Gibbard <cgibbard at gmail.com> - - - - - b15c876d by Matthew Pickering at 2021-03-14T12:56:21-04:00 Make traceHeapEventInfo an init event This means it will be reposted everytime the eventlog is started. - - - - - d412cd10 by Sylvain Henry at 2021-03-14T12:57:01-04:00 Write explicit IOEnv's Functor and MonadIO instances (#18202) - - - - - 87ae062a by Sylvain Henry at 2021-03-14T12:57:40-04:00 Compute length only once in foldBal - - - - - 7ea7624c by Ryan Scott at 2021-03-15T00:42:27-04:00 Document the interaction between ScopedTypeVariables and StandaloneKindSignatures This documents a limitation of `StandaloneKindSignatures`—namely, that it does not bring type variables bound by an outermost `forall` into scope over a type-level declaration—in the GHC User's Guide. See #19498 for more discussion. - - - - - 92d98424 by Vladislav Zavialov at 2021-03-15T00:43:05-04:00 Fix record dot precedence (#19521) By moving the handling of TIGHT_INFIX_PROJ to the correct place, we can remove the isGetField hack and fix a bug at the same time. - - - - - 545cfefa by Vladislav Zavialov at 2021-03-15T00:43:05-04:00 Test chained record construction/update/access According to the proposal, we have the following equivalence: e{lbl1 = val1}.val2 == (e{lbl1 = val1}).val2 This is a matter of parsing. Record construction/update must have the same precedence as dot access. Add a test case to ensure this. - - - - - b5b51c54 by Moritz Angermann at 2021-03-16T10:04:23+08:00 [ci] Skip test's on windows that often fail in CI. - - - - - 58cfcc65 by Hécate Moonlight at 2021-03-17T00:57:17-04:00 Make the CI jobs interruptible closes #19362 - - - - - 43a64744 by Moritz Angermann at 2021-03-17T04:16:27-04:00 [ci] don't make marge double build. This fixes !18744 - - - - - f11954b1 by ARATA Mizuki at 2021-03-17T19:05:13-04:00 Add a test for fromInteger :: Integer -> Float/Double (#15926, #17231, #17782) - - - - - 540fa6b2 by ARATA Mizuki at 2021-03-17T19:05:13-04:00 fromInteger :: Integer -> {Float,Double} now always round to nearest even integerToFloat# and integerToDouble# were moved from ghc-bignum to base. GHC.Integer.floatFromInteger and doubleFromInteger were removed. Fixes #15926, #17231, #17782 - - - - - 84927818 by Ben Gamari at 2021-03-17T19:05:50-04:00 llvmGen: Accept range of LLVM versions Previously we would support only one LLVM major version. Here we generalize this to accept a range, taking this range to be LLVM 10 to 11, as 11 is necessary for Apple M1 support. We also accept 12, as that is what apple ships with BigSur on the M1. - - - - - d14a2068 by Sylvain Henry at 2021-03-17T19:06:33-04:00 Enhance pass result forcing When we use `withTiming` we need to force the results of each timed pass to better represent the time spent in each phase. This patch forces some results that weren't before. It also retrieve timings for the CoreToStg and WriteIface passes. - - - - - 665b757f by Ben Gamari at 2021-03-17T19:07:10-04:00 IfaceToType: Ensure that IfaceTyConInfo is shared In #19194 mpickering detailed that there are a LOT of allocations of IfaceTyConInfo: There are just two main cases: IfaceTyConInfo IsPromoted IfaceNormalTyCon and IfaceTyConInfo NotPromoted IfaceNormalTyCon. These should be made into CAFs and shared. From my analysis, the most common case is IfaceTyConInfo NotPromoted IfaceNormalTyCon (53 000) then IfaceTyConInfo IsPromoted IfaceNormalTyCon (28 000). This patch makes it so these are properly shared by using a smart constructor. Fixes #19194. - - - - - 4fbc8558 by Ben Gamari at 2021-03-17T19:07:47-04:00 Eliminate selector thunk allocations - - - - - 42049339 by Ben Gamari at 2021-03-17T19:07:47-04:00 CmmToAsm.Reg.Linear: Make linearRA body a join point Avoid top-level recursion. - - - - - fe6cad22 by Ben Gamari at 2021-03-17T19:07:47-04:00 CmmtoAsm.Reg.Linear: Rewrite process CmmToAsm.Reg.Linear: More strictness More strictness - - - - - 6b10163e by Sylvain Henry at 2021-03-17T19:08:27-04:00 Disable bogus assertion (#19489) - - - - - 26d26974 by Ryan Scott at 2021-03-17T19:09:03-04:00 Document how GADT patterns are matched from left-to-right, outside-in This adds some bullet points to the GHC User's Guide section on `GADTs` to explain some subtleties in how GHC typechecks GADT patterns. In particular, this adds examples of programs being rejected for matching on GADTs in a way that does not mesh with GHC's left-to-right, outside-in order for checking patterns, which can result in programs being rejected for seemingly counterintuitive reasons. (See #12018 for examples of confusion that arose from this.) In addition, now that we have visible type application in data constructor patterns, I mention a possible workaround of using `TypeApplications` to repair programs of this sort. Resolves #12018. - - - - - 30285415 by Vladislav Zavialov at 2021-03-17T19:09:40-04:00 Built-in type families: CharToNat, NatToChar (#19535) Co-authored-by: Daniel Rogozin <daniel.rogozin at serokell.io> Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> - - - - - 0a986685 by Ben Gamari at 2021-03-19T19:58:52-04:00 testsuite: Make --ignore-perf-tests more expressive Allow skipping of only increases/decreases. - - - - - d03d8761 by Ben Gamari at 2021-03-19T19:58:52-04:00 gitlab-ci: Ignore performance improvements in marge jobs Currently we have far too many merge failures due to cumulative performance improvements. Avoid this by accepting metric decreases in marge-bot jobs. Fixes #19562. - - - - - 7d027433 by Gaël Deest at 2021-03-20T07:48:01-04:00 [skip ci] Fix 'Ord' documentation inconsistency Current documentation for the `Ord` typeclass is inconsistent. It simultaneously mentions that: > The 'Ord' class is used for totally ordered datatypes. And: > The Haskell Report defines no laws for 'Ord'. However, '<=' is > customarily expected to implement a non-strict partial order […] The Haskell report (both 98 and 2010 versions) mentions total ordering, which implicitly does define laws. Moreover, `compare :: Ord a => a -> a -> Ordering` and `data Ordering = LT | EQ | GT` imply that the order is indeed total (there is no way to say that two elements are not comparable). This MR fixes the Haddock comment, and adds a comparability law to the list of suggested properties. - - - - - f940fd46 by Alan Zimmerman at 2021-03-20T07:48:37-04:00 Add the main types to be used for exactprint in the GHC AST The MR introducing the API Annotations, !2418 is huge. Conceptually it is two parts, the one deals with introducing the new types to be used for annotations, and outlining how they will be used. This is a small change, localised to compiler/GHC/Parser/Annotation.hs and is contained in this commit. The follow-up, larger commit deals with mechanically working this through the entire AST and updating all the parts affected by it. It is being split so the part that needs good review feedback can be seen in isolation, prior to the rest coming in. - - - - - 95275a5f by Alan Zimmerman at 2021-03-20T07:48:38-04:00 GHC Exactprint main commit Metric Increase: T10370 parsing001 Updates haddock submodule - - - - - adf93721 by GHC GitLab CI at 2021-03-20T07:48:38-04:00 check-ppr,check-exact: Write out result as binary Previously we would use `writeFile` to write the intermediate files to check for round-tripping. However, this will open the output handle as a text handle, which on Windows will change line endings. Avoid this by opening as binary. Explicitly use utf8 encoding. This is for tests only, do not need to worry about user compatibility. - - - - - ceef490b by GHC GitLab CI at 2021-03-20T07:48:38-04:00 testsuite: Normalise slashes In the `comments` and `literals` tests, since they contain file paths. - - - - - dd11f2d5 by Luite Stegeman at 2021-03-20T07:49:15-04:00 Save the type of breakpoints in the Breakpoint tick in STG GHCi needs to know the types of all breakpoints, but it's not possible to get the exprType of any expression in STG. This is preparation for the upcoming change to make GHCi bytecode from STG instead of Core. - - - - - 26328a68 by Luite Stegeman at 2021-03-20T07:49:15-04:00 remove superfluous 'id' type parameter from GenTickish The 'id' type is now determined by the pass, using the XTickishId type family. - - - - - 0107f356 by Luite Stegeman at 2021-03-20T07:49:15-04:00 rename Tickish to CoreTickish - - - - - 7de3532f by Luite Stegeman at 2021-03-20T07:49:15-04:00 Transfer tickish things to GHC.Types.Tickish Metric Increase: MultiLayerModules - - - - - 1f94e0f7 by Luite Stegeman at 2021-03-20T07:49:15-04:00 Generate GHCi bytecode from STG instead of Core and support unboxed tuples and sums. fixes #1257 - - - - - 62b0e1bc by Andreas Klebinger at 2021-03-20T07:49:50-04:00 Make the simplifier slightly stricter. This commit reduces allocations by the simplifier by 3% for the Cabal test at -O2. We do this by making a few select fields, bindings and arguments strict which reduces allocations for the simplifier by around 3% in total for the Cabal test. Which is about 2% fewer allocations in total at -O2. ------------------------- Metric Decrease: T18698a T18698b T9233 T9675 T9872a T9872b T9872c T9872d T10421 T12425 T13253 T5321FD T9961 ------------------------- - - - - - 044e5be3 by Sebastian Graf at 2021-03-20T07:50:26-04:00 Nested CPR light (#19398) While fixing #19232, it became increasingly clear that the vestigial hack described in `Note [Optimistic field binder CPR]` is complicated and causes reboxing. Rather than make the hack worse, this patch gets rid of it completely in favor of giving deeply unboxed parameters the Nested CPR property. Example: ```hs f :: (Int, Int) -> Int f p = case p of (x, y) | x == y = x | otherwise = y ``` Based on `p`'s `idDemandInfo` `1P(1P(L),1P(L))`, we can see that both fields of `p` will be available unboxed. As a result, we give `p` the nested CPR property `1(1,1)`. When analysing the `case`, the field CPRs are transferred to the binders `x` and `y`, respectively, so that we ultimately give `f` the CPR property. I took the liberty to do a bit of refactoring: - I renamed `CprResult` ("Constructed product result result") to plain `Cpr`. - I Introduced `FlatConCpr` in addition to (now nested) `ConCpr` and and according pattern synonym that rewrites flat `ConCpr` to `FlatConCpr`s, purely for compiler perf reasons. - Similarly for performance reasons, we now store binders with a Top signature in a separate `IntSet`, see `Note [Efficient Top sigs in SigEnv]`. - I moved a bit of stuff around in `GHC.Core.Opt.WorkWrap.Utils` and introduced `UnboxingDecision` to replace the `Maybe DataConPatContext` type we used to return from `wantToUnbox`. - Since the `Outputable Cpr` instance changed anyway, I removed the leading `m` which we used to emit for `ConCpr`. It's just noise, especially now that we may output nested CPRs. Fixes #19398. - - - - - 8592a246 by Simon Jakobi at 2021-03-20T07:51:01-04:00 Add compiler perf regression test for #9198 - - - - - d4605e7c by Simon Peyton Jones at 2021-03-20T07:51:36-04:00 Fix an levity-polymorphism error As #19522 points out, we did not account for visible type application when trying to reject naked levity-polymorphic functions that have no binding. This patch tidies up the code, and fixes the bug too. - - - - - 3fa3fb79 by John Ericson at 2021-03-20T07:52:12-04:00 Add more boundary checks for `rem` and `mod` It's quite backend-dependent whether we will actually handle that case right, so let's just always do this as a precaution. In particular, once we replace the native primops used here with the new sized primops, the 16-bit ones on x86 will begin to use 16-bit sized instructions where they didn't before. Though I'm not sure of any arch which has 8-bit scalar instructions, I also did those for consistency. Plus, there are *vector* 8-bit ops in the wild, so if we ever got into autovectorization or something maybe it's prudent to put this here as a reminder not to forget about catching overflows. Progress towards #19026 - - - - - 8e054ff3 by John Ericson at 2021-03-20T07:52:47-04:00 Fix literals for unregisterized backend of small types All credit to @hsyl20, who in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4717#note_338560 figured out this was a problem. To fix this, we use casts in addition to the shrinking and suffixing that is already done. It might make for more verbose code, I don't think that matters too much. In the future, perhaps some of the shrinking and suffixing can be removed for being redundant. That proved less trivial than it sounds, so this wasn't done at this time. Progress towards #19026 Metric Increase: T12707 T13379 Co-authored-by: Sylvain Henry <hsyl20 at gmail.com> - - - - - 226cefd0 by Sylvain Henry at 2021-03-20T07:53:24-04:00 Fix fake import in GHC.Exception.Type boot module It seems like I imported "GHC.Types ()" thinking that it would transitively import GHC.Num.Integer when I wrote that module; but it doesn't. This led to build failures. See https://mail.haskell.org/pipermail/ghc-devs/2021-March/019641.html - - - - - e84e2805 by Viktor Dukhovni at 2021-03-20T07:54:01-04:00 Add fold vs. mconcat test T17123 - - - - - fa499356 by Sebastian Graf at 2021-03-20T07:54:36-04:00 Remove outdated Vagrantfile - - - - - 71e609fb by Moritz Angermann at 2021-03-20T07:55:11-04:00 Add error information to osCommitMemory on failure. - - - - - fb939498 by Ben Gamari at 2021-03-20T10:20:30-04:00 gitlab-ci: Always start with fresh clone Currently we are suffering from issues that appear to be caused by non-hermetic builds. Try avoiding this by setting `GIT_STRATEGY` to `clone`. - - - - - c53faa0c by Ben Gamari at 2021-03-20T15:12:12-04:00 Clean up TBDs in changelog (cherry picked from commit 4f334120c8e9cc4aefcbf11d99f169f648af9fde) - - - - - 91ddac2f by Ryan Scott at 2021-03-20T15:12:12-04:00 Move miscategorized items in template-haskell changelog - - - - - 6a375b53 by Ryan Scott at 2021-03-20T15:12:12-04:00 Bump template-haskell version to 2.18.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #19083. - - - - - adbaa9a9 by Ryan Scott at 2021-03-21T19:40:02-04:00 Remove unnecessary extendTyVarEnvFVRn function The `extendTyVarEnvFVRn` function does the exact same thing as `bindLocalNamesFV`. I see no meaningful distinction between the two functions, so let's just remove the former (which is only used in a handful of places) in favor of the latter. Historical note: `extendTyVarEnvFVRn` and `bindLocalNamesFV` used to be distinct functions, but their implementations were synchronized in 2004 as a part of commit 20e39e0e07e4a8e9395894b2785d6675e4e3e3b3. - - - - - 0cbdba27 by Moritz Angermann at 2021-03-21T21:04:42-04:00 [ci/arm/darwin/testsuite] Forwards ports from GHC-8.10 This is a set of forward ports (cherry-picks) from 8.10 - a7d22795ed [ci] Add support for building on aarch64-darwin - 5109e87e13 [testlib/driver] denoise - 307d34945b [ci] default value for CONFIGURE_ARGS - 10a18cb4e0 [testsuite] mark ghci056 as fragile - 16c13d5acf [ci] Default value for MAKE_ARGS - ab571457b9 [ci/build] Copy config.sub around - 251892b98f [ci/darwin] bump nixpkgs rev - 5a6c36ecb4 [testsuite/darwin] fix conc059 - aae95ef0c9 [ci] add timing info - 3592d1104c [Aarch64] No div-by-zero; disable test. - 57671071ad [Darwin] mark stdc++ tests as broken - 33c4d49754 [testsuite] filter out superfluous dylib warnings - 4bea83afec [ci/nix-shell] Add Foundation and Security - 6345530062 [testsuite/json2] Fix failure with LLVM backends - c3944bc89d [ci/nix-shell] [Darwin] Stop the ld warnings about libiconv. - b821fcc714 [testsuite] static001 is not broken anymore. - f7062e1b0c [testsuite/arm64] fix section_alignment - 820b076698 [darwin] stop the DYLD_LIBRARY_PATH madness - 07b1af0362 [ci/nix-shell] uniquify NIX_LDFLAGS{_FOR_TARGET} As well as a few additional fixups needed to make this block compile: - Fixup all.T - Set CROSS_TARGET, BROKEN_TESTS, XZ, RUNTEST_ARGS, default value. - [ci] shell.nix bump happy - - - - - c46e8147 by Moritz Angermann at 2021-03-21T21:04:42-04:00 [elf/aarch64] Fall Through decoration - - - - - 069abe27 by Moritz Angermann at 2021-03-21T21:04:42-04:00 [llvm/darwin] change vortex cpu to generic For now only the apple flavoured llvm knows vortex, as we build against other toolchains, lets stay with generic for now. - - - - - 2907949c by Moritz Angermann at 2021-03-21T21:04:42-04:00 [ci] Default values for GITLAB_CI_BRANCH, and IGNORE_PERF_FAILURES - - - - - e82d32d6 by Ben Gamari at 2021-03-22T09:22:29-04:00 compiler: Introduce mutableByteArrayContents# primop As noted in #19540, a number of users within and outside of GHC rely on unsafeCoerceUnlifted to work around the fact that this was missing - - - - - eeba7a3a by Ben Gamari at 2021-03-22T09:22:29-04:00 base: Use mutableByteArrayContents - - - - - a9129f9f by Simon Peyton Jones at 2021-03-22T09:23:04-04:00 Short-circuit warning generation for partial type signatures This Note says it all: Note [Skip type holes rapidly] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose we have module with a /lot/ of partial type signatures, and we compile it while suppressing partial-type-signature warnings. Then we don't want to spend ages constructing error messages and lists of relevant bindings that we never display! This happened in #14766, in which partial type signatures in a Happy-generated parser cause a huge increase in compile time. The function ignoreThisHole short-circuits the error/warning generation machinery, in cases where it is definitely going to be a no-op. It makes a pretty big difference on the Sigs.hs example in #14766: Compile-time allocation GHC 8.10 5.6G Before this patch 937G With this patch 4.7G Yes, that's more than two orders of magnitude! - - - - - 6e437a12 by Ben Gamari at 2021-03-22T18:35:24-04:00 UniqSM: oneShot-ify Part of #18202 ------------------------- Metric Decrease: T12707 T3294 ------------------------- - - - - - 26dd1f88 by Simon Peyton Jones at 2021-03-23T08:09:05-04:00 More improvement to MonoLocalBinds documentation - - - - - 26ba86f7 by Peter Trommler at 2021-03-23T08:09:40-04:00 PPC NCG: Fix int to float conversion In commit 540fa6b2 integer to float conversions were changed to round to the nearest even. Implement a special case for 64 bit integer to single precision floating point numbers. Fixes #19563. - - - - - 7a657751 by Ben Gamari at 2021-03-23T13:00:37-04:00 rts: Use long-path-aware stat Previously `pathstat` relied on msvcrt's `stat` implementation, which was not long-path-aware. It should rather be defined in terms of the `stat` implementation provided by `utils/fs`. Fixes #19541. - - - - - 05c5c054 by Sylvain Henry at 2021-03-23T13:01:15-04:00 Move loader state into Interp The loader state was stored into HscEnv. As we need to have two interpreters and one loader state per interpreter in #14335, it's natural to make the loader state a field of the Interp type. As a side effect, many functions now only require a Interp parameter instead of HscEnv. Sadly we can't fully free GHC.Linker.Loader of HscEnv yet because the loader is initialised lazily from the HscEnv the first time it is used. This is left as future work. HscEnv may not contain an Interp value (i.e. hsc_interp :: Maybe Interp). So a side effect of the previous side effect is that callers of the modified functions now have to provide an Interp. It is satisfying as it pushes upstream the handling of the case where HscEnv doesn't contain an Interpreter. It is better than raising a panic (less partial functions, "parse, don't validate", etc.). - - - - - df895b3f by Ben Gamari at 2021-03-23T20:43:36-04:00 gitlab-ci: Rework handling of head.hackage job trigger GitLab 12.3 now has reasonable support [1] for cross-project job dependencies, allowing us to drop the awful hack of a shell script we used previously. [1] https://docs.gitlab.com/ee/ci/multi_project_pipelines.html#mirroring-status-from-triggered-pipeline - - - - - 25306ddc by GHC GitLab CI at 2021-03-23T20:44:11-04:00 EPA: Run exactprint transformation tests as part of CI EPA == exact print annotations. When !2418 landed, it did not run the tests brought over from ghc-exactprint for making sure the AST prints correctly efter being edited. This enables those tests. - - - - - 55fd158d by Ben Gamari at 2021-03-24T12:35:23+01:00 CmmToAsm.Reg.Linear: Use concat rather than repeated (++) - - - - - 23f4bc89 by Ben Gamari at 2021-03-24T12:35:23+01:00 CmmToAsm.Reg.Linear: oneShot-ify RegM ------------------------- Metric Decrease: T783 T4801 T12707 T13379 T3294 T4801 T5321FD ------------------------- - - - - - 60127035 by Andreas Klebinger at 2021-03-24T16:10:07-04:00 STG AST - Make ConstructorNumber always a field. It's used by all passes and already used as a regular field. So I figured it would be both more consistent and performant to make it a regular field for all constructors. I also added a few bangs in the process. - - - - - 5483b1a4 by Adam Sandberg Ericsson at 2021-03-24T23:31:09-04:00 hadrian: remove alex and happy from build-tools Hadrian doesn't actually depend on them as built-tools and normal usage where you want to compile GHC will pick up the tools before you run hadrian via the ./configure script. Not building an extra copy of alex and happy might also improve overall build-times when building from scratch. - - - - - aa99f516 by Simon Peyton Jones at 2021-03-24T23:31:44-04:00 Fix the binder-swap transformation in OccurAnal The binder-swap transformation needs to be iterated, as shown by #19581. The fix is pretty simple, and is explained in point (BS2) of Note [The binder-swap substitution]. Net effect: - sometimes, fewer simplifier iterations - sometimes, more case merging - - - - - 0029df2b by Hécate at 2021-03-25T04:52:41-04:00 Add compiler linting to CI This commit adds the `lint:compiler` Hadrian target to the CI runner. It does also fixes hints in the compiler/ and libraries/base/ codebases. - - - - - 1350a5cd by GHC GitLab CI at 2021-03-25T04:53:16-04:00 EPA : Remove ApiAnn from ParsedModule All the comments are now captured in the AST, there is no need for a side-channel structure for them. - - - - - c74bd3da by GHC GitLab CI at 2021-03-25T17:31:57+00:00 EPA: Tidy up some GHC.Parser.Annotation comments This is a follow up from !2418 / #19579 [skip ci] - - - - - 0d5d344d by Oleg Grenrus at 2021-03-25T17:36:50-04:00 Implement -Wmissing-kind-signatures Fixes #19564 - - - - - d930fecb by Sylvain Henry at 2021-03-26T19:00:07-04:00 Refactor interface loading In order to support several home-units and several independent unit-databases, it's easier to explicitly pass UnitState, DynFlags, etc. to interface loading functions. This patch converts some functions using monads such as IfG or TcRnIf with implicit access to HscEnv to use IO instead and to pass them specific fields of HscEnv instead of an HscEnv value. - - - - - 872a9444 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Refactor NameCache * Make NameCache the mutable one and replace NameCacheUpdater with it * Remove NameCache related code duplicated into haddock Bump haddock submodule - - - - - 599efd90 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Refactor FinderCache - - - - - 532c6a54 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Remove UniqSupply from NameCache As suggested by @alexbiehl, this patch replaces the always updated UniqSupply in NameCache with a fixed Char and use it with `uniqFromMask` to generate uniques. This required some refactoring because getting a new unique from the NameCache can't be done in pure code anymore, in particular not in an atomic update function for `atomicModifyIORef`. So we use an MVar instead to store the OrigNameCache field. For some reason, T12545 increases (+1%) on i386 while it decreases on other CI runners. T9630 ghc/peak increases only with the dwarf build on CI (+16%). Metric Decrease: T12425 T12545 T9198 T12234 Metric Increase: T12545 T9630 Update haddock submodule - - - - - 89ee9206 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Use foldGet in getSymbolTable Implement @alexbiehl suggestion of using a foldGet function to avoid the creation of an intermediate list while reading the symbol table. Do something similar for reading the Hie symbol table and the interface dictionary. Metric Decrease: T10421 - - - - - a9c0b3ca by Sylvain Henry at 2021-03-26T19:00:07-04:00 Bump haddock submodule - - - - - 628417b4 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Fix lint issue - - - - - ef03fa6f by GHC GitLab CI at 2021-03-26T19:00:42-04:00 Bump Win32 to 2.13.0.0 Bumps Win32 submodule. - - - - - 5741caeb by Sylvain Henry at 2021-03-26T19:01:20-04:00 Only update config.sub when it already exists (#19574) - - - - - 57d21e6a by Sebastian Graf at 2021-03-26T23:02:15-04:00 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. - - - - - c83e4d05 by Adam Sandberg Ericsson at 2021-03-26T23:02:52-04:00 hadrian: build ghc-stageN wrapper when building the stageN:exe:ghc-bin target - - - - - 59375de1 by Viktor Dukhovni at 2021-03-27T18:09:31-04:00 bump submodule nofib - - - - - f72d4ebb by Ben Gamari at 2021-03-27T18:10:06-04:00 rts: Fix joinOSThread on Windows Previously we were treating the thread ID as a HANDLE, but it is not. We must first OpenThread. - - - - - f6960b18 by Simon Peyton Jones at 2021-03-28T00:11:46-04:00 Make RULES more robust in GHC.Float The RULES that use hand-written specialised code for overloaded class methods like floor, ceiling, truncate etc were fragile to certain transformations. This patch makes them robust. See #19582. It's all described in Note [Rules for overloaded class methods]. No test case because currently we don't do the transformation (floating out over-saturated applications) that makes this patch have an effect. But we may so so in future, and this patch makes the RULES much more robust. - - - - - b02c8ef7 by Sebastian Graf at 2021-03-28T00:12:21-04:00 Rename StrictSig to DmdSig (#19597) In #19597, we also settled on the following renamings: * `idStrictness` -> `idDmdSig`, `strictnessInfo` -> `dmdSigInfo`, `HsStrictness` -> `HsDmdSig` * `idCprInfo` -> `idCprSig`, `cprInfo` -> `cprSigInfo`, `HsCpr` -> `HsCprSig` Fixes #19597. - - - - - 29d75863 by Fendor at 2021-03-28T17:26:37-04:00 Add UnitId to Target record In the future, we want `HscEnv` to support multiple home units at the same time. This means, that there will be 'Target's that do not belong to the current 'HomeUnit'. This is an API change without changing behaviour. Update haddock submodule to incorporate API changes. - - - - - 9594f6f6 by Ben Gamari at 2021-03-28T17:27:12-04:00 gitlab-ci: Bump ci-images Upgrades bootstrap GHC to 8.10.4, hopefully avoiding #19600. - - - - - 9c9e40e5 by Oleg Grenrus at 2021-03-28T17:27:49-04:00 Replace - with negate It also failed to parse with HLint (I wonder how GHC itself handles it?) - - - - - c30af951 by Alfredo Di Napoli at 2021-03-29T07:58:00+02:00 Add `MessageClass`, rework `Severity` and add `DiagnosticReason`. Other than that: * Fix T16167,json,json2,T7478,T10637 tests to reflect the introduction of the `MessageClass` type * Remove `makeIntoWarning` * Remove `warningsToMessages` * Refactor GHC.Tc.Errors 1. Refactors GHC.Tc.Errors so that we use `DiagnosticReason` for "choices" (defer types errors, holes, etc); 2. We get rid of `reportWarning` and `reportError` in favour of a general `reportDiagnostic`. * Introduce `DiagnosticReason`, `Severity` is an enum: This big commit makes `Severity` a simple enumeration, and introduces the concept of `DiagnosticReason`, which classifies the /reason/ why we are emitting a particular diagnostic. It also adds a monomorphic `DiagnosticMessage` type which is used for generic messages. * The `Severity` is computed (for now) from the reason, statically. Later improvement will add a `diagReasonSeverity` function to compute the `Severity` taking `DynFlags` into account. * Rename `logWarnings` into `logDiagnostics` * Add note and expand description of the `mkHoleError` function - - - - - 4421fb34 by Moritz Angermann at 2021-03-29T17:25:48-04:00 [macho] improved linker with proper plt support This is a pre-requisite for making aarch64-darwin work. - - - - - e754ff7f by Moritz Angermann at 2021-03-29T17:25:49-04:00 Allocate Adjustors and mark them readable in two steps This drops allocateExec for darwin, and replaces it with a alloc, write, mark executable strategy instead. This prevents us from trying to allocate an executable range and then write to it, which X^W will prohibit on darwin. This will *only* work if we can use mmap. - - - - - 026a53e0 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] Additional FALLTHROUGH decorations. - - - - - dc6fa61c by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] SymbolExtras are only used on PPC and X86 - - - - - 710ef9d2 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] align prototype with implementation signature. - - - - - e72a2f77 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker/aarch64-elf] support section symbols for GOT relocation - - - - - 38504b6f by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testsuite] Fix SubsectionsViaSymbols test - - - - - 93b8db6b by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] no munmap if either agument is invalid. - - - - - 095e1624 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [rts] cast return value to struct. - - - - - 09ea36cf by Moritz Angermann at 2021-03-29T17:25:49-04:00 [aarch64-darwin] be very careful of warnings. So we did *not* have the stgCallocBytes prototype, and subsequently the C compiler defaulted to `int` as a return value. Thus generating sxtw instructions for the return value of stgCalloBytes to produce the expected void *. - - - - - 4bbd1445 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testlib] ignore strip warnings - - - - - df08d548 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [armv7] arm32 needs symbols! - - - - - f3c23939 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testsuite/aarch64] disable T18623 - - - - - 142950d9 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testsuite/aarch64-darwin] disable T12674 - - - - - 66044095 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [armv7] PIC by default + [aarch64-linux] T11276 metric increase Metric Increase: T11276 - - - - - afdacc55 by Takenobu Tani at 2021-03-30T20:41:46+09:00 users-guide: Correct markdown for ghc-9.2 This patch corrects some markdown. [skip ci] - - - - - 470839c5 by Oleg Grenrus at 2021-03-30T17:39:39-04:00 Additionally export asum from Control.Applicative Fixes #19575 - - - - - 128fd85c by Simon Jakobi at 2021-03-30T17:40:14-04:00 Add regression test for #5298 Closes #5298. - - - - - 86e7aa01 by Ben Gamari at 2021-03-30T19:14:19-04:00 gitlab-ci: Trigger head.hackage jobs via pipeline ID As noted in ghc/head.hackage!152, the previous plan of using the commit didn't work when the triggering pipeline had not yet successfully finished. - - - - - 59e82fb3 by Oleg Grenrus at 2021-03-31T11:12:17-04:00 import Data.List with explicit import list - - - - - 44774dc5 by Oleg Grenrus at 2021-03-31T11:12:17-04:00 Add -Wcompat to hadrian Update submodules haskeline and hpc - - - - - dbadd672 by Simon Peyton Jones at 2021-03-31T11:12:52-04:00 The result kind of a signature can't mention quantified vars This patch fixes a small but egregious bug, which allowed a type signature like f :: forall a. blah not to fail if (blah :: a). Acutally this only showed up as a ASSERT error (#19495). The fix is very short, but took quite a bit of head scratching Hence the long Note [Escaping kind in type signatures] While I was in town, I also added a short-cut for the common case of having no quantifiers to tcImplicitTKBndrsX. Metric Decrease: T9198 Metric Increase: T9198 - - - - - 2fcebb72 by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : Rename AddApiAnn to AddEpAnn As port of the process of migrating naming from API Annotations to exact print annotations (EPA) Follow-up from !2418, see #19579 - - - - - 0fe5175a by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : Rename ApiAnn to EPAnn Follow-up from !2418, see #19579 Updates haddock submodule - - - - - d03005e6 by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : rename 'api annotations' to 'exact print annotations' In comments, and notes. Follow-up from !2418, see #19579 - - - - - 49bc1e9e by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : rename AnnAnchor to EpaAnchor Follow-up from !2418, see #19579 - - - - - 798d8f80 by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : Rename AnnComment to EpaComment Follow-up from !2418, see #19579 - - - - - 317295da by Simon Peyton Jones at 2021-03-31T11:14:04-04:00 Avoid fundep-caused loop in the typechecker Ticket #19415 showed a nasty typechecker loop, which can happen with fundeps that do not satisfy the coverage condition. This patch fixes the problem. It's described in GHC.Tc.Solver.Interact Note [Fundeps with instances] It's not a perfect solution, as the Note explains, but it's better than the status quo. - - - - - aaf8e293 by Ryan Scott at 2021-03-31T11:14:39-04:00 Add regression tests for #17772 and #18308 Resolves #17772. Addresses one part of #18308. - - - - - efe5fdab by Ben Gamari at 2021-03-31T11:15:14-04:00 gitlab-ci: Extend expiration time of simple perf job artifacts - - - - - 5192183f by Oleg Grenrus at 2021-04-01T00:39:28-04:00 import Data.List with explicit import list - - - - - bddecda1 by Oleg Grenrus at 2021-04-01T00:39:28-04:00 Data.List specialization to [] - Remove GHC.OldList - Remove Data.OldList - compat-unqualified-imports is no-op - update haddock submodule - - - - - 751b2144 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Encapsulate the EPS IORef in a newtype - - - - - 29326979 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Properly initialise UnitEnv - - - - - 0219297c by Sylvain Henry at 2021-04-01T00:40:07-04:00 Move unit DBs in UnitEnv Also make the HomeUnit optional to keep the field strict and prepare for UnitEnvs without a HomeUnit (e.g. in Plugins envs, cf #14335). - - - - - 7acfb617 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Move HPT in UnitEnv - - - - - 85d7056a by Sylvain Henry at 2021-04-01T00:40:07-04:00 Move the EPS into UnitEnv - - - - - 706fad60 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Fix tests - - - - - b2f51099 by Ben Gamari at 2021-04-01T08:21:30-04:00 ghc-bignum: Add missing source files to cabal file - - - - - 9b05b601 by Ben Gamari at 2021-04-01T08:21:30-04:00 ghc-boot: Use cabal-version: 3.0 - - - - - 75e594d0 by Ben Gamari at 2021-04-01T08:21:30-04:00 libiserv: Add description - - - - - 2266bdae by Ben Gamari at 2021-04-01T08:21:30-04:00 configure: Update comment describing versioning policy As noted in my comment on #19058, this comment was previously a bit misleading in the case of stable branches. - - - - - 65c50d8d by Ben Gamari at 2021-04-01T08:21:30-04:00 gitlab-ci: Drop Debian 8 job - - - - - d44e42a2 by Vladislav Zavialov at 2021-04-01T08:22:06-04:00 Add missing axiom exports for CharToNat/NatToChar When the CharToNat and NatToChar type families were added, the corresponding axioms were not exported. This led to a failure much like #14934 - - - - - 15b6c9f9 by Alfredo Di Napoli at 2021-04-01T16:13:23-04:00 Compute Severity of diagnostics at birth This commit further expand on the design for #18516 by getting rid of the `defaultReasonSeverity` in favour of a function called `diagReasonSeverity` which correctly takes the `DynFlags` as input. The idea is to compute the `Severity` and the `DiagnosticReason` of each message "at birth", without doing any later re-classifications, which are potentially error prone, as the `DynFlags` might evolve during the course of the program. In preparation for a proper refactoring, now `pprWarning` from the Parser.Ppr module has been renamed to `mkParserWarn`, which now takes a `DynFlags` as input. We also get rid of the reclassification we were performing inside `printOrThrowWarnings`. Last but not least, this commit removes the need for reclassify inside GHC.Tc.Errors, and also simplifies the implementation of `maybeReportError`. Update Haddock submodule - - - - - 84b76f60 by Viktor Dukhovni at 2021-04-01T16:13:59-04:00 Chiral foldable caveats - - - - - 07393306 by Viktor Dukhovni at 2021-04-01T16:13:59-04:00 Address review feedback on chirality Also added nested foldr example for `concat`. - - - - - 8ef6eaf7 by Ben Gamari at 2021-04-02T05:15:23-04:00 sdist: Fix packaging of Windows tarballs These now live in the ghc-tarballs/mingw-w64 directory. Fixes #19316. - - - - - 82d8847e by Ben Gamari at 2021-04-02T05:15:23-04:00 gitlab-ci: CI wibbles Ensure that deb10-dwarf artifacts are preserved. - - - - - ee877571 by Ben Gamari at 2021-04-02T05:15:23-04:00 gitlab-ci: Ignore performance metrics failures in release jobs We don't want these failing merely due to performance metrics - - - - - ee55d57e by Matthew Pickering at 2021-04-02T05:15:59-04:00 Fix copy+pasto in Sanity.c - - - - - 78ca4a27 by Ben Gamari at 2021-04-02T05:16:35-04:00 testsuite: Make passFail a boolean - - - - - a9154662 by Ben Gamari at 2021-04-02T05:16:35-04:00 testsuite: Check test stats only after test correctness Ticket #19576 noted that a test that failed in correctness (e.g. due to stderr mismatch) *and* failed due to a metrics change would report misleading stats. This was due to the testsuite driver *first* checking stats, before checking for correctness. Fix this. Closes #19576. - - - - - c265d19f by Ben Gamari at 2021-04-02T05:17:11-04:00 testsuite: Add test for #7275 - - - - - ce706fae by Sebastian Graf at 2021-04-02T05:17:47-04:00 Pmc: Add regression test for #19622 It appears that the issue has already been fixed. Judging by the use of a pattern synonym with a provided constraint, my bet is on 1793ca9d. Fixes #19622. - - - - - 918d5021 by Ben Gamari at 2021-04-05T20:37:28-04:00 configure: Fix parsing of ARM triples To support proper parsing of arm64 targets, we needed to adjust the GHC_LLVM_TARGET function to allow parsing arm64-apple-darwin into aarch64. This however discared the proper os detection. To rectify this, we'll pull the os detection into separate block. Fixes #19173. - - - - - 9c9adbd0 by Oleg Grenrus at 2021-04-05T20:38:07-04:00 Implement proposal 403: Lexer cleanup This allows Other Numbers to be used in identifiers, and also documents other, already existing lexer divergence from Haskell Report - - - - - 89acbf35 by Matthew Pickering at 2021-04-05T20:38:42-04:00 Add special case to stripStgTicksTop for [] In the common case where the list of ticks is empty, building a thunk just applies 'reverse' to '[]' which is quite wasteful. - - - - - 77772bb1 by Harry Garrood harry at garrood.me at 2021-04-05T20:39:19-04:00 Add type signature for TargetContents.go These changes made it slightly easier for me to work out what was going on in this test. I've also fixed a typo in the comments. - - - - - 49528121 by Alfredo Di Napoli at 2021-04-05T20:39:54-04:00 Introduce SevIgnore Severity to suppress warnings This commit introduces a new `Severity` type constructor called `SevIgnore`, which can be used to classify diagnostic messages which are not meant to be displayed to the user, for example suppressed warnings. This extra constructor allows us to get rid of a bunch of redundant checks when emitting diagnostics, typically in the form of the pattern: ``` when (optM Opt_XXX) $ addDiagnosticTc (WarningWithFlag Opt_XXX) ... ``` Fair warning! Not all checks should be omitted/skipped, as evaluating some data structures used to produce a diagnostic might still be expensive (e.g. zonking, etc). Therefore, a case-by-case analysis must be conducted when deciding if a check can be removed or not. Last but not least, we remove the unnecessary `CmdLine.WarnReason` type, which is now redundant with `DiagnosticReason`. - - - - - 3483c3de by Alfredo Di Napoli at 2021-04-05T20:39:54-04:00 Correct warning for deprecated and unrecognised flags Fixes #19616. This commit changes the `GHC.Driver.Errors.handleFlagWarnings` function to rely on the newly introduced `DiagnosticReason`. This allows us to correctly pretty-print the flags which triggered some warnings and in turn remove the cruft around this function (like the extra filtering and the `shouldPrintWarning` function. - - - - - 54247fb1 by Joachim Breitner at 2021-04-05T20:40:30-04:00 ./configure: Indicate that GHC=… should be a full path and not just the name on the binary on the `$PATH`. - - - - - 5db116e9 by Joachim Breitner at 2021-04-05T20:40:30-04:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 2783d498 by Luite Stegeman at 2021-04-05T20:41:06-04:00 fix sub-word literals in GHCi - - - - - 33b88645 by Andreas Klebinger at 2021-04-05T20:41:41-04:00 Add regression test for T19474. In version 0.12.2.0 of vector when used with GHC-9.0 we rebox values from storeable mutable vectors. This should catch such a change in the future. - - - - - 939fa61c by Łukasz Gołębiewski at 2021-04-05T20:42:17-04:00 Fixes Monad's associativity docs It is incorrectly displayed in hackage as: `m1 <*> m2 = m1 >>= (x1 -> m2 >>= (x2 -> return (x1 x2)))` which isn't correct Haskell - - - - - 10782edf by Simon Jakobi at 2021-04-05T20:42:53-04:00 Mark p6 and T3333 as fragile See #17018. - - - - - 048af266 by Andreas Klebinger at 2021-04-05T20:43:27-04:00 One-Shotify GHC.Utils.Monad.State (#18202) - - - - - 83654240 by Matthew Pickering at 2021-04-05T20:44:02-04:00 Add (expect_broken) test for #11545 - - - - - 53cf2c04 by Ben Gamari at 2021-04-05T20:44:37-04:00 hadrian: Refactor hlint target Not only does this eliminate some code duplication but we also add a maximum core count to HLint's command-line, hopefully avoiding issue #19600. - - - - - eac9d376 by Ben Gamari at 2021-04-05T20:45:12-04:00 hadrian: Fix build-stack-nix As noted by #19589, `stack` is not stateful and therefore must be passed `--nix` on every invocation. Do so. Fixes #19589. - - - - - bfe8ef8e by Ben Gamari at 2021-04-05T20:45:46-04:00 rts: Fix usage of pthread_setname_np Previously we used this non-portable function unconditionally, breaking FreeBSD. Fixes #19637. - - - - - 403bf88c by Ben Gamari at 2021-04-05T20:46:21-04:00 Revert "[ci/arm/darwin/testsuite] Forwards ports from GHC-8.10" This reverts commit 0cbdba2768d84a0f6832ae5cf9ea1e98efd739da. - - - - - 54880c13 by Sylvain Henry at 2021-04-05T20:46:59-04:00 Bignum: fix invalid hs-boot declaration (#19638) - - - - - 247684ad by Sylvain Henry at 2021-04-05T20:47:37-04:00 Bignum: remove unused extra files - - - - - 2e3a6fba by Adam Sandberg Ericsson at 2021-04-07T12:37:11-04:00 hadrian: don't hardcode -fuse-ld=gold in hsc2hs wrapper #19514 - - - - - b06e457d by Simon Peyton Jones at 2021-04-07T12:37:47-04:00 Make specialisation a bit more aggressive The patch commit c43c981705ec33da92a9ce91eb90f2ecf00be9fe Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Oct 23 16:15:51 2009 +0000 Fix Trac #3591: very tricky specialiser bug fixed a nasty specialisation bug /for DFuns/. Eight years later, this patch commit 2b74bd9d8b4c6b20f3e8d9ada12e7db645cc3c19 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 7 12:03:51 2017 +0100 Stop the specialiser generating loopy code extended it to work for /imported/ DFuns. But in the process we lost the fact that it was needed only for DFuns! As a result we started silently losing useful specialisation for non-DFuns. But there was no regression test to spot the lossage. Then, nearly four years later, Andreas filed #19599, which showed the lossage in high relief. This patch restores the DFun test, and adds Note [Avoiding loops (non-DFuns)] to explain why. This is undoubtedly a very tricky corner of the specialiser, and one where I would love to have a more solid argument, even a paper! But meanwhile I think this fixes the lost specialisations without introducing any new loops. I have two regression tests, T19599 and T19599a, so I hope we'll know if we lose them again in the future. Vanishingly small effect on nofib. A couple of compile-time benchmarks improve T9872a(normal) ghc/alloc 1660559328.0 1643827784.0 -1.0% GOOD T9872c(normal) ghc/alloc 1691359152.0 1672879384.0 -1.1% GOOD Many others wiggled around a bit. Metric Decrease: T9872a T9872c - - - - - 546f8b14 by Matthew Pickering at 2021-04-07T12:38:22-04:00 hadrian: Don't try to build iserv-prof if we don't have profiled libraries Workaround for #19624 - - - - - d014ab0d by Sylvain Henry at 2021-04-07T12:39:00-04:00 Remove dynamic-by-default (#16782) Dynamic-by-default was a mechanism to automatically select the -dynamic way for some targets. It was implemented in a convoluted way: it was defined as a flavour option, hence it couldn't be passed as a global settings (which are produced by `configure` before considering flavours), so a build system rule was used to pass -DDYNAMIC_BY_DEFAULT to the C compiler so that deriveConstants could infer it. * Make build system has it disabled for 8 years (951e28c0625ece7e0db6ac9d4a1e61e2737b10de) * It has never been implemented in Hadrian * Last time someone tried to enable it 1 year ago it didn't work (!2436) * Having this as a global constant impedes making GHC multi-target (see !5427) This commit fully removes support for dynamic-by-default. If someone wants to reimplement something like this, it would probably need to move the logic in the compiler. (Doing this would probably need some refactoring of the way the compiler handles DynFlags: DynFlags are used to store and to pass enabled ways to many parts of the compiler. It can be set by command-line flags, GHC API, global settings. In multi-target GHC, we will use DynFlags to load the target platform and its constants: but at this point with the current DynFlags implementation we can't easily update the existing DynFlags with target-specific options such as dynamic-by-default without overriding ways previously set by the user.) - - - - - 88d8a0ed by James Foster at 2021-04-07T14:17:31-04:00 Change foldl' to inline when partially applied (#19534) And though partially applied foldl' is now again inlined, #4301 has not resurfaced, and appears to be resolved. - - - - - 898afe90 by Matthew Pickering at 2021-04-08T08:07:10-04:00 Stop retaining SimplEnvs in unforced Unfoldings Related to #15455 - - - - - 8417e866 by Matthew Pickering at 2021-04-08T08:07:10-04:00 Don't retain reference to whole TcLclEnv in SkolemTV - - - - - 352a463b by Matthew Pickering at 2021-04-08T08:07:10-04:00 Use DmdEnv rather than VarEnv DmdEnv - - - - - adc52bc8 by Matthew Pickering at 2021-04-08T08:07:10-04:00 Make updTcRef force the result This can lead to a classic thunk build-up in a TcRef Fixes #19596 - - - - - eaa1461a by Matthew Pickering at 2021-04-08T08:07:11-04:00 Make sure mergeWithKey is inlined and applied strictly In the particular case of `DmdEnv`, not applying this function strictly meant 500MB of thunks were accumulated before the values were forced at the end of demand analysis. - - - - - 629a5e98 by Matthew Pickering at 2021-04-08T08:07:11-04:00 Some extra strictness in Demand.hs It seems that these places were supposed to be forced anyway but the forcing has no effect because the result was immediately placed in a lazy box. - - - - - 42d88003 by Matthew Pickering at 2021-04-08T08:07:11-04:00 Make sure result of demand analysis is forced promptly This avoids a big spike in memory usage during demand analysis. Part of fixing #15455 ------------------------- Metric Decrease: T18698a T18698b T9233 T9675 T9961 ------------------------- - - - - - e0d861d4 by Matthew Pickering at 2021-04-08T08:07:11-04:00 T11545 now also passes due to modifications in demand analysis Fixes #11545 - - - - - a3cc9a29 by Ryan Scott at 2021-04-08T08:07:45-04:00 Fix #19649 by using filterInScopeM in rnFamEqn Previously, associated type family instances would incorrectly claim to implicitly quantify over type variables bound by the instance head in the `HsOuterImplicit`s that `rnFamEqn` returned. This is fixed by using `filterInScopeM` to filter out any type variables that the instance head binds. Fixes #19649. - - - - - 6e8e2e08 by Alfredo Di Napoli at 2021-04-08T08:08:20-04:00 Move Iface.Load errors into Iface.Errors module This commit moves the error-related functions in `GHC.Iface.Load` into a brand new module called `GHC.Iface.Errors`. This will avoid boot files and circular dependencies in the context of #18516, in the pretty-printing modules. - - - - - 8a099701 by Ben Gamari at 2021-04-09T03:30:26-04:00 CoreTidy: enhance strictness note - - - - - 0bdb867e by Sylvain Henry at 2021-04-09T03:30:26-04:00 CoreTidy: handle special cases to preserve more sharing. Metric Decrease: T16577 - - - - - c02ac1bb by Andreas Klebinger at 2021-04-09T03:31:02-04:00 Re-export GHC.Bits from GHC.Prelude with custom shift implementation. This allows us to use the unsafe shifts in non-debug builds for performance. For older versions of base we instead export Data.Bits See also #19618 - - - - - 35407d67 by Peter Trommler at 2021-04-09T03:31:37-04:00 testsuite: Skip T18623 on powerpc64le In commit f3c23939 T18623 is disabled for aarch64. The limit seems to be too low for powerpc64le, too. This could be because tables next to code is not supported and our code generator produces larger code on PowerPC. - - - - - d8f04425 by Peter Trommler at 2021-04-09T03:31:37-04:00 Fix typo - - - - - fd5ca9c3 by Peter Trommler at 2021-04-09T03:31:37-04:00 testsuite/ppc64le: Mark UnboxedTuples test broken - - - - - d4a71b0c by Matthew Pickering at 2021-04-09T03:32:12-04:00 Avoid repeated zonking and tidying of types in `relevant_bindings` The approach taking in this patch is that the tcl_bndrs in TcLclEnv are zonked and tidied eagerly, so that work can be shared across multiple calls to `relevant_bindings`. To test this patch I tried without the `keepThisHole` filter and the test finished quickly. Fixes #14766 - - - - - 28d2d646 by Matthew Pickering at 2021-04-09T03:32:47-04:00 Don't tidy type in pprTypeForUser There used to be some cases were kinds were not generalised properly before being printed in GHCi. This seems to have changed in the past so now it's uncessary to tidy before printing out the test case. ``` > :set -XPolyKinds > data A x y > :k A k1 -> k2 -> A ``` This tidying was causing issues with an attempt to increase sharing by making `mkTyConApp` (see !4762) - - - - - 6d29e635 by Matthew Pickering at 2021-04-09T03:33:22-04:00 Add perf test for #15304 The test max memory usage improves dramatically with the fixes to memory usage in demand analyser from #15455 - - - - - 70c39e22 by Douglas Wilson at 2021-04-09T03:33:56-04:00 [docs] release notes for !4729 + !3678 Also includes small unrelated type fix - - - - - c1d6daab by Matthew Pickering at 2021-04-09T03:34:31-04:00 Update HACKING.md - - - - - a951e069 by Sylvain Henry at 2021-04-09T03:35:08-04:00 Bignum: add BigNat Eq/Ord instances (#19647) - - - - - cd391756 by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Tweak kick-out condition K2b to deal with LHSs Kick out condition K2b really only makes sense for inerts with a type variable on the left. This updates the commentary and the code to skip this check for inerts with type families on the left. Also cleans up some commentary around solver invariants and adds Note [K2b]. Close #19042. test case: typecheck/should_compile/T19042 - - - - - 7536126e by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Kick out fewer equalities by thinking harder Close #17672. By scratching our heads quite hard, we realized that we should never kick out Given/Nominal equalities. This commit tweaks the kick-out conditions accordingly. See also Note [K4] which describes what is going on. This does not fix a known misbehavior, but it should be a small improvement in both practice (kicking out is bad, and we now do less of it) and theory (a Given/Nominal should behave just like a filled-in metavariable, which has no notion of kicking out). - - - - - 449be647 by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Clarify commentary around the constraint solver No changes to code; no changes to theory. Just better explanation. - - - - - 3c98dda6 by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Test #19665 as expect_broken, with commentary - - - - - 6b1d0b9c by Koz Ross at 2021-04-10T05:29:59-04:00 Implement list `fold` and `foldMap` via mconcat - This allows specialized mconcat implementations an opportunity to combine elements efficiently in a single pass. - Inline the default implementation of `mconcat`, this may result in list fusion. - In Monoids with strict `mappend`, implement `mconcat` as a strict left fold: * And (FiniteBits) * Ior (FiniteBits) * Xor (FiniteBits) * Iff (FiniteBits) * Max (Ord) * Min (Ord) * Sum (Num) * Product (Num) * (a -> m) (Monoid m) - Delegate mconcat for WrappedMonoid to the underlying monoid. Resolves: #17123 Per the discussion in !4890, we expect some stat changes: * T17123(normal) run/alloc 403143160.0 4954736.0 -98.8% GOOD This is the expected improvement in `fold` for a long list of `Text` elements. * T13056(optasm) ghc/alloc 381013328.0 447700520.0 +17.5% BAD Here there's an extra simplifier run as a result of the new methods of the Foldable instance for List. It looks benign. The test is a micro benchmark that compiles just the derived foldable instances for a pair of structures, a cost of this magnitude is not expected to extend to more realistic programs. * T9198(normal) ghc/alloc 504661992.0 541334168.0 +7.3% BAD This test regressed from 8.10 and 9.0 back to exponential blowup. This metric also fluctuates, for reasons not yet clear. The issue here is the exponetial blowup, not this MR. Metric Decrease: T17123 Metric Increase: T9198 T13056 - - - - - 3f851bbd by Sylvain Henry at 2021-04-10T05:30:37-04:00 Enhance pretty-printing perf A few refactorings made after looking at Core/STG * Use Doc instead of SDoc in pprASCII to avoid passing the SDocContext that is never used. * Inline every SDoc wrappers in GHC.Utils.Outputable to expose Doc constructs * Add text/[] rule for empty strings (i.e., text "") * Use a single occurrence of pprGNUSectionHeader * Use bangs on Platform parameters and some others Metric Decrease: ManyAlternatives ManyConstructors T12707 T13035 T13379 T18698a T18698b T1969 T3294 T4801 T5321FD T783 - - - - - 9c762f27 by Sylvain Henry at 2021-04-10T05:31:14-04:00 Generate parser for DerivedConstants.h deriveConstants utility now generates a Haskell parser for DerivedConstants.h. It can be used to replace the one used to read platformConstants file. - - - - - 085983e6 by Sylvain Henry at 2021-04-10T05:31:14-04:00 Read constants header instead of global platformConstants With this patch we switch from reading the globally installed platformConstants file to reading the DerivedConstants.h header file that is bundled in the RTS unit. When we build the RTS unit itself, we get it from its includes directories. The new parser is more efficient and strict than the Read instance for PlatformConstants and we get about 2.2MB less allocations in every cases. However it only really shows in tests that don't allocate much, hence the following metric decreases. Metric Decrease: Naperian T10421 T10547 T12150 T12234 T12425 T13035 T18304 T18923 T5837 T6048 T18140 - - - - - 2cdc95f9 by Sylvain Henry at 2021-04-10T05:31:14-04:00 Don't produce platformConstants file It isn't used for anything anymore - - - - - b699c4fb by Sylvain Henry at 2021-04-10T05:31:14-04:00 Constants: add a note and fix minor doc glitches - - - - - eb1a86bb by John Ericson at 2021-04-10T05:31:49-04:00 Allow C-- to scrutinize non-native-size words - - - - - c363108e by John Ericson at 2021-04-10T05:31:49-04:00 Add missing relational constant folding for sized numeric types - - - - - b39dec86 by Facundo Domínguez at 2021-04-10T05:32:28-04:00 Report actual port in libiserv:Remote.Slave.startSlave This allows to start iserv by passing port 0 to startSlave, which in turns allows to get an available port when no port is known to be free a priori. - - - - - 94d48ec9 by Matthew Pickering at 2021-04-10T05:33:03-04:00 Use CI_MERGE_REQUEST_SOURCE_BRANCH_NAME rather than undefined GITLAB_CI_BRANCH env var See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html - - - - - d39a2b24 by Matthew Pickering at 2021-04-10T05:33:03-04:00 tests: Allow --skip-perf-tests/--only-perf-tests to be used with --ignore-perf-failures - - - - - 6974c9e4 by Matthew Pickering at 2021-04-10T05:33:38-04:00 Fix magicDict in ghci (and in the presence of other ticks) The problem was that ghci inserts some ticks around the crucial bit of the expression. Just like in some of the other rules we now strip the ticks so that the rule fires more reliably. It was possible to defeat magicDict by using -fhpc as well, so not just an issue in ghci. Fixes #19667 and related to #19673 - - - - - 792d9289 by Simon Peyton Jones at 2021-04-12T13:50:49-04:00 More accurate SrcSpan when reporting redundant constraints We want an accurate SrcSpan for redundant constraints: • Redundant constraint: Eq a • In the type signature for: f :: forall a. Eq a => a -> () | 5 | f :: Eq a => a -> () | ^^^^ This patch adds some plumbing to achieve this * New data type GHC.Tc.Types.Origin.ReportRedundantConstraints (RRC) * This RRC value is kept inside - FunSigCtxt - ExprSigCtxt * Then, when reporting the error in GHC.Tc.Errors, use this SrcSpan to control the error message: GHC.Tc.Errors.warnRedundantConstraints Quite a lot of files are touched in a boring way. - - - - - 18cbff86 by Matthew Pickering at 2021-04-12T13:51:23-04:00 template-haskell: Run TH splices with err_vars from current context Otherwise, errors can go missing which arise when running the splices. Fixes #19470 - - - - - 89ff1230 by Matthew Pickering at 2021-04-12T13:51:58-04:00 Add regression test for T19615 Fixes #19615 - - - - - 9588f3fa by Matthew Pickering at 2021-04-12T13:52:33-04:00 Turn T11545 into a normal performance test This makes it more robust to people running it with `quick` flavour and so on. - - - - - d1acda98 by Matthew Pickering at 2021-04-12T17:07:01-04:00 CI: Also ignore metric decreases on master Otherwise, if the marge batch has decreased metrics, they will fail on master which will result in the pipeline being cut short and the expected metric values for the other jobs will not be updated. - - - - - 6124d172 by Stefan Schulze Frielinghaus at 2021-04-13T18:42:40-04:00 hadrian: Provide build rule for ghc-stage3 wrapper - - - - - ef013593 by Simon Peyton Jones at 2021-04-13T18:43:15-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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - 8d87975e by Sylvain Henry at 2021-04-13T18:43:53-04:00 Produce constant file atomically (#19684) - - - - - 1e2e62a4 by Ryan Scott at 2021-04-13T18:44:28-04:00 Add {lifted,unlifted}DataConKey to pretendNameIsInScope's list of Names Fixes #19688. - - - - - b665d983 by Ben Gamari at 2021-04-13T20:04:53-04:00 configure: Bump version to 9.3 Bumps the `haddock` submodule. - - - - - 726da09e by Matthew Pickering at 2021-04-14T05:07:45-04:00 Always generate ModDetails from ModIface This vastly reduces memory usage when compiling with `--make` mode, from about 900M when compiling Cabal to about 300M. As a matter of uniformity, it also ensures that reading from an interface performs the same as using the in-memory cache. We can also delete all the horrible knot-tying in updateIdInfos. Goes some way to fixing #13586 Accept new output of tests fixing some bugs along the way ------------------------- Metric Decrease: T12545 ------------------------- - - - - - 78ed7adf by Hécate Moonlight at 2021-04-14T14:40:46-04:00 Data.List strictness optimisations for maximumBy and minimumBy follow-up from !4675 - - - - - 79e5c867 by Peter Trommler at 2021-04-14T14:41:21-04:00 Prelude: Fix version bound on Bits import Fixes #19683 - - - - - 5f172299 by Adam Gundry at 2021-04-14T19:42:18-04:00 Add isInjectiveTyCon check to opt_univ (fixes #19509) - - - - - cc1ba576 by Matthew Pickering at 2021-04-14T19:42:53-04:00 Fix some negation issues when creating FractionalLit There were two different issues: 1. integralFractionalLit needed to be passed an already negated value. (T19680) 2. negateFractionalLit did not actually negate the argument, only flipped the negation flag. (T19680A) Fixes #19680 - - - - - da92e728 by Matthew Pickering at 2021-04-15T12:27:44-04:00 hie: Initialise the proper environment for calling dsExpr We now use DsM as the base monad for writing hie files and properly initialise it from the TcGblEnv. Before, we would end up reading the interface file from disk for the module we were currently compiling. The modules iface then ended up in the EPS causing all sorts of subtle carnage, including difference in the generated core and haddock emitting a lot of warnings. With the fix, the module in the TcGblEnv is set correctly so the lookups happen in the local name env rather than thinking the identifier comes from an external package. Fixes #19693 and #19334 - - - - - 0a8c14bd by Simon Peyton Jones at 2021-04-15T12:28:18-04:00 Fix handling ze_meta_tv_env in GHC.Tc.Utils.Zonk As #19668 showed, there was an /asymptotic/ slow-down in zonking in GHC 9.0, exposed in test T9198. The bug was actually present in earlier compilers, but by a fluke didn't actually show up in any of our tests; but adding Quick Look exposed it. The bug was that in zonkTyVarOcc we 1. read the meta-tyvar-env variable 2. looked up the variable in the env 3. found a 'miss' 4. looked in the variable, found `Indirect ty` 5. zonked `ty` 6. update the env *gotten from step 1* to map the variable to its zonked type. The bug is that we thereby threw away all teh work done in step 4. In T9198 that made an enormous, indeed asymptotic difference. The fix is easy: use updTcRef. I commented in `Note [Sharing when zonking to Type]` ------------------------- Metric Decrease: T9198 ------------------------- - - - - - 7bd12940 by Simon Peyton Jones at 2021-04-17T22:56:32+01:00 Improve CSE in STG-land This patch fixes #19717, a long-standing bug in CSE for STG, which led to a stupid loss of CSE in some situations. It's explained in Note [Trivial case scrutinee], which I have substantially extended. - - - - - c71b2204 by Simon Peyton Jones at 2021-04-17T23:03:56+01:00 Improvements in SpecConstr * Allow under-saturated calls to specialise See Note [SpecConstr call patterns] This just allows a bit more specialisation to take place. * Don't discard calls from un-specialised RHSs. This was a plain bug in `specialise`, again leading to loss of specialisation. Refactoring yields an `otherwise` case that is easier to grok. * I refactored CallPat to become a proper data type, not a tuple. All this came up when I was working on eta-reduction. The ticket is #19672. The nofib results are mostly zero, with a couple of big wins: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- awards +0.2% -0.1% -18.7% -18.8% 0.0% comp_lab_zift +0.2% -0.2% -23.9% -23.9% 0.0% fft2 +0.2% -1.0% -34.9% -36.6% 0.0% hpg +0.2% -0.3% -18.4% -18.4% 0.0% mate +0.2% -15.7% -19.3% -19.3% +11.1% parser +0.2% +0.6% -16.3% -16.3% 0.0% puzzle +0.4% -19.7% -33.7% -34.0% 0.0% rewrite +0.2% -0.5% -20.7% -20.7% 0.0% -------------------------------------------------------------------------------- Min +0.2% -19.7% -48.1% -48.9% 0.0% Max +0.4% +0.6% -1.2% -1.1% +11.1% Geometric Mean +0.2% -0.4% -21.0% -21.1% +0.1% I investigated the 0.6% increase on 'parser'. It comes because SpecConstr has a limit of 3 specialisations. With HEAD, hsDoExpr has 2 specialisations, and then a further several from the specialised bodies, of which 1 is picked. With this patch we get 3 specialisations right off the bat, so we discard all from the recursive calls. Turns out that that's not the best choice, but there is no way to tell that. I'm accepting it. NB: these figures actually come from this patch plus the preceding one for StgCSE, but I think the gains come from SpecConstr. - - - - - 40d28436 by Matthew Pickering at 2021-04-18T11:09:32-04:00 Only load package environment file once when starting GHCi Since d880d6b2e48268f5ed4d3eb751fe24cc833e9221 the parsing of the environment files was moved to `parseDynamicFlags`, under the assumption it was typically only called once. It turns out not to be true in GHCi and this led to continually reparsing the environment file whenever a new option was set, the options were appended to the package state and hence all packages reloaded, as it looked like the options were changed. The simplest fix seems to be a clearer specification: > Package environment files are only loaded in GHCi during initialisation. Fixes #19650 - - - - - a4234697 by Ben Gamari at 2021-04-18T20:12:26-04:00 Fix Haddock reference - - - - - 78288b97 by Ben Gamari at 2021-04-18T20:12:26-04:00 users-guide: Clarify GHC2021 documentation Point out that GHC2021 doesn't offer the same degree of stability that Haskell2010 does, as noted by @phadej. - - - - - b5189749 by Ben Gamari at 2021-04-18T20:12:26-04:00 users guide: Sort lists of implied language extensions - - - - - 0165b029 by Ben Gamari at 2021-04-18T20:12:26-04:00 users-guide: Add missing FieldSelectors to GHC2021 list - - - - - 0b398d55 by Ryan Scott at 2021-04-18T20:13:01-04:00 Use correct precedence in Complex's Read1/Show1 instances Fixes #19719. - - - - - 8b5e5b05 by Andreas Schwab at 2021-04-19T15:40:25-04:00 Enable tables next to code for riscv64 This requires adding another rewrite to the mangler, to avoid generating PLT entries. - - - - - 0619fb0f by Alan Zimmerman at 2021-04-19T15:41:00-04:00 EPA: cleanups after the merge Remove EpaAnn type synonym, rename EpaAnn' to EpaAnn. Closes #19705 Updates haddock submodule -- Change data EpaAnchor = AR RealSrcSpan | AD DeltaPos To instead be data EpaAnchor = AnchorReal RealSrcSpan | AnchorDelta DeltaPos Closes #19699 -- Change data DeltaPos = DP { deltaLine :: !Int, deltaColumn :: !Int } To instead be data DeltaPos = SameLine { deltaColumn :: !Int } | DifferentLine { deltaLine :: !Int, startColumn :: !Int } Closes #19698 -- Also some clean-ups of unused parts of check-exact. - - - - - 99bd4ae6 by Sebastian Graf at 2021-04-20T10:17:52+02:00 Factor out DynFlags from WorkWrap.Utils Plus a few minor refactorings: * Introduce `normSplitTyConApp_maybe` to Core.Utils * Reduce boolean blindness in the Bool argument to `wantToUnbox` * Let `wantToUnbox` also decide when to drop an argument, cleaning up `mkWWstr_one` - - - - - ee5dadad by Sebastian Graf at 2021-04-20T10:17:55+02:00 Refactor around `wantToUnbox` I renamed `wantToUnbox` to `wantToUnboxArg` and then introduced `wantToUnboxResult`, which we call in `mkWWcpr_one` now. I also deleted `splitArgType_maybe` (the single call site outside of `wantToUnboxArg` actually cared about the result type of a function, not an argument) and `splitResultType_maybe` (which is entirely superceded by `wantToUnboxResult`. - - - - - 0e541137 by Sebastian Graf at 2021-04-20T10:17:55+02:00 Worker/wrapper: Consistent names - - - - - fdbead70 by Sebastian Graf at 2021-04-20T14:55:16+02:00 Worker/wrapper: Refactor CPR WW to work for nested CPR (#18174) In another small step towards bringing a manageable variant of Nested CPR into GHC, this patch refactors worker/wrapper to be able to exploit Nested CPR signatures. See the new Note [Worker/wrapper for CPR]. The nested code path is currently not triggered, though, because all signatures that we annotate are still flat. So purely a refactoring. I am very confident that it works, because I ripped it off !1866 95% unchanged. A few test case outputs changed, but only it's auxiliary names only. I also added test cases for #18109 and #18401. There's a 2.6% metric increase in T13056 after a rebase, caused by an additional Simplifier run. It appears b1d0b9c saw a similar additional iteration. I think it's just a fluke. Metric Increase: T13056 - - - - - b7980b5d by Simon Peyton Jones at 2021-04-20T21:33:09-04:00 Fix occAnalApp In OccurAnal the function occAnalApp was failing to reset occ_encl to OccVanilla. This omission sometimes resulted in over-pessimistic occurrence information. I tripped over this when analysing eta-expansions. Compile times in perf/compiler fell slightly (no increases) PmSeriesG(normal) ghc/alloc 50738104.0 50580440.0 -0.3% PmSeriesS(normal) ghc/alloc 64045284.0 63739384.0 -0.5% PmSeriesT(normal) ghc/alloc 94430324.0 93800688.0 -0.7% PmSeriesV(normal) ghc/alloc 63051056.0 62758240.0 -0.5% T10547(normal) ghc/alloc 29322840.0 29307784.0 -0.1% T10858(normal) ghc/alloc 191988716.0 189801744.0 -1.1% T11195(normal) ghc/alloc 282654016.0 281839440.0 -0.3% T11276(normal) ghc/alloc 142994648.0 142338688.0 -0.5% T11303b(normal) ghc/alloc 46435532.0 46343376.0 -0.2% T11374(normal) ghc/alloc 256866536.0 255653056.0 -0.5% T11822(normal) ghc/alloc 140210356.0 138935296.0 -0.9% T12234(optasm) ghc/alloc 60753880.0 60720648.0 -0.1% T14052(ghci) ghc/alloc 2235105796.0 2230906584.0 -0.2% T17096(normal) ghc/alloc 297725396.0 296237112.0 -0.5% T17836(normal) ghc/alloc 1127785292.0 1125316160.0 -0.2% T17836b(normal) ghc/alloc 54761928.0 54637592.0 -0.2% T17977(normal) ghc/alloc 47529464.0 47397048.0 -0.3% T17977b(normal) ghc/alloc 42906972.0 42809824.0 -0.2% T18478(normal) ghc/alloc 777385708.0 774219280.0 -0.4% T18698a(normal) ghc/alloc 415097664.0 409009120.0 -1.5% GOOD T18698b(normal) ghc/alloc 500082104.0 493124016.0 -1.4% GOOD T18923(normal) ghc/alloc 72252364.0 72216016.0 -0.1% T1969(normal) ghc/alloc 811581860.0 804883136.0 -0.8% T5837(normal) ghc/alloc 37688048.0 37666288.0 -0.1% Nice! Metric Decrease: T18698a T18698b - - - - - 7f4d06e6 by Matthew Pickering at 2021-04-22T16:59:42-04:00 driver: Consider dyn_o files when checking recompilation in -c When -dynamic-too is enabled, there are two result files, .o and .dyn_o, therefore we should check both to decide whether to set SourceModified or not. The whole recompilation logic is very messy, a more thorough refactor would be beneficial in this area but this is the minimal patch to fix this more high priority problem. Fixes #17968 and hopefully #17534 - - - - - 4723652a by Fendor at 2021-04-22T17:00:19-04:00 Move 'nextWrapperNum' into 'DsM' and 'TcM' Previously existing in 'DynFlags', 'nextWrapperNum' is a global variable mapping a Module to a number for name generation for FFI calls. This is not the right location for 'nextWrapperNum', as 'DynFlags' should not contain just about any global variable. - - - - - 350f4f61 by Viktor Dukhovni at 2021-04-22T17:00:54-04:00 Support R_X86_64_TLSGD relocation on FreeBSD The FreeBSD C <ctype.h> header supports per-thread locales by exporting a static inline function that references the `_ThreadRuneLocale` thread-local variable. This means that object files that use e.g. isdigit(3) end up with TLSGD(19) relocations, and would not load into ghci or the language server. Here we add support for this type of relocation, for now just on FreeBSD, and only for external references to thread-specifics defined in already loaded dynamic modules (primarily libc.so). This is sufficient to resolve the <ctype.h> issues. Runtime linking of ".o" files which *define* new thread-specific variables would be noticeably more difficult, as this would likely require new rtld APIs. - - - - - aa685c50 by Viktor Dukhovni at 2021-04-22T17:00:55-04:00 Add background note in elf_tlsgd.c. Also some code cleanup, and a fix for an (extant unrelated) missing <pthread_np.h> include that should hopefully resolve a failure in the FreeBSD CI build, since it is best to make sure that this MR actually builds on FreeBSD systems other than mine. Some unexpected metric changes on FreeBSD (perhaps because CI had been failing for a while???): Metric Decrease: T3064 T5321Fun T5642 T9020 T12227 T13253-spj T15164 T18282 WWRec Metric Increase: haddock.compiler - - - - - 72b48c44 by Viktor Dukhovni at 2021-04-22T17:00:55-04:00 Block signals in the ticker thread This avoids surprises in the non-threaded runtime with blocked signals killing the process because they're only blocked in the main thread and not in the ticker thread. - - - - - 7bc7eea3 by Viktor Dukhovni at 2021-04-22T17:00:55-04:00 Make tests more portable on FreeBSD - - - - - 0015f019 by Adam Gundry at 2021-04-23T23:05:04+01:00 Rename references to Note [Trees That Grow] consistently [skip ci] I tend to find Notes by (case-sensitive) grep, and I spent a surprisingly long time looking for this Note, because it was referenced inconsistently with different cases, and without the module name. - - - - - d38397fa by Sebastian Graf at 2021-04-26T23:53:56-04:00 Parser: Unbox `ParseResult` Using `UnliftedNewtypes`, unboxed tuples and sums and a few pattern synonyms, we can make `ParseResult` completely allocation-free. Part of #19263. - - - - - 045e5f49 by Oleg Grenrus at 2021-04-26T23:54:34-04:00 Add Eq1 and Ord1 Fixed instances - - - - - 721ea018 by Ben Gamari at 2021-04-26T23:55:09-04:00 codeGen: Teach unboxed sum rep logic about levity Previously Unarise would happily project lifted and unlifted fields to lifted slots. This broke horribly in #19645, where a ByteArray# was passed in a lifted slot and consequently entered. The simplest way to fix this is what I've done here, distinguishing between lifted and unlifted slots in unarise. However, one can imagine more clever solutions, where we coerce the binder to the correct levity with respect to the sum's tag. I doubt that this would be worth the effort. Fixes #19645. - - - - - 9f9fab15 by Ben Gamari at 2021-04-26T23:55:09-04:00 testsuite: Add test for #19645 - - - - - 3339ed49 by Ben Gamari at 2021-04-26T23:55:44-04:00 users-guide: Document deprecation of -funfolding-keeness-factor See #15304. - - - - - 9d34f454 by Ben Gamari at 2021-04-26T23:55:44-04:00 users guide: Various other cleanups - - - - - 06654a6e by Matthew Pickering at 2021-04-26T23:56:18-04:00 Correct treatment of rexported modules in mkModuleNameProvidersMap Before we would get the incorrect error message saying that the rexporting package was the same as the defining package. I think this only affects error messages for now. ``` - it is bound as p-0.1.0.0:P2 by a reexport in package p-0.1.0.0 - it is bound as P by a reexport in package p-0.1.0.0 + it is bound as p-0.1.0.0:P2 by a reexport in package q-0.1.0.0 + it is bound as P by a reexport in package r-0.1.0.0 ``` and the output of `-ddump-mod-map` claimed.. ``` Moo moo-0.0.0.1 (hidden package, reexport by moo-0.0.0.1) ``` - - - - - 6c7fff0b by Simon Peyton Jones at 2021-04-26T23:56:53-04:00 Eliminate unsafeEqualityProof in CorePrep The main idea here is to avoid treating * case e of {} * case unsafeEqualityProof of UnsafeRefl co -> blah specially in CoreToStg. Instead, nail them in CorePrep, by converting case e of {} ==> e |> unsafe-co case unsafeEqualityProof of UnsafeRefl cv -> blah ==> blah[unsafe-co/cv] in GHC.Core.Prep. Now expressions that we want to treat as trivial really are trivial. We can get rid of cpExprIsTrivial. And we fix #19700. A downside is that, at least under unsafeEqualityProof, we substitute in types and coercions, which is more work. But a big advantage is that it's all very simple and principled: CorePrep really gets rid of the unsafeCoerce stuff, as it does empty case, runRW#, lazyId etc. I've updated the overview in GHC.Core.Prep, and added Note [Unsafe coercions] in GHC.Core.Prep Note [Implementing unsafeCoerce] in base:Unsafe.Coerce We get 3% fewer bytes allocated when compiling perf/compiler/T5631, which uses a lot of unsafeCoerces. (It's a happy-generated parser.) Metric Decrease: T5631 - - - - - b9e2491d by Rafal Gwozdzinski at 2021-04-26T23:57:29-04:00 Add GHC.Utils.Error.pprMessages - - - - - 72c1812f by Ben Gamari at 2021-04-26T23:58:16-04:00 rts/m32: Fix bounds check Previously we would check only that the *start* of the mapping was in the bottom 32-bits of address space. However, we need the *entire* mapping to be in low memory. Fix this. Noticed by @Phyx. - - - - - dd0a95a3 by Sasha Bogicevic at 2021-04-26T23:58:56-04:00 18000 Use GHC.IO.catchException in favor of Exception.catch fix #18000 - - - - - c1549069 by Adam Sandberg Ericsson at 2021-04-26T23:59:32-04:00 docs: add a short up-front description for -O, -n, -qn, -I and -Iw - - - - - d9ceb2fb by iori tsu at 2021-04-27T00:00:08-04:00 Add documentation for GHC.Exts.sortWith sortWith has the same type definition as `Data.List.sortOn` (eg: `Ord b => (a -> b) -> [a] -> [a]`). Nonetheless, they behave differently, sortOn being more efficient. This merge request add documentation to reflect on this differences - - - - - dd121fa1 by Ryan Scott at 2021-04-27T00:00:43-04:00 Pretty-print HsArgPar applications correctly (#19737) Previously, the `Outputable` instance for `HsArg` was being used to pretty-print each `HsArgPar` in a list of `HsArg`s individually, which simply doesn't work. In lieu of the `Outputable` instance, we now use a dedicated `pprHsArgsApp` function to print a list of `HsArg`s as a single unit. I have also added documentation to the `Outputable` instance for `HsArg` to more clearly signpost that it is only suitable for debug pretty-printing. Fixes #19737. - - - - - 484a8b2d by Ben Gamari at 2021-04-27T21:57:56-04:00 Introduce -ddump-verbose-inlinings Previously -ddump-inlinings and -dverbose-core2core used in conjunction would have the side-effect of dumping additional information about all inlinings considered by the simplifier. However, I have sometimes wanted this inlining information without the firehose of information produced by -dverbose-core2core. Introduce a new dump flag for this purpose. - - - - - 9ead1b35 by Daniel Rogozin at 2021-04-27T21:58:32-04:00 fix #19736 - - - - - d2399a46 by Sasha Bogicevic at 2021-04-27T21:59:08-04:00 19079 DerivingVia: incorrectly accepts deriving via types with differing runtime representations - - - - - 59cf287d by Sylvain Henry at 2021-04-29T17:26:43-04:00 Refactor divInt# to make it branchless (#18067, #19636) - - - - - 8d069477 by Sylvain Henry at 2021-04-29T17:26:43-04:00 Refactor modInt# to make it branchless - - - - - e50d0675 by Sylvain Henry at 2021-04-29T17:26:43-04:00 Allow divInt#/modInt# to inline (#18067) - - - - - c308c9af by Sylvain Henry at 2021-04-29T17:26:43-04:00 Make divModInt# branchless - - - - - 7bb3443a by Sylvain Henry at 2021-04-29T17:26:43-04:00 Fix inlining of division wrappers - - - - - 7d18e1ba by Alfredo Di Napoli at 2021-04-29T17:27:19-04:00 Add GhcMessage and ancillary types This commit adds GhcMessage and ancillary (PsMessage, TcRnMessage, ..) types. These types will be expanded to represent more errors generated by different subsystems within GHC. Right now, they are underused, but more will come in the glorious future. See https://gitlab.haskell.org/ghc/ghc/-/wikis/Errors-as-(structured)-values for a design overview. Along the way, lots of other things had to happen: * Adds Semigroup and Monoid instance for Bag * Fixes #19746 by parsing OPTIONS_GHC pragmas into Located Strings. See GHC.Parser.Header.toArgs (moved from GHC.Utils.Misc, where it didn't belong anyway). * Addresses (but does not completely fix) #19709, now reporting desugarer warnings and errors appropriately for TH splices. Not done: reporting type-checker warnings for TH splices. * Some small refactoring around Safe Haskell inference, in order to keep separate classes of messages separate. * Some small refactoring around initDsTc, in order to keep separate classes of messages separate. * Separate out the generation of messages (that is, the construction of the text block) from the wrapping of messages (that is, assigning a SrcSpan). This is more modular than the previous design, which mixed the two. Close #19746. This was a collaborative effort by Alfredo di Napoli and Richard Eisenberg, with a key assist on #19746 by Iavor Diatchki. Metric Increase: MultiLayerModules - - - - - 5981ac7d by Ryan Scott at 2021-04-29T17:27:54-04:00 Redesign withDict (formerly magicDict) This gives a more precise type signature to `magicDict` as proposed in #16646. In addition, this replaces the constant-folding rule for `magicDict` in `GHC.Core.Opt.ConstantFold` with a special case in the desugarer in `GHC.HsToCore.Expr.dsHsWrapped`. I have also renamed `magicDict` to `withDict` in light of the discussion in https://mail.haskell.org/pipermail/ghc-devs/2021-April/019833.html. All of this has the following benefits: * `withDict` is now more type safe than before. Moreover, if a user applies `withDict` at an incorrect type, the special-casing in `dsHsWrapped` will now throw an error message indicating what the user did incorrectly. * `withDict` can now work with classes that have multiple type arguments, such as `Typeable @k a`. This means that `Data.Typeable.Internal.withTypeable` can now be implemented in terms of `withDict`. * Since the special-casing for `withDict` no longer needs to match on the structure of the expression passed as an argument to `withDict`, it no longer cares about the presence or absence of `Tick`s. In effect, this obsoletes the fix for #19667. The new `T16646` test case demonstrates the new version of `withDict` in action, both in terms of `base` functions defined in terms of `withDict` as well as in terms of functions from the `reflection` and `singletons` libraries. The `T16646Fail` test case demonstrates the error message that GHC throws when `withDict` is applied incorrectly. This fixes #16646. By adding more tests for `withDict`, this also fixes #19673 as a side effect. - - - - - 51470000 by Ryan Scott at 2021-04-29T17:28:30-04:00 Expand synonyms in mkCastTy when necessary Doing so is important to maintain invariants (EQ3) and (EQ4) from `Note [Respecting definitional equality]` in `GHC.Core.TyCo.Rep`. For the details, see the new `Note [Using coreView in mk_cast_ty]`. Fixes #19742. - - - - - c2541c49 by Ryan Scott at 2021-04-29T17:29:05-04:00 Propagate free variables in extract_lctxt correctly This fixes an oversight in the implementation of `extract_lctxt` which was introduced in commit ce85cffc. Fixes #19759. - - - - - 1d03d8be by Sylvain Henry at 2021-04-29T17:29:44-04:00 Replace (ptext .. sLit) with `text` 1. `text` is as efficient as `ptext . sLit` thanks to the rewrite rules 2. `text` is visually nicer than `ptext . sLit` 3. `ptext . sLit` encourages using one `ptext` for several `sLit` as in: ptext $ case xy of ... -> sLit ... ... -> sLit ... which may allocate SDoc's TextBeside constructors at runtime instead of sharing them into CAFs. - - - - - 2d2985a7 by Adam Sandberg Ericsson at 2021-04-29T17:30:20-04:00 rts: export allocateWrite, freeWrite and markExec #19763 - - - - - c0c0b4e0 by Viktor Dukhovni at 2021-04-30T23:21:34-04:00 Tighten scope of non-POSIX visibility macros The __BSD_VISIBLE and _DARWIN_C_SOURCE macros expose non-POSIX prototypes in system header files. We should scope these to just the ".c" modules that actually need them, and avoid defining them in header files used in other C modules. - - - - - c7ca3619 by Sylvain Henry at 2021-04-30T23:22:13-04:00 Interpreter: replace DynFlags with EvalOpts/BCOOpts - - - - - 491266ee by Sylvain Henry at 2021-04-30T23:22:13-04:00 Make GHC.Runtime.Interpreter independent of GHC.Driver - - - - - 48c2c2af by Sylvain Henry at 2021-04-30T23:22:13-04:00 Fix genprimopcode warning - - - - - 6623790d by Sylvain Henry at 2021-04-30T23:22:13-04:00 Hadrian: build check-* with -Wall/-Werror Otherwise CI fails only with make build system. - - - - - 460afbe6 by Ryan Scott at 2021-04-30T23:22:48-04:00 Bring tcTyConScopedTyVars into scope in tcClassDecl2 It is possible that the type variables bound by a class header will map to something different in the typechecker in the presence of `StandaloneKindSignatures`. `tcClassDecl2` was not aware of this, however, leading to #19738. To fix it, in `tcTyClDecls` we map each class `TcTyCon` to its `tcTyConScopedTyVars` as a `ClassScopedTVEnv`. We then plumb that `ClassScopedTVEnv` to `tcClassDecl2` where it can be used. Fixes #19738. - - - - - e61d2d47 by Sylvain Henry at 2021-04-30T23:23:26-04:00 Make sized division primops ok-for-spec (#19026) - - - - - 1b9df111 by Harry Garrood harry at garrood.me at 2021-05-03T19:48:21-04:00 Add test case for #8144 Fixes #8144 - - - - - 4512ad2d by John Ericson at 2021-05-03T19:48:56-04:00 Use fix-sized bit-fiddling primops for fixed size boxed types Like !5572, this is switching over a portion of the primops which seems safe to use. - - - - - 8d6b2525 by Sylvain Henry at 2021-05-03T19:48:56-04:00 Move shift ops out of GHC.Base With a quick flavour I get: before T12545(normal) ghc/alloc 8628109152 after T12545(normal) ghc/alloc 8559741088 - - - - - 3a2f2475 by bit at 2021-05-03T19:49:32-04:00 Update documentation of 'Weak' - - - - - 4e546834 by Tamar Christina at 2021-05-03T19:50:10-04:00 pe: enable code unloading for Windows - - - - - 5126a07e by Philipp Dargel at 2021-05-03T19:50:46-04:00 Remove duplicate modules in GHCi %s prompt fixes #19757 - - - - - 0680e9a5 by Hécate Moonlight at 2021-05-03T19:51:22-04:00 Disable HLint colours closes #19776 - - - - - 7f5ee719 by iori tsu at 2021-05-03T19:51:58-04:00 visually align expected and actual modules name before: > /home/matt/Projects/persistent/persistent/Database/Persist/ImplicitIdDef.hs:1:8: error: > File name does not match module name: > Saw: ‘A.B.Module’ > Expected: ‘A.B.Motule’ > | > 1 | module A.B.Motule > | ^^^^^^^^^^> after: > /home/matt/Projects/persistent/persistent/Database/Persist/ImplicitIdDef.hs:1:8: error: > File name does not match module name: > Saw: ‘A.B.Module’ > Expected: ‘A.B.Motule’ > | > 1 | module A.B.Motule > | ^^^^^^^^^^> - - - - - 24a9b170 by sheaf at 2021-05-03T19:52:34-04:00 Improve hs-boot binds error (#19781) - - - - - 39020600 by Roland Senn at 2021-05-04T16:00:13-04:00 Tweak function `quantifyType` to fix #12449 In function `compiler/GHC/Runtime/Heap/Inspect.hs:quantifyType` replace `tcSplitForAllInvisTyVars` by `tcSplitNestedSigmaTys`. This will properly split off the nested foralls in examples like `:print fmap`. Do not remove the `forall`s from the `snd` part of the tuple returned by `quantifyType`. It's not necessary and the reason for the bug in #12449. Some code simplifications at the calling sites of `quantifyTypes`. - - - - - 6acadb79 by Simon Peyton Jones at 2021-05-04T16:00:48-04:00 Persist CorePrepProv into IfaceUnivCoProv CorePrepProv is only created in CorePrep, so I thought it wouldn't be needed in IfaceUnivCoProv. But actually IfaceSyn is used during pretty-printing, and we can certainly pretty-print things after CorePrep as #19768 showed. So the simplest thing is to represent CorePrepProv in IfaceSyn. To improve what Lint can do I also added a boolean to CorePrepProv, to record whether it is homogeneously kinded or not. It is introduced in two distinct ways (see Note [Unsafe coercions] in GHC.CoreToStg.Prep), one of which may be hetero-kinded (e.g. Int ~ Int#) beause it is casting a divergent expression; but the other is not. The boolean keeps track. - - - - - 7ffbdc3f by Ben Gamari at 2021-05-05T05:42:38-04:00 Break up aclocal.m4 - - - - - 34452fbd by Ben Gamari at 2021-05-05T05:42:38-04:00 configure: Move pthreads checks to macro - - - - - 0de2012c by Ben Gamari at 2021-05-05T05:42:38-04:00 configure: Move libnuma check to macro - - - - - 958c6fbd by Ben Gamari at 2021-05-05T05:42:38-04:00 configure: Move libdw search logic to macro - - - - - 101d25fc by Alfredo Di Napoli at 2021-05-05T05:43:14-04:00 Add some DriverMessage type constructors This commit expands the DriverMessage type with new type constructors, making the number of diagnostics GHC can emit richer. In particular: * Add DriverMissingHomeModules message * Add DriverUnusedPackage message * Add DriverUnnecessarySourceImports message This commit adds the `DriverUnnecessarySourceImports` message and fixes a small bug in its reporting: inside `warnUnnecessarySourceImports` we were checking for `Opt_WarnUnusedSourceImports` to be set, but we were emitting the diagnostic with `WarningWithoutFlag`. This also adjusts the T10637 test to reflect that. * Add DriverDuplicatedModuleDeclaration message * Add DriverModuleNotFound message * Add DriverFileModuleNameMismatch message * Add DriverUnexpectedSignature message * Add DriverFileNotFound message * Add DriverStaticPointersNotSupported message * Add DriverBackpackModuleNotFound message - - - - - e9617fba by Matthew Pickering at 2021-05-05T05:43:49-04:00 test driver: Make sure RESIDENCY_OPTS is passed for 'all' perf tests Fixes #19731 ------------------------- Metric Decrease: T11545 Metric Increase: T12545 T15304 ------------------------- - - - - - f464e477 by Jaro Reinders at 2021-05-05T05:44:26-04:00 More specific error messages for annotations (fixes #19740) - - - - - 3280eb22 by Luite Stegeman at 2021-05-05T05:45:03-04:00 support LiftedRep and UnliftedRep in GHCi FFI fixes #19733 - - - - - 049c3a83 by Hécate Moonlight at 2021-05-05T05:45:39-04:00 Add an .editorconfig file closes #19793 - - - - - a5e9e5b6 by Ben Gamari at 2021-05-06T02:30:18-04:00 Re-introduce Note [keepAlive# magic] Somewhere in the course of forward- and back-porting the keepAlive# branch the Note which described the mechanism was dropped. Reintroduce it. Closes #19712. - - - - - c4f4193a by John Ericson at 2021-05-06T02:30:54-04:00 Use fix-sized arithmetic primops for fixed size boxed types We think the compiler is ready, so we can do this for all over the 8-, 16-, and 32-bit boxed types. We are holding off on doing all the primops at once so things are easier to investigate. Metric Decrease: T12545 - - - - - 418295ea by Sasha Bogicevic at 2021-05-06T02:31:31-04:00 19486 Nearly all uses of `uniqCompareFS` are dubious and lack a non-determinism justification - - - - - 1635d5c2 by Alan Zimmerman at 2021-05-06T02:32:06-04:00 EPA: properly capture semicolons between Matches in a FunBind For the source module MatchSemis where { a 0 = 1; a _ = 2; } Make sure that the AddSemiAnn entries for the two trailing semicolons are attached to the component Match elements. Closes #19784 - - - - - e5778365 by PHO at 2021-05-06T02:32:44-04:00 rts/posix/GetTime.c: Use Solaris-specific gethrvtime(3) on OpenSolaris derivatives The constant CLOCK_THREAD_CPUTIME_ID is defined in a system header but it isn't acutally usable. clock_gettime(2) always returns EINVAL. - - - - - 87d8c008 by Ben Gamari at 2021-05-06T12:44:06-04:00 Bump binary submodule Fixes #19631. - - - - - 0281dae8 by Aaron Allen at 2021-05-06T12:44:43-04:00 Disallow -XDerivingVia when -XSafe is on (#19786) Since `GeneralizedNewtypeDeriving` is considered unsafe, `DerivingVia` should be as well. - - - - - 30f6923a by Ben Gamari at 2021-05-06T12:45:19-04:00 hadrian: Don't depend upon bash from PATH Previously Hadrian depended implicitly upon whatever `bash` it found in `PATH`, offerring no way for the user to override. Fix this by detecting `sh` in `configure` and passing the result to Hadrian. Fixes #19797. - - - - - c5454dc7 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [ci] Add support for building on aarch64-darwin This will fail for now. But allows us to add aarch64-darwin machines to CI. (cherry picked from commit a7d22795ed118abfe64f4fc55d96d8561007ce1e) - - - - - 41b0c288 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [testlib/driver] denoise this prevents the testlib/driver to be overly noisy, and will also kill some noise produiced by the aarch64-darwin cc (for now). Fixing sysctl, will allow us to run the test's properly in a nix-shell on aarch64-darwin (cherry picked from commit 5109e87e13ab45d799db2013535f54ca35f1f4dc) - - - - - bb78df78 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [ci] default value for CONFIGURE_ARGS (cherry picked from commit 307d34945b7d932156e533736c91097493e6181b) - - - - - 5f5b02c2 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [ci] Default value for MAKE_ARGS We don't pass MAKE_ARGS for windows builds, so this should unbreak them. (cherry picked from commit 16c13d5acfdc8053f7de9e908cc9d845e9bd34bb) - - - - - 79019dd6 by Moritz Angermann at 2021-05-07T09:17:23+08:00 [testsuite/darwin] fix conc059 This resolves the following: Compile failed (exit code 1) errors were: conc059_c.c:27:5: error: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration] exit(0); ^ conc059_c.c:27:5: error: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit' (cherry picked from commit 5a6c36ecb41fccc07c1b01fe0f330cd38c2a0c76) - - - - - 8a36ebfa by Moritz Angermann at 2021-05-07T09:17:23+08:00 [Aarch64] No div-by-zero; disable test. (cherry picked from commit 3592d1104c47b006fd9f4127d93916f477a6e010) - - - - - 10b5dc88 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [Darwin] mark stdc++ tests as broken There is no libstdc++, only libc++ (cherry picked from commit 57671071adeaf0b45e86bb0ee050e007e3b161fb) - - - - - 035f4bb1 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [testsuite] filter out superfluous dylib warnings (cherry picked from commit 33c4d497545559a38bd8d1caf6c94e5e2a77647b) - - - - - 3f09c6f8 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [ci/nix-shell] Add Foundation and Security (cherry picked from commit 4bea83afec009dfd3c6313cac4610d00ba1f9a3d) - - - - - 65440597 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [testsuite/json2] Fix failure with LLVM backends -Wno-unsupported-llvm-version should suppress the LLVM version missmatch warning that messes up the output. (cherry picked from commit 63455300625fc12b2aafc3e339eb307510a6e8bd) - - - - - 582fc583 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [ci/nix-shell] [Darwin] Stop the ld warnings about libiconv. (cherry picked from commit c3944bc89d062a4850946904133c7a1464d59012) - - - - - 7df44e43 by Moritz Angermann at 2021-05-07T09:19:48+08:00 [testsuite] static001 is not broken anymore. (cherry picked from commit b821fcc7142edff69aa4c47dc1a5bd30b13c1ceb) - - - - - 49839322 by Moritz Angermann at 2021-05-07T09:19:48+08:00 [testsuite/arm64] fix section_alignment (cherry picked from commit f7062e1b0c91e8aa78e245a3dab9571206fce16d) - - - - - ccea6117 by Moritz Angermann at 2021-05-07T09:19:48+08:00 [ci/nix-shell] uniquify NIX_LDFLAGS{_FOR_TARGET} (cherry picked from commit 07b1af0362beaaf221cbee7b17bbe0a5606fd87d) - - - - - cceb461a by Moritz Angermann at 2021-05-07T09:19:48+08:00 [darwin] stop the DYLD_LIBRARY_PATH madness this causes *significant* slowdown on macOS as the linker ends up looking through all the paths. Slowdown can be as bad as 100% or more. (cherry picked from commit 820b0766984d42c06c977a6c32da75c429106f7f) - - - - - a664a2ad by Moritz Angermann at 2021-05-07T09:19:48+08:00 [ci] Default values for CI_COMMIT_BRANCH, CI_PROJECT_PATH - - - - - 8e0f48bd by Simon Peyton Jones at 2021-05-07T09:43:57-04:00 Allow visible type application for levity-poly data cons This patch was driven by #18481, to allow visible type application for levity-polymorphic newtypes. As so often, it started simple but grew: * Significant refactor: I removed HsConLikeOut from the client-independent Language.Haskell.Syntax.Expr, and put it where it belongs, as a new constructor `ConLikeTc` in the GHC-specific extension data type for expressions, `GHC.Hs.Expr.XXExprGhcTc`. That changed touched a lot of files in a very superficial way. * Note [Typechecking data constructors] explains the main payload. The eta-expansion part is no longer done by the typechecker, but instead deferred to the desugarer, via `ConLikeTc` * A little side benefit is that I was able to restore VTA for data types with a "stupid theta": #19775. Not very important, but the code in GHC.Tc.Gen.Head.tcInferDataCon is is much, much more elegant now. * I had to refactor the levity-polymorphism checking code in GHC.HsToCore.Expr, see Note [Checking for levity-polymorphic functions] Note [Checking levity-polymorphic data constructors] - - - - - 740103c5 by PHO at 2021-05-07T20:06:43-04:00 rts/posix/OSThreads.c: Implement getNumberOfProcessors() for NetBSD - - - - - 39be3283 by PHO at 2021-05-07T20:06:43-04:00 rts: Correctly call pthread_setname_np() on NetBSD NetBSD supports pthread_setname_np() but it expects a printf-style format string and a string argument. Also use pthread for itimer on this platform. - - - - - a32eb0f3 by Simon Peyton Jones at 2021-05-07T20:07:19-04:00 Fix newtype eta-reduction The eta-reduction we do for newype axioms was generating an inhomogeneous axiom: see #19739. This patch fixes it in a simple way; see GHC.Tc.TyCl.Build Note [Newtype eta and homogeneous axioms] - - - - - ad5a3aeb by Alan Zimmerman at 2021-05-08T11:19:26+01:00 EPA: update some comments in Annotations. Follow-up from !2418, see #19579 - - - - - 736d47ff by Alan Zimmerman at 2021-05-09T18:13:40-04:00 EPA: properly capture leading semicolons in statement lists For the fragment blah = do { ; print "a" ; print "b" } capture the leading semicolon before 'print "a"' in 'al_rest' in AnnList instead of in 'al_trailing'. Closes #19798 - - - - - c4a85e3b by Andreas Klebinger at 2021-05-11T05:34:52-04:00 Expand Note [Data con representation]. Not perfect. But I consider this to be a documentation fix for #19789. - - - - - 087ac4eb by Simon Peyton Jones at 2021-05-11T05:35:27-04:00 Minor refactoring in WorkWrap This patch just does the tidying up from #19805. No change in behaviour. - - - - - 32367cac by Alan Zimmerman at 2021-05-11T05:36:02-04:00 EPA: Use custom AnnsIf structure for HsIf and HsCmdIf This clearly identifies the presence and location of optional semicolons in an if statement. Closes #19813 - - - - - 09918343 by Andreas Klebinger at 2021-05-11T16:58:38-04:00 Don't warn about ClassOp bindings not specialising. Fixes #19586 - - - - - 5daf1aa9 by Andreas Klebinger at 2021-05-11T16:59:17-04:00 Document unfolding treatment of simplLamBndr. Fixes #19817 - - - - - c7717949 by Simon Peyton Jones at 2021-05-11T23:00:27-04:00 Fix strictness and arity info in SpecConstr In GHC.Core.Opt.SpecConstr.spec_one we were giving join-points an incorrect join-arity -- this was fallout from commit c71b220491a6ae46924cc5011b80182bcc773a58 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu Apr 8 23:36:24 2021 +0100 Improvements in SpecConstr * Allow under-saturated calls to specialise See Note [SpecConstr call patterns] This just allows a bit more specialisation to take place. and showed up in #19780. I refactored the code to make the new function calcSpecInfo which treats join points separately. In doing this I discovered two other small bugs: * In the Var case of argToPat we were treating UnkOcc as uninteresting, but (by omission) NoOcc as interesting. As a result we were generating SpecConstr specialisations for functions with unused arguments. But the absence anlyser does that much better; doing it here just generates more code. Easily fixed. * The lifted/unlifted test in GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs was back to front (#19794). Easily fixed. * In the same function, mkWorkerArgs, we were adding an extra argument nullary join points, which isn't necessary. I added a test for this. That in turn meant I had to remove an ASSERT in CoreToStg.mkStgRhs for nullary join points, which was always bogus but now trips; I added a comment to explain. - - - - - c3868451 by Alan Zimmerman at 2021-05-11T23:01:03-04:00 EPA: record annotations for braces in LetStmt Closes #19814 - - - - - 6967088d by Ben Gamari at 2021-05-11T23:01:38-04:00 base: Update Unicode data to 13.0.0 (cherry picked from commit d22e087f7bf74341c4468f11b4eb0273033ca931) - - - - - 673ff667 by Matthew Pickering at 2021-05-11T23:02:14-04:00 hadrian: Don't always links against libffi The RTS flag `ffi` is set to either True or False depending on whether we want to link against `libffi`, therefore in order to work out whether to add the build tree to the arguments we check whether `ffi` is in the extraLibs or not before adding the argument. Fixes #16022 - - - - - d22e8d89 by Matthew Pickering at 2021-05-11T23:02:50-04:00 rts: Remove trailing whitespace from Adjustor.c - - - - - f0b73ddd by Sylvain Henry at 2021-05-11T23:03:28-04:00 Hadrian: add comment to avoid surprises - - - - - 55223780 by Andreas Klebinger at 2021-05-12T14:49:23-04:00 W/W: Always zap useless idInfos. tryWW used to always returns an Id with a zapped: * DmdEnv * Used Once info except in the case where the ID was guaranteed to be inlined. We now also zap the info in that case. Fixes #19818. - - - - - 541665b7 by Matthew Pickering at 2021-05-12T14:49:58-04:00 hadrian: Fix dynamic+debug flag combination for check-ppr executable - - - - - a7473e03 by Peter Trommler at 2021-05-12T14:50:33-04:00 Hadrian: Enable SMP on powerpc64{le} Fixes #19825 - - - - - f78c25da by Sylvain Henry at 2021-05-12T21:41:43-04:00 Move GlobalVar macros into GHC.Utils.GlobalVars That's the only place where they are used and they shouldn't be used elsewhere. - - - - - da56ed41 by Sylvain Henry at 2021-05-12T21:41:43-04:00 Ensure assert from Control.Exception isn't used - - - - - bfabf94f by Sylvain Henry at 2021-05-12T21:41:43-04:00 Replace CPP assertions with Haskell functions There is no reason to use CPP. __LINE__ and __FILE__ macros are now better replaced with GHC's CallStack. As a bonus, assert error messages now contain more information (function name, column). Here is the mapping table (HasCallStack omitted): * ASSERT: assert :: Bool -> a -> a * MASSERT: massert :: Bool -> m () * ASSERTM: assertM :: m Bool -> m () * ASSERT2: assertPpr :: Bool -> SDoc -> a -> a * MASSERT2: massertPpr :: Bool -> SDoc -> m () * ASSERTM2: assertPprM :: m Bool -> SDoc -> m () - - - - - 0ef11907 by Sylvain Henry at 2021-05-12T21:41:44-04:00 Fully remove HsVersions.h Replace uses of WARN macro with calls to: warnPprTrace :: Bool -> SDoc -> a -> a Remove the now unused HsVersions.h Bump haddock submodule - - - - - 67a5a91e by Sylvain Henry at 2021-05-12T21:41:44-04:00 Remove useless {-# LANGUAGE CPP #-} pragmas - - - - - c34f4c0c by Alan Zimmerman at 2021-05-12T21:42:21-04:00 EPA: Fix incorrect SrcSpan for FamDecl The SrcSpan for a type family declaration did not include the family equations. Closes #19821 - - - - - e0ded198 by Matthew Pickering at 2021-05-12T21:42:57-04:00 ci: Fix unbound CI_MERGE_REQUEST_SOURCE_BRANCH_NAME variable Fixes #19831 - - - - - c6de5805 by John Ericson at 2021-05-13T16:44:23-04:00 Use fix-sized order primops for fixed size boxed types Progress towards #19026 - - - - - fc9546ca by Sylvain Henry at 2021-05-13T16:45:03-04:00 genprimopcode: fix bootstrap errors * Fix for unqualified Data.List import * Fix monad instance - - - - - 60f088b3 by Matthew Pickering at 2021-05-19T09:10:16+01:00 CI: Disable darwin builds They are taking over 4 hours to complete which is stalling the rest of the merge pipeline. - - - - - baa969c3 by Koz Ross at 2021-05-19T23:31:51-04:00 Implement bitwise infix ops - - - - - c8564c63 by Alfredo Di Napoli at 2021-05-19T23:32:27-04:00 Add some TcRn diagnostic messages This commit converts some TcRn diagnostic into proper structured errors. Ported by this commit: * Add TcRnImplicitLift This commit adds the TcRnImplicitLift diagnostic message and a prototype API to be able to log messages which requires additional err info. * Add TcRnUnusedPatternBinds * Add TcRnDodgyExports * Add TcRnDodgyImports message * Add TcRnMissingImportList - - - - - 38faeea1 by Matthew Pickering at 2021-05-19T23:33:02-04:00 Remove transitive information about modules and packages from interface files This commit modifies interface files so that *only* direct information about modules and packages is stored in the interface file. * Only direct module and direct package dependencies are stored in the interface files. * Trusted packages are now stored separately as they need to be checked transitively. * hs-boot files below the compiled module in the home module are stored so that eps_is_boot can be calculated in one-shot mode without loading all interface files in the home package. * The transitive closure of signatures is stored separately This is important for two reasons * Less recompilation is needed, as motivated by #16885, a lot of redundant compilation was triggered when adding new imports deep in the module tree as all the parent interface files had to be redundantly updated. * Checking an interface file is cheaper because you don't have to perform a transitive traversal to check the dependencies are up-to-date. In the code, places where we would have used the transitive closure, we instead compute the necessary transitive closure. The closure is not computed very often, was already happening in checkDependencies, and was already happening in getLinkDeps. Fixes #16885 ------------------------- Metric Decrease: MultiLayerModules T13701 T13719 ------------------------- - - - - - 29d104c6 by nineonine at 2021-05-19T23:33:40-04:00 Implement :info for record pattern synonyms (#19462) - - - - - d45e3cda by Matthew Pickering at 2021-05-19T23:34:15-04:00 hadrian: Make copyFileLinked a bit more robust Previously it only worked if the two files you were trying to symlink were already in the same directory. - - - - - 176b1305 by Matthew Pickering at 2021-05-19T23:34:15-04:00 hadrian: Build check-ppr and check-exact using normal hadrian rules when in-tree Fixes #19606 #19607 - - - - - 3c04e7ac by Andreas Klebinger at 2021-05-19T23:34:49-04:00 Fix LitRubbish being applied to values. This fixes #19824 - - - - - 32725617 by Matthew Pickering at 2021-05-19T23:35:24-04:00 Tidy: Ignore rules (more) when -fomit-interface-pragmas is on Before this commit, the RHS of a rule would expose additional definitions, despite the fact that the rule wouldn't get exposed so it wouldn't be possible to ever use these definitions. The net-result is slightly less recompilation when specialisation introduces rules. Related to #19836 - - - - - 10ae305e by Alan Zimmerman at 2021-05-19T23:35:59-04:00 EPA: Remove duplicate annotations from HsDataDefn They are repeated in the surrounding DataDecl and FamEqn. Updates haddock submodule Closes #19834 - - - - - 8e7f02ea by Richard Eisenberg at 2021-05-19T23:36:35-04:00 Point posters to ghc-proposals - - - - - 6844ead4 by Matthew Pickering at 2021-05-19T23:37:09-04:00 testsuite: Don't copy .hi-boot and .o-boot files into temp dir - - - - - e87b8e10 by Sebastian Graf at 2021-05-19T23:37:44-04:00 CPR: Detect constructed products in `runRW#` apps (#19822) In #19822, we realised that the Simplifier's new habit of floating cases into `runRW#` continuations inhibits CPR analysis from giving key functions of `text` the CPR property, such as `singleton`. This patch fixes that by anticipating part of !5667 (Nested CPR) to give `runRW#` the proper CPR transformer it now deserves: Namely, `runRW# (\s -> e)` should have the CPR property iff `e` has it. The details are in `Note [Simplification of runRW#]` in GHC.CoreToStg.Prep. The output of T18086 changed a bit: `panic` (which calls `runRW#`) now has `botCpr`. As outlined in Note [Bottom CPR iff Dead-Ending Divergence], that's OK. Fixes #19822. Metric Decrease: T9872d - - - - - d3ef2dc2 by Baldur Blöndal at 2021-05-19T23:38:20-04:00 Add pattern TypeRep (#19691), exported by Type.Reflection. - - - - - f192e623 by Sylvain Henry at 2021-05-19T23:38:58-04:00 Cmm: fix sinking after suspendThread Suppose a safe call: myCall(x,y,z) It is lowered into three unsafe calls in Cmm: r = suspendThread(...); myCall(x,y,z); resumeThread(r); Consider the following situation for myCall arguments: x = Sp[..] -- stack y = Hp[..] -- heap z = R1 -- global register r = suspendThread(...); myCall(x,y,z); resumeThread(r); The sink pass assumes that unsafe calls clobber memory (heap and stack), hence x and y assignments are not sunk after `suspendThread`. The sink pass also correctly handles global register clobbering for all unsafe calls, except `suspendThread`! `suspendThread` is special because it releases the capability the thread is running on. Hence the sink pass must also take into account global registers that are mapped into memory (in the capability). In the example above, we could get: r = suspendThread(...); z = R1 myCall(x,y,z); resumeThread(r); But this transformation isn't valid if R1 is (BaseReg->rR1) as BaseReg is invalid between suspendThread and resumeThread. This caused argument corruption at least with the C backend ("unregisterised") in #19237. Fix #19237 - - - - - df4a0a53 by Sylvain Henry at 2021-05-19T23:39:37-04:00 Bignum: bump to version 1.1 (#19846) - - - - - d48b7e5c by Shayne Fletcher at 2021-05-19T23:40:12-04:00 Changes to HsRecField' - - - - - 441fdd6c by Adam Sandberg Ericsson at 2021-05-19T23:40:47-04:00 driver: check if clang is the assembler when passing clang specific arguments (#19827) Previously we assumed that the assembler was the same as the c compiler, but we allow setting them to different programs with -pgmc and -pgma. - - - - - 6a577cf0 by Peter Trommler at 2021-05-19T23:41:22-04:00 PPC NCG: Fix unsigned compare with 16-bit constants Fixes #19852 and #19609 - - - - - c4099b09 by Matthew Pickering at 2021-05-19T23:41:57-04:00 Make setBndrsDemandInfo work with only type variables Fixes #19849 Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - 4b5de954 by Matthew Pickering at 2021-05-19T23:42:32-04:00 constant folding: Make shiftRule for Word8/16/32# types return correct type Fixes #19851 - - - - - 82b097b3 by Sylvain Henry at 2021-05-19T23:43:09-04:00 Remove wired-in names hs-boot check bypass (#19855) The check bypass is no longer necessary and the check would have avoided #19638. - - - - - 939a56e7 by Baldur Blöndal at 2021-05-19T23:43:46-04:00 Added new regresion test for #18036 from ticket #19865. - - - - - 43139064 by Ben Gamari at 2021-05-20T11:36:55-04:00 gitlab-ci: Add Alpine job linking against gmp integer backend As requested by Michael Snoyman. - - - - - 7c066734 by Roland Senn at 2021-05-20T11:37:32-04:00 Use pprSigmaType to print GHCi debugger Suspension Terms (Fix #19355) In the GHCi debugger use the function `pprSigmaType` to print out Suspension Terms. The function `pprSigmaType` respect the flag `-f(no-)print-explicit-foralls` and so it fixes #19355. Switch back output of existing tests to default mode (no explicit foralls). - - - - - aac87bd3 by Alfredo Di Napoli at 2021-05-20T18:08:37-04:00 Extensible Hints for diagnostic messages This commit extends the GHC diagnostic hierarchy with a `GhcHint` type, modelling helpful suggestions emitted by GHC which can be used to deal with a particular warning or error. As a direct consequence of this, the `Diagnostic` typeclass has been extended with a `diagnosticHints` method, which returns a `[GhcHint]`. This means that now we can clearly separate out the printing of the diagnostic message with the suggested fixes. This is done by extending the `printMessages` function in `GHC.Driver.Errors`. On top of that, the old `PsHint` type has been superseded by the new `GhcHint` type, which de-duplicates some hints in favour of a general `SuggestExtension` constructor that takes a `GHC.LanguageExtensions.Extension`. - - - - - 649d63db by Divam at 2021-05-20T18:09:13-04:00 Add tests for code generation options specified via OPTIONS_GHC in multi module compilation - - - - - 5dcb8619 by Matthías Páll Gissurarson at 2021-05-20T18:09:50-04:00 Add exports to GHC.Tc.Errors.Hole (fixes #19864) - - - - - 703c0c3c by Sylvain Henry at 2021-05-20T18:10:31-04:00 Bump libffi submodule to libffi-3.3 (#16940) - - - - - d9eb8bbf by Jakob Brünker at 2021-05-21T06:22:47-04:00 Only suggest names that make sense (#19843) * Don't show suggestions for similar variables when a data constructor in a pattern is not in scope. * Only suggest record fields when a record field for record creation or updating is not in scope. * Suggest similar record fields when a record field is not in scope with -XOverloadedRecordDot. * Show suggestions for data constructors if a type constructor or type is not in scope, but only if -XDataKinds is enabled. Fixes #19843. - - - - - ec10cc97 by Matthew Pickering at 2021-05-21T06:23:26-04:00 hadrian: Reduce verbosity on failed testsuite run When the testsuite failed before it would print a big exception which gave you the very long command line which was used to invoke the testsuite. By capturing the exit code and rethrowing the exception, the error is must less verbose: ``` Error when running Shake build system: at want, called at src/Main.hs:104:30 in main:Main * Depends on: test * Raised the exception: user error (tests failed) ``` - - - - - f5f74167 by Matthew Pickering at 2021-05-21T06:24:02-04:00 Only run armv7-linux-deb10 build nightly - - - - - 6eed426b by Sylvain Henry at 2021-05-21T06:24:44-04:00 SysTools: make file copy more efficient - - - - - 0da85d41 by Alan Zimmerman at 2021-05-21T15:05:44-04:00 EPA: Fix explicit specificity and unicode linear arrow annotations Closes #19839 Closes #19840 - - - - - 5ab174e4 by Alan Zimmerman at 2021-05-21T15:06:20-04:00 Remove Maybe from Context in HsQualTy Updates haddock submodule Closes #19845 - - - - - b4d240d3 by Matthew Pickering at 2021-05-22T00:07:42-04:00 hadrian: Reorganise modules so KV parser can be used to define transformers - - - - - 8c871c07 by Matthew Pickering at 2021-05-22T00:07:42-04:00 hadrian: Add omit_pragmas transformer This transformer builds stage2 GHC with -fomit-interface-pragmas which can greatly reduce the amount of rebuilding but still allows most the tests to pass. - - - - - c6806912 by Matthew Pickering at 2021-05-22T00:08:18-04:00 Remove ANN pragmas in check-ppr and check-exact This fixes the `devel2+werror` build combo as stage1 does not have TH enabled. ``` utils/check-exact/Preprocess.hs:51:1: error: [-Werror] Ignoring ANN annotations, because this is a stage-1 compiler without -fexternal-interpreter or doesn't support GHCi | 51 | {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` - - - - - e2d4f241 by PHO at 2021-05-22T00:08:55-04:00 Support NetBSD/aarch64 via LLVM codegen Only adding "aarch64-unknown-netbsd" to gen-data-layout.sh was sufficient to get it working. No other changes were strictly required. - - - - - ef4d2999 by nineonine at 2021-05-22T00:09:32-04:00 Add regression test for #19287 - - - - - 0b1eed74 by Shayne Fletcher at 2021-05-23T08:02:58+10:00 Change representation of field selector occurences - Change the names of the fields in in `data FieldOcc` - Renames `HsRecFld` to `HsRecSel` - Replace `AmbiguousFieldOcc p` in `HsRecSel` with `FieldOcc p` - Contains a haddock submodule update The primary motivation of this change is to remove `AmbiguousFieldOcc`. This is one of a suite of changes improving how record syntax (most notably record update syntax) is represented in the AST. - - - - - 406cd90b by Alan Zimmerman at 2021-05-23T02:07:36-04:00 EPA: AnnAt missing for type application in patterns Ensure that the exact print annotations accurately record the `@` for code like tyApp :: Con k a -> Proxy a tyApp (Con @kx @ax (x :: Proxy ax)) = x :: Proxy (ax :: kx) Closes #19850 - - - - - 82c6a939 by Vladislav Zavialov at 2021-05-23T18:53:13-04:00 Pre-add test case for #19156 - - - - - d82d3823 by Vladislav Zavialov at 2021-05-23T18:53:13-04:00 Introduce Strict.Maybe, Strict.Pair (#19156) This patch fixes a space leak related to the use of Maybe in RealSrcSpan by introducing a strict variant of Maybe. In addition to that, it also introduces a strict pair and uses the newly introduced strict data types in a few other places (e.g. the lexer/parser state) to reduce allocations. Includes a regression test. - - - - - f8c6fce4 by Vladislav Zavialov at 2021-05-23T18:53:50-04:00 HsToken for HsPar, ParPat, HsCmdPar (#19523) This patch is a first step towards a simpler design for exact printing. - - - - - fc23ae89 by nineonine at 2021-05-24T00:14:53-04:00 Add regression test for #9985 - - - - - 3e4ef4b2 by Sylvain Henry at 2021-05-24T00:15:33-04:00 Move warning flag handling into Flags module I need this to make the Logger independent of DynFlags. Also fix copy-paste errors: Opt_WarnNonCanonicalMonadInstances was associated to "noncanonical-monadfail-instances" (MonadFailInstances vs MonadInstances). In the process I've also made the default name for each flag more explicit. - - - - - 098c7794 by Matthew Pickering at 2021-05-24T09:47:52-04:00 check-{ppr/exact}: Rewrite more directly to just parse files There was quite a large amount of indirection in these tests, so I have rewritten them to just directly parse the files rather than making a module graph and entering other twisty packages. - - - - - a3665a7a by Matthew Pickering at 2021-05-24T09:48:27-04:00 docs: Fix example in toIntegralSized Thanks to Mathnerd3141 for the fixed example. Fixes #19880 - - - - - f243acf4 by Divam at 2021-05-25T05:50:51-04:00 Refactor driver code; de-duplicate and split APIs (#14095, !5555) This commit does some de-duplication of logic between the one-shot and --make modes, and splitting of some of the APIs so that its easier to do the fine-grained parallelism implementation. This is the first part of the implementation plan as described in #14095 * compileOne now uses the runPhase pipeline for most of the work. The Interpreter backend handling has been moved to the runPhase. * hscIncrementalCompile has been broken down into multiple APIs. * haddock submodule bump: Rename of variables in html-test ref: This is caused by a change in ModDetails in case of NoBackend. Now the initModDetails is used to recreate the ModDetails from interface and in-memory ModDetails is not used. - - - - - 6ce8e687 by Zubin Duggal at 2021-05-25T05:51:26-04:00 Make tcIfaceCompleteMatch lazier. Insufficient lazyness causes a loop while typechecking COMPLETE pragmas from interfaces (#19744). - - - - - 8f22af8c by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci] darwin uses hadrian Make is bad, and really slow, and we should just stop using it outright, or kill hadrian. Let's rather go for hadrian all the way and phase out make. - - - - - 4d100f68 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci] no more brew or pip We pull dependencies (reliably) via nix, and open up nix where needed. - - - - - c67c9e82 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [bindist] inject xattr -c -r . into the darwin install phase This is so awful, but at least it might get the job done. - - - - - 544414ba by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci/darwin] use system provided iconv and curses Also make sure to be able to build with non-apple-clang, while using apple's SDK on macOS - - - - - 527543fc by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci/darwin] cabal-cache dir can be specified per arch Also while we are at it, run shellcheck on ci.sh - - - - - 7b1eeabf by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci/darwin] set SH to /bin/bash This should prevent some other `bash` to leak into the binary distributions. - - - - - f101e019 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [hadrian] Do not add full tool paths This prohuibits CC=clang to work generically and will always bake in the clang that is found on the build machine in PATH, what ever clang that might be. It might not even be on the final host. - - - - - c4b4b1d7 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci] faster pipeline - - - - - 50c3061d by Moritz Angermann at 2021-05-25T05:52:02-04:00 [hadrian] Properly build hsc2hs wrapper - - - - - 11bdf3cd by Matthew Pickering at 2021-05-25T05:52:02-04:00 Revert "hadrian: Don't always links against libffi" This reverts commit 673ff667c98eafc89e6746d1ac69d33b8330d755. - - - - - 2023b344 by Richard Eisenberg at 2021-05-25T09:08:36-04:00 Add 9.2 release note about linear case This is part of #18738 [skip ci] - - - - - cdbce8fc by Alfredo Di Napoli at 2021-05-26T16:03:15-04:00 Support new parser types in GHC This commit converts the lexers and all the parser machinery to use the new parser types and diagnostics infrastructure. Furthermore, it cleans up the way the parser code was emitting hints. As a result of this systematic approach, the test output of the `InfixAppPatErr` and `T984` tests have been changed. Previously they would emit a `SuggestMissingDo` hint, but this was not at all helpful in resolving the error, and it was even confusing by just looking at the original program that triggered the errors. Update haddock submodule - - - - - 9faafb0a by Pepe Iborra at 2021-05-26T16:03:52-04:00 Avoid fingerprinting the absolute path to the source file This change aims to make source files relocatable w.r.t. to the interface files produced by the compiler. This is so that we can download interface files produced by a cloud build system and then reuse them in a local ghcide session catch another case of implicit includes actually use the implicit quote includes add another missing case recomp020 test that .hi files are reused even if .hs files are moved to a new location Added recomp021 to record behaviour with non implicit includes add a note additional pointer to the note Mention #16956 in Note - - - - - 03d69e4b by Andreas Klebinger at 2021-05-27T02:35:11-04:00 Enable strict dicts by default at -O2. In the common case this is a straight performance win at a compile time cost so we enable it at -O2. In rare cases it can lead to compile time regressions because of changed inlining behaviour. Which can very rarely also affect runtime performance. Increasing the inlining threshold can help to avoid this which is documented in the user guide. In terms of measured results this reduced instructions executed for nofib by 1%. However for some cases (e.g. Cabal) enabling this by default increases compile time by 2-3% so we enable it only at -O2 where it's clear that a user is willing to trade compile time for runtime. Most of the testsuite runs without -O2 so there are few perf changes. Increases: T12545/T18698: We perform more WW work because dicts are now treated strict. T9198: Also some more work because functions are now subject to W/W Decreases: T14697: Compiling empty modules. Probably because of changes inside ghc. T9203: I can't reproduce this improvement locally. Might be spurious. ------------------------- Metric Decrease: T12227 T14697 T9203 Metric Increase: T9198 T12545 T18698a T18698b ------------------------- - - - - - 9935e99c by Shayne Fletcher at 2021-05-27T02:35:47-04:00 Change representation of HsGetField and HsProjection Another change in a series improving record syntax in the AST. The key change in this commit is the renaming of `HsFieldLabel` to `DotFieldOcc`. - - - - - ce1b8f42 by Andreas Klebinger at 2021-05-27T02:36:23-04:00 Improve deriveConstants error message. This fixes #19823 - - - - - 6de8ac89 by Alan Zimmerman at 2021-05-27T19:25:24+01:00 [EPA] exact print linear arrows. Closes #19903 Note: the normal ppr does not reproduce unicode linear arrows, so that part of the normal printing test is ommented out in the Makefile for this test. See #18846 - - - - - f74204c4 by Boris Lykah at 2021-05-28T15:32:01-04:00 Document release when TypeApplications allowed declaring variables as inferred - - - - - df997fac by Sylvain Henry at 2021-05-28T15:32:44-04:00 Use quotRemWord in showWord Using the following high-quality benchmark (with -O2): main :: IO () main = do let go 0 = "" go n@(W# n#) = showWord n# (go (n -1)) print $ length (go 10000000) I get the following performance results: - remWord+quotRem: 0,76s user 0,00s system 99% cpu 0,762 total - quotRemWord: 0,45s user 0,01s system 99% cpu 0,456 total Note that showSignedInt already uses quotRemInt. - - - - - 5ae070f1 by Thomas Winant at 2021-05-29T05:04:00-04:00 Add -Wmissing-exported-pattern-synonym-signatures After !4741, it was no longer possible to silence a warning about a missing pattern synonym signature if the `-Wmissing-signatures` flag was on. Restore the previous semantics while still adhering to the principle "enabling an additional warning flag should never make prior warnings disappear". For more symmetry and granularity, introduce `-Wmissing-exported-pattern-synonym-signatures`. See Note [Missing signatures] for an overview of all flags involved. - - - - - 28e0dca2 by Luite Stegeman at 2021-05-29T05:04:39-04:00 Work around LLVM backend overlapping register limitations The stg_ctoi_t and stg_ret_t procedures which convert unboxed tuples between the bytecode an native calling convention were causing a panic when using the LLVM backend. Fixes #19591 - - - - - 6412bf6e by parsonsmatt at 2021-05-29T05:05:18-04:00 Add `newDeclarationGroup` and provide documentation in reifyInstances and isInstance - - - - - 99b5cce9 by parsonsmatt at 2021-05-29T05:05:18-04:00 Address review comments, export from TH - - - - - 76902415 by parsonsmatt at 2021-05-29T05:05:18-04:00 Apply 2 suggestion(s) to 1 file(s) - - - - - 0c0e1855 by parsonsmatt at 2021-05-29T05:05:18-04:00 sigh - - - - - 10f48e22 by Matthew Pickering at 2021-05-29T05:05:55-04:00 ghci: Enable -fkeep-going by default This also demotes the error message about -fkeep-going to a trace message which matches the behaviour of other build systems (such as cabal-install and nix) which don't print any message like this on a failure. We want to remove the stable module check in a future patch, which is an approximation of `-fkeep-going`. At the moment this change shouldn't do very much. - - - - - 492b2dc5 by Zubin Duggal at 2021-05-29T05:06:32-04:00 Fix Note [Positioning of forkM] - - - - - 45387760 by Sylvain Henry at 2021-05-29T10:18:01-04:00 Bignum: match on DataCon workers in rules (#19892) We need to match on DataCon workers for the rules to be triggered. T13701 ghc/alloc decreases by ~2.5% on some archs Metric Decrease: T13701 - - - - - 0f8872ec by Sylvain Henry at 2021-05-29T10:18:01-04:00 Fix and slight improvement to datacon worker/wrapper notes - - - - - 6db8a0f7 by Richard Eisenberg at 2021-05-29T10:18:37-04:00 Rip GHC.Tc.Solver.Monad asunder (only) This creates new modules GHC.Tc.Solver.InertSet and GHC.Tc.Solver.Types. The Monad module is still pretty big, but this is an improvement. Moreover, it means that GHC.HsToCore.Pmc.Solver.Types no longer depends on the constraint solver (it now depends on GHC.Tc.Solver.InertSet), making the error-messages work easier. This patch thus contributes to #18516. - - - - - 42c611cf by Ben Gamari at 2021-05-29T11:57:51-04:00 Split GHC.Utils.Monad.State into .Strict and .Lazy - - - - - ec646247 by Ben Gamari at 2021-05-29T11:58:45-04:00 Use GHC's State monad consistently GHC's internal State monad benefits from oneShot annotations on its state, allowing for more aggressive eta expansion. We currently don't have monad transformers with the same optimisation, so we only change uses of the pure State monad here. See #19657 and 19380. Metric Decrease: hie002 - - - - - 21bdd9b7 by Ben Gamari at 2021-05-29T11:58:52-04:00 StgM: Use ReaderT rather than StateT - - - - - 6b6c4b9a by Viktor Dukhovni at 2021-06-02T04:38:47-04:00 Improve wording of fold[lr]M documentation. The sequencing of monadic effects in foldlM and foldrM was described as respectively right-associative and left-associative, but this could be confusing, as in essence we're just composing Kleisli arrows, whose composition is simply associative. What matters therefore is the order of sequencing of effects, which can be described more clearly without dragging in associativity as such. This avoids describing these folds as being both left-to-right and right-to-left depending on whether we're tracking effects or operator application. The new text should be easier to understand. - - - - - fcd124d5 by Roland Senn at 2021-06-02T04:39:23-04:00 Allow primops in a :print (and friends) command. Fix #19394 * For primops from `GHC.Prim` lookup the HValues in `GHC.PrimopWrappers`. * Add short error messages if a user tries to use a *Non-Id* value or a `pseudoop` in a `:print`, `:sprint` or `force`command. * Add additional test cases for `Magic Ids`. - - - - - adddf248 by Zubin Duggal at 2021-06-02T04:39:58-04:00 Fail before checking instances in checkHsigIface if exports don't match (#19244) - - - - - c5a9e32e by Divam at 2021-06-02T04:40:34-04:00 Specify the reason for import for the backpack's extra imports - - - - - 7d8e1549 by Vladislav Zavialov at 2021-06-02T04:41:08-04:00 Disallow linear arrows in GADT records (#19928) Before this patch, GHC used to silently accept programs such as the following: data R where D1 :: { d1 :: Int } %1 -> R The %1 annotation was completely ignored. Now it is a proper error. One remaining issue is that in the error message (⊸) turns into (%1 ->). This is to be corrected with upcoming exactprint updates. - - - - - 437a6ccd by Matthew Pickering at 2021-06-02T16:23:53-04:00 hadrian: Speed up lint:base rule The rule before decided to build the whole stage1 compiler, but this was unecessary as we were just missing one header file which can be generated directly by calling configure. Before: 18 minutes After: 54s - - - - - de33143c by Matthew Pickering at 2021-06-02T16:23:53-04:00 Run both lint jobs together - - - - - 852a12c8 by Matthew Pickering at 2021-06-02T16:23:53-04:00 CI: Don't explicitly build hadrian before using run_hadrian This causes hadrian to be built twice because the second time uses a different index state. - - - - - b66cf8ad by Matthew Pickering at 2021-06-02T16:24:27-04:00 Fix infinite looping in hptSomeModulesBelow When compiling Agda we entered into an infinite loop as the stopping condition was a bit wrong in hptSomeModulesBelow. The bad situation was something like * We would see module A (NotBoot) and follow it dependencies * Later on we would encounter A (Boot) and follow it's dependencies, because the lookup would not match A (NotBoot) and A (IsBoot) * Somewhere in A (Boot)s dependencies, A (Boot) would appear again and lead us into an infinite loop. Now the state marks whether we have been both variants (IsBoot and NotBoot) so we don't follow dependencies for A (Boot) many times. - - - - - b585aff0 by Sebastian Graf at 2021-06-02T23:06:18-04:00 WW: Mark absent errors as diverging again As the now historic part of `NOTE [aBSENT_ERROR_ID]` explains, we used to have `exprIsHNF` respond True to `absentError` and give it a non-bottoming demand signature, in order to perform case-to-let on certain `case`s we used to emit that scrutinised `absentError` (Urgh). What changed, why don't we emit these questionable absent errors anymore? The absent errors in question filled in for binders that would end up in strict fields after being seq'd. Apparently, the old strictness analyser would give these binders an absent demand, but today we give them head-strict demand `1A` and thus don't replace with absent errors at all. This fixes items (1) and (2) of #19853. - - - - - 79d12d34 by Shayne Fletcher at 2021-06-02T23:06:52-04:00 CountDeps: print graph of module dependencies in dot format The tests `CountParserDeps.hs` and `CountAstDeps.hs` are implemented by calling `CountDeps`. In this MR, `CountDeps.printDeps` is updated such tat by uncommenting a line, you can print a module's dependency graph showing what includes what. The output is in a format suitable for use with graphviz. - - - - - 25977ab5 by Matthew Pickering at 2021-06-03T08:46:47+01:00 Driver Rework Patch This patch comprises of four different but closely related ideas. The net result is fixing a large number of open issues with the driver whilst making it simpler to understand. 1. Use the hash of the source file to determine whether the source file has changed or not. This makes the recompilation checking more robust to modern build systems which are liable to copy files around changing their modification times. 2. Remove the concept of a "stable module", a stable module was one where the object file was older than the source file, and all transitive dependencies were also stable. Now we don't rely on the modification time of the source file, the notion of stability is moot. 3. Fix TH/plugin recompilation after the removal of stable modules. The TH recompilation check used to rely on stable modules. Now there is a uniform and simple way, we directly track the linkables which were loaded into the interpreter whilst compiling a module. This is an over-approximation but more robust wrt package dependencies changing. 4. Fix recompilation checking for dynamic object files. Now we actually check if the dynamic object file exists when compiling with -dynamic-too Fixes #19774 #19771 #19758 #17434 #11556 #9121 #8211 #16495 #7277 #16093 - - - - - d5b89ed4 by Alfredo Di Napoli at 2021-06-03T15:58:33-04:00 Port HsToCore messages to new infrastructure This commit converts a bunch of HsToCore (Ds) messages to use the new GHC's diagnostic message infrastructure. In particular the DsMessage type has been expanded with a lot of type constructors, each encapsulating a particular error and warning emitted during desugaring. Due to the fact that levity polymorphism checking can happen both at the Ds and at the TcRn level, a new `TcLevityCheckDsMessage` constructor has been added to the `TcRnMessage` type. - - - - - 7a05185a by Roland Senn at 2021-06-03T15:59:10-04:00 Follow up #12449: Improve function `Inspect.hs:check2` * Add a Note to clarify RttiTypes. * Don't call `quantifyType` at all the call sites of `check2`. * Simplyfy arguments of functions `Inspect.hs:check1` and `Inspect.hs:check2`. - `check1` only uses the two lists of type variables, but not the types. - `check2` only uses the two types, but not the lists of type variables. * In `Inspect.hs:check2` send only the tau part of the type to `tcSplitTyConApp_maybe`. - - - - - 1bb0565c by Thomas Winant at 2021-06-04T00:30:22-04:00 Fix incorrect mention of -Wprepositive-qualified-syntax in docs The flag is called `-Wprepositive-qualified-module`, not `-Wprepositive-qualified-syntax`. Use the `:ghc-flag:` syntax, which would have caught the mistake in the first place. - - - - - 44d131af by Takenobu Tani at 2021-06-04T00:30:59-04:00 users-guide: Add OverloadedRecordDot and OverloadedRecordUpdate for ghc-9.2 This patch adds OverloadedRecordDot and OverloadedRecordUpdate in 9.2.1's release note. - - - - - f1b748b4 by Alfredo Di Napoli at 2021-06-04T12:43:41-04:00 Add PsHeaderMessage diagnostic (fixes #19923) This commit replaces the PsUnknownMessage diagnostics over at `GHC.Parser.Header` with a new `PsHeaderMessage` type (part of the more general `PsMessage`), so that we can throw parser header's errors which can be correctly caught by `GHC.Driver.Pipeline.preprocess` and rewrapped (correctly) as Driver messages (using the `DriverPsHeaderMessage`). This gets rid of the nasty compiler crash as part of #19923. - - - - - 733757ad by sheaf at 2021-06-04T12:44:19-04:00 Make some simple primops levity-polymorphic Fixes #17817 - - - - - 737b0ae1 by Sylvain Henry at 2021-06-04T12:45:01-04:00 Fix Integral instances for Words * ensure that division wrappers are INLINE * make div/mod/divMod call quot/rem/quotRem (same code) * this ensures that the quotRemWordN# primitive is used to implement divMod (it wasn't the case for sized Words) * make first argument strict for Natural and Integer (similarly to other numeric types) - - - - - 1713cbb0 by Shayne Fletcher at 2021-06-05T03:47:48-04:00 Make 'count-deps' a ghc/util standalone program - Move 'count-deps' into 'ghc/utils' so that it can be called standalone. - Move 'testsuite/tests/parser/should_run/' tests 'CountParserDeps' and 'CountAstDeps' to 'testsuite/tests/count-deps' and reimplement in terms of calling the utility - Document how to use 'count-deps' in 'ghc/utils/count-deps/README' - - - - - 9a28680d by Sylvain Henry at 2021-06-05T03:48:25-04:00 Put Unique related global variables in the RTS (#19940) - - - - - 8c90e6c7 by Richard Eisenberg at 2021-06-05T10:29:22-04:00 Fix #19682 by breaking cycles in Deriveds This commit expands the old Note [Type variable cycles in Givens] to apply as well to Deriveds. See the Note for details and examples. This fixes a regression introduced by my earlier commit that killed off the flattener in favor of the rewriter. A few other things happened along the way: * unifyTest was renamed to touchabilityTest, because that's what it does. * isInsolubleOccursCheck was folded into checkTypeEq, which does much of the same work. To get this to work out, though, we need to keep more careful track of what errors we spot in checkTypeEq, and so CheckTyEqResult has become rather more glorious. * A redundant Note or two was eliminated. * Kill off occCheckForErrors; due to Note [Rewriting synonyms], the extra occCheckExpand here is always redundant. * Store blocked equalities separately from other inerts; less stuff to look through when kicking out. Close #19682. test case: typecheck/should_compile/T19682{,b} - - - - - 3b1aa7db by Moritz Angermann at 2021-06-05T10:29:57-04:00 Adds AArch64 Native Code Generator In which we add a new code generator to the Glasgow Haskell Compiler. This codegen supports ELF and Mach-O targets, thus covering Linux, macOS, and BSDs in principle. It was tested only on macOS and Linux. The NCG follows a similar structure as the other native code generators we already have, and should therfore be realtively easy to follow. It supports most of the features required for a proper native code generator, but does not claim to be perfect or fully optimised. There are still opportunities for optimisations. Metric Decrease: ManyAlternatives ManyConstructors MultiLayerModules PmSeriesG PmSeriesS PmSeriesT PmSeriesV T10421 T10421a T10858 T11195 T11276 T11303b T11374 T11822 T12227 T12545 T12707 T13035 T13253 T13253-spj T13379 T13701 T13719 T14683 T14697 T15164 T15630 T16577 T17096 T17516 T17836 T17836b T17977 T17977b T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T3064 T5030 T5321FD T5321Fun T5631 T5642 T5837 T783 T9198 T9233 T9630 T9872d T9961 WWRec Metric Increase: T4801 - - - - - db1e07f1 by Moritz Angermann at 2021-06-05T10:29:57-04:00 [ci] -llvm with --way=llvm - - - - - 1b2f894f by Moritz Angermann at 2021-06-05T10:29:57-04:00 [ci] no docs for aarch64-linux-llvm - - - - - a1fed3a5 by Moritz Angermann at 2021-06-05T10:29:57-04:00 [ci] force CC=clang for aarch64-linux - - - - - 4db2d44c by Moritz Angermann at 2021-06-05T10:29:57-04:00 [testsuite] fix T13702 with clang - - - - - ecc3a405 by Moritz Angermann at 2021-06-05T10:29:57-04:00 [testsuite] fix T6132 when using the LLVM toolchain - - - - - cced9454 by Shayne Fletcher at 2021-06-05T19:23:11-04:00 Countdeps: Strictly documentation markup fixes [ci skip] - - - - - ea9a4ef6 by Simon Peyton Jones at 2021-06-05T19:23:46-04:00 Avoid useless w/w split, take 2 This commit: commit c6faa42bfb954445c09c5680afd4fb875ef03758 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Mon Mar 9 10:20:42 2020 +0000 Avoid useless w/w split This patch is just a tidy-up for the post-strictness-analysis worker wrapper split. Consider f x = x Strictnesss analysis does not lead to a w/w split, so the obvious thing is to leave it 100% alone. But actually, because the RHS is small, we ended up adding a StableUnfolding for it. There is some reason to do this if we choose /not/ do to w/w on the grounds that the function is small. See Note [Don't w/w inline small non-loop-breaker things] But there is no reason if we would not have done w/w anyway. This patch just moves the conditional to later. Easy. turns out to have a bug in it. Instead of /moving/ the conditional, I /duplicated/ it. Then in a subsequent unrelated tidy-up (087ac4eb) I removed the second (redundant) test! This patch does what I originally intended. There is also a small refactoring in GHC.Core.Unfold, to make the code clearer, but with no change in behaviour. It does, however, have a generally good effect on compile times, because we aren't dealing with so many silly stable unfoldings. Here are the non-zero changes: Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change --------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 791969344.0 792665048.0 +0.1% ManyConstructors(normal) ghc/alloc 4351126824.0 4358303528.0 +0.2% PmSeriesG(normal) ghc/alloc 50362552.0 50482208.0 +0.2% PmSeriesS(normal) ghc/alloc 63733024.0 63619912.0 -0.2% T10421(normal) ghc/alloc 121224624.0 119695448.0 -1.3% GOOD T10421a(normal) ghc/alloc 85256392.0 83714224.0 -1.8% T10547(normal) ghc/alloc 29253072.0 29258256.0 +0.0% T10858(normal) ghc/alloc 189343152.0 187972328.0 -0.7% T11195(normal) ghc/alloc 281208248.0 279727584.0 -0.5% T11276(normal) ghc/alloc 141966952.0 142046224.0 +0.1% T11303b(normal) ghc/alloc 46228360.0 46259024.0 +0.1% T11545(normal) ghc/alloc 2663128768.0 2667412656.0 +0.2% T11822(normal) ghc/alloc 138686944.0 138760176.0 +0.1% T12227(normal) ghc/alloc 482836000.0 475421056.0 -1.5% GOOD T12234(optasm) ghc/alloc 60710520.0 60781808.0 +0.1% T12425(optasm) ghc/alloc 104089000.0 104022424.0 -0.1% T12545(normal) ghc/alloc 1711759416.0 1705711528.0 -0.4% T12707(normal) ghc/alloc 991541120.0 991921776.0 +0.0% T13035(normal) ghc/alloc 108199872.0 108370704.0 +0.2% T13056(optasm) ghc/alloc 414642544.0 412580384.0 -0.5% T13253(normal) ghc/alloc 361701272.0 355838624.0 -1.6% T13253-spj(normal) ghc/alloc 157710168.0 157397768.0 -0.2% T13379(normal) ghc/alloc 370984400.0 371345888.0 +0.1% T13701(normal) ghc/alloc 2439764144.0 2441351984.0 +0.1% T14052(ghci) ghc/alloc 2154090896.0 2156671400.0 +0.1% T15164(normal) ghc/alloc 1478517688.0 1440317696.0 -2.6% GOOD T15630(normal) ghc/alloc 178053912.0 172489808.0 -3.1% T16577(normal) ghc/alloc 7859948896.0 7854524080.0 -0.1% T17516(normal) ghc/alloc 1271520128.0 1202096488.0 -5.5% GOOD T17836(normal) ghc/alloc 1123320632.0 1123922480.0 +0.1% T17836b(normal) ghc/alloc 54526280.0 54576776.0 +0.1% T17977b(normal) ghc/alloc 42706752.0 42730544.0 +0.1% T18140(normal) ghc/alloc 108834568.0 108693816.0 -0.1% T18223(normal) ghc/alloc 5539629264.0 5579500872.0 +0.7% T18304(normal) ghc/alloc 97589720.0 97196944.0 -0.4% T18478(normal) ghc/alloc 770755472.0 771232888.0 +0.1% T18698a(normal) ghc/alloc 408691160.0 374364992.0 -8.4% GOOD T18698b(normal) ghc/alloc 492419768.0 458809408.0 -6.8% GOOD T18923(normal) ghc/alloc 72177032.0 71368824.0 -1.1% T1969(normal) ghc/alloc 803523496.0 804655112.0 +0.1% T3064(normal) ghc/alloc 198411784.0 198608512.0 +0.1% T4801(normal) ghc/alloc 312416688.0 312874976.0 +0.1% T5321Fun(normal) ghc/alloc 325230680.0 325474448.0 +0.1% T5631(normal) ghc/alloc 592064448.0 593518968.0 +0.2% T5837(normal) ghc/alloc 37691496.0 37710904.0 +0.1% T783(normal) ghc/alloc 404629536.0 405064432.0 +0.1% T9020(optasm) ghc/alloc 266004608.0 266375592.0 +0.1% T9198(normal) ghc/alloc 49221336.0 49268648.0 +0.1% T9233(normal) ghc/alloc 913464984.0 742680256.0 -18.7% GOOD T9675(optasm) ghc/alloc 552296608.0 466322000.0 -15.6% GOOD T9872a(normal) ghc/alloc 1789910616.0 1793924472.0 +0.2% T9872b(normal) ghc/alloc 2315141376.0 2310338056.0 -0.2% T9872c(normal) ghc/alloc 1840422424.0 1841567224.0 +0.1% T9872d(normal) ghc/alloc 556713248.0 556838432.0 +0.0% T9961(normal) ghc/alloc 383809160.0 384601600.0 +0.2% WWRec(normal) ghc/alloc 773751272.0 753949608.0 -2.6% GOOD Residency goes down too: Metrics: compile_time/max_bytes_used ------------------------------------ Baseline Test Metric value New value Change ----------------------------------------------------------- T10370(optasm) ghc/max 42058448.0 39481672.0 -6.1% T11545(normal) ghc/max 43641392.0 43634752.0 -0.0% T15304(normal) ghc/max 29895824.0 29439032.0 -1.5% T15630(normal) ghc/max 8822568.0 8772328.0 -0.6% T18698a(normal) ghc/max 13882536.0 13787112.0 -0.7% T18698b(normal) ghc/max 14714112.0 13836408.0 -6.0% T1969(normal) ghc/max 24724128.0 24733496.0 +0.0% T3064(normal) ghc/max 14041152.0 14034768.0 -0.0% T3294(normal) ghc/max 32769248.0 32760312.0 -0.0% T9630(normal) ghc/max 41605120.0 41572184.0 -0.1% T9675(optasm) ghc/max 18652296.0 17253480.0 -7.5% Metric Decrease: T10421 T12227 T15164 T17516 T18698a T18698b T9233 T9675 WWRec Metric Increase: T12545 - - - - - 52a524f7 by Simon Peyton Jones at 2021-06-05T19:23:46-04:00 Re-do rubbish literals As #19882 pointed out, we were simply doing rubbish literals wrong. (I'll refrain from explaining the wrong-ness here -- see the ticket.) This patch fixes it by adding a Type (of kind RuntimeRep) as field of LitRubbish, rather than [PrimRep]. The Note [Rubbish literals] in GHC.Types.Literal explains the details. - - - - - 34424b9d by Simon Peyton Jones at 2021-06-05T19:23:46-04:00 Drop absent bindings in worker/wrapper Consider this (from #19824) let t = ...big... in ...(f t x)... were `f` ignores its first argument. With luck f's wrapper will inline thereby dropping `t`, but maybe not: the arguments to f all look boring. So we pre-empt the problem by replacing t's RHS with an absent filler during w/w. Simple and effective. The main payload is the new `isAbsDmd` case in `tryWw`, but there are some other minor refactorings: * To implment this I had to refactor `mk_absent_let` to `mkAbsentFiller`, which can be called from `tryWW`. * wwExpr took both WwOpts and DynFlags which seems silly. I combined them into one. * I renamed the historical mkInineRule to mkWrapperUnfolding - - - - - 3e343292 by Ben Gamari at 2021-06-05T19:23:46-04:00 testsuite: Eliminate fragility of ioprof As noted in #10037, the `ioprof` test would change its stderr output (specifically the stacktrace produced by `error`) depending upon optimisation level. As the `error` backtrace is not the point of this test, we now ignore the `stderr` output. - - - - - 5e1a2244 by Ben Gamari at 2021-06-05T19:23:46-04:00 testsuite: Fix Note style - - - - - 4dc681c7 by Sylvain Henry at 2021-06-07T10:35:39+02:00 Make Logger independent of DynFlags Introduce LogFlags as a independent subset of DynFlags used for logging. As a consequence in many places we don't have to pass both Logger and DynFlags anymore. The main reason for this refactoring is that I want to refactor the systools interfaces: for now many systools functions use DynFlags both to use the Logger and to fetch their parameters (e.g. ldInputs for the linker). I'm interested in refactoring the way they fetch their parameters (i.e. use dedicated XxxOpts data types instead of DynFlags) for #19877. But if I did this refactoring before refactoring the Logger, we would have duplicate parameters (e.g. ldInputs from DynFlags and linkerInputs from LinkerOpts). Hence this patch first. Some flags don't really belong to LogFlags because they are subsystem specific (e.g. most DumpFlags). For example -ddump-asm should better be passed in NCGConfig somehow. This patch doesn't fix this tight coupling: the dump flags are part of the UI but they are passed all the way down for example to infer the file name for the dumps. Because LogFlags are a subset of the DynFlags, we must update the former when the latter changes (not so often). As a consequence we now use accessors to read/write DynFlags in HscEnv instead of using `hsc_dflags` directly. In the process I've also made some subsystems less dependent on DynFlags: - CmmToAsm: by passing some missing flags via NCGConfig (see new fields in GHC.CmmToAsm.Config) - Core.Opt.*: - by passing -dinline-check value into UnfoldingOpts - by fixing some Core passes interfaces (e.g. CallArity, FloatIn) that took DynFlags argument for no good reason. - as a side-effect GHC.Core.Opt.Pipeline.doCorePass is much less convoluted. - - - - - 3a90814f by Sylvain Henry at 2021-06-07T11:19:35+02:00 Parser: make less DynFlags dependent This is an attempt at reducing the number of dependencies of the Parser (as reported by CountParserDeps). Modules in GHC.Parser.* don't import GHC.Driver.Session directly anymore. Sadly some GHC.Driver.* modules are still transitively imported and the number of dependencies didn't decrease. But it's a step in the right direction. - - - - - 40c0f67f by Sylvain Henry at 2021-06-07T11:19:35+02:00 Bump haddock submodule - - - - - 9e724f6e by Viktor Dukhovni at 2021-06-07T15:35:22-04:00 Small ZipList optimisation In (<|>) for ZipList, avoid processing the first argument twice (both as first argument of (++) and for its length in drop count of the second argument). Previously, the entire first argument was forced into memory, now (<|>) can run in constant space even with long inputs. - - - - - 7ea3b7eb by Ryan Scott at 2021-06-08T01:07:10+05:30 Introduce `hsExprType :: HsExpr GhcTc -> Type` in the new module `GHC.Hs.Syn.Type` The existing `hsPatType`, `hsLPatType` and `hsLitType` functions have also been moved to this module This is a less ambitious take on the same problem that !2182 and !3866 attempt to solve. Rather than have the `hsExprType` function attempt to efficiently compute the `Type` of every subexpression in an `HsExpr`, this simply computes the overall `Type` of a single `HsExpr`. - Explicitly forbids the `SplicePat` `HsIPVar`, `HsBracket`, `HsRnBracketOut` and `HsTcBracketOut` constructors during the typechecking phase by using `Void` as the TTG extension field - Also introduces `dataConCantHappen` as a domain specific alternative to `absurd` to handle cases where the TTG extension points forbid a constructor. - Turns HIE file generation into a pure function that doesn't need access to the `DsM` monad to compute types, but uses `hsExprType` instead. - Computes a few more types during HIE file generation - Makes GHCi's `:set +c` command also use `hsExprType` instead of going through the desugarer to compute types. Updates haddock submodule Co-authored-by: Zubin Duggal <zubin.duggal at gmail.com> - - - - - 378c0bba by Tamar Christina at 2021-06-08T15:40:50-04:00 winio: use synchronous access explicitly for handles that may not be asynchronous. - - - - - 31bfafec by Baldur Blöndal at 2021-06-09T09:46:17-04:00 Added a regression test, this would trigger a Core Lint error before GHC 9 - - - - - d69067a1 by Matthew Pickering at 2021-06-09T09:46:51-04:00 FinderCache: Also cache file hashing in interface file checks Now that we hash object files to decide when to recompile due to TH, this can make a big difference as each interface file in a project will contain reference to the object files of all package dependencies. Especially when these are statically linked, hashing them can add up. The cache is invalidated when `depanalPartial` is called, like the normal finder cache. - - - - - f4a5e30e by Simon Peyton Jones at 2021-06-10T02:38:19-04:00 Do not add unfoldings to lambda-binders For reasons described in GHC.Core.Opt.Simplify Historical Note [Case binders and join points], we used to keep a Core unfolding in one of the lambda-binders for a join point. But this was always a gross hack -- it's very odd to have an unfolding in a lambda binder, that refers to earlier lambda binders. The hack bit us in various ways: * Most seriously, it is incompatible with linear types in Core. * It complicated demand analysis, and could worsen results * It required extra care in the simplifier (simplLamBinder) * It complicated !5641 (look for "join binder unfoldings") So this patch just removes the hack. Happily, doind so turned out to have no effect on performance. - - - - - 8baa8874 by Li-yao Xia at 2021-06-10T02:38:54-04:00 User's Guide: reword and fix punctuation in description of PostfixOperators - - - - - fb6b6379 by Matthew Pickering at 2021-06-10T02:39:29-04:00 Add (broken) test for #19966 - - - - - 61c51c00 by Sylvain Henry at 2021-06-10T02:40:07-04:00 Fix redundant import - - - - - 472c2bf0 by sheaf at 2021-06-10T13:54:05-04:00 Reword: representation instead of levity fixes #19756, updates haddock submodule - - - - - 3d5cb335 by Simon Peyton Jones at 2021-06-10T13:54:40-04:00 Fix INLINE pragmas in desugarer In #19969 we discovered that GHC has has a bug *forever* that means it sometimes essentially discarded INLINE pragams. This happened when you have * Two more more mutually recursive functions * Some of which (presumably not all!) have an INLINE pragma * Completely monomorphic. This hits a particular case in GHC.HsToCore.Binds.dsAbsBinds, which was simply wrong -- it put the INLINE pragma on the wrong binder. This patch fixes the bug, rather easily, by adjusting the no-tyvar, no-dict case of GHC.HsToCore.Binds.dsAbsBinds. I also discovered that the GHC.Core.Opt.Pipeline.shortOutIndirections was not doing a good job for {-# INLINE lcl_id #-} lcl_id = BIG gbl_id = lcl_id Here we want to transfer the stable unfolding to gbl_id (we do), but we also want to remove it from lcl_id (we were not doing that). Otherwise both Ids have large stable unfoldings. Easily fixed. Note [Transferring IdInfo] explains. - - - - - 2a7e29e5 by Ben Gamari at 2021-06-16T16:58:37+00:00 gitlab-ci: Bump ci-images - - - - - 6c131ba0 by Baldur Blöndal at 2021-06-16T20:18:35-04:00 DerivingVia for Hsc instances. GND for NonDetFastString and LexicalFastString. - - - - - a2e4cb80 by Vladislav Zavialov at 2021-06-16T20:19:10-04:00 HsUniToken and HsToken for HsArrow (#19623) Another step towards a simpler design for exact printing. Updates the haddock submodule. - - - - - 01fd2617 by Matthew Pickering at 2021-06-16T20:19:45-04:00 profiling: Look in RHS of rules for cost centre ticks There are some obscure situations where the RHS of a rule can contain a tick which is not mentioned anywhere else in the program. If this happens you end up with an obscure linker error. The solution is quite simple, traverse the RHS of rules to also look for ticks. It turned out to be easier to implement if the traversal was moved into CoreTidy rather than at the start of code generation because there we still had easy access to the rules. ./StreamD.o(.text+0x1b9f2): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc' ./MArray.o(.text+0xbe83): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc' Main.o(.text+0x6fdb): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc' - - - - - d8bfebec by AriFordsham at 2021-06-16T20:20:22-04:00 Corrected typo - - - - - 34484c89 by Divam at 2021-06-16T20:20:59-04:00 Remove the backend correction logic, as it is already been fixed at this point - - - - - e25772a0 by Peter Trommler at 2021-06-16T20:21:34-04:00 PPC NCG: Fix panic in linear register allocator - - - - - a83d2999 by Krzysztof Gogolewski at 2021-06-16T20:22:09-04:00 Fix error message for record updates, #19972 Fix found by Adam Gundry. - - - - - a0622459 by Matthew Pickering at 2021-06-17T11:55:17+01:00 Move validate-x86_64-linux-deb9-hadrian back to quick-build This increases the critical path length but in practice will reduce pressure on runners because less jobs overall will be spawned. See #20003 [skip ci] - - - - - 3b783496 by Simon Peyton Jones at 2021-06-18T12:27:33-04:00 Enhance cast worker/wrapper for INLINABLE In #19890 we realised that cast worker/wrapper didn't really work properly for functions with an INLINABLE pragma, and hence a stable unfolding. This patch fixes the problem. Instead of disabling cast w/w when there is a stable unfolding (as we did before), we now tranfer the stable unfolding to the worker. It turned out that it was easier to do that if I moved the cast w/w stuff from prepareBinding to completeBind. No chnages at all in nofib results: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- Min -0.0% 0.0% -63.8% -78.2% 0.0% Max -0.0% 0.0% +11.8% +11.7% 0.0% Geometric Mean -0.0% -0.0% -26.6% -33.4% -0.0% Small decreases in compile-time allocation for two tests (below) of around 2%. T12545 increased in compile-time alloc by 4%, but it's not reproducible on my machine, and is a known-wobbly test. Metric Increase: T12545 Metric Decrease: T18698a T18698b - - - - - c6a00c15 by Simon Peyton Jones at 2021-06-18T12:27:33-04:00 Improve abstractVars quantification ordering When floating a binding out past some type-variable binders, don't gratuitiously change the order of the binders. This small change gives code that is simpler, has less risk of non-determinism, and does not gratuitiously change type-variable order. See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. This is really just refactoring; no change in behaviour. - - - - - db7e6dc5 by Simon Peyton Jones at 2021-06-18T12:27:33-04:00 Improve pretty-printing of coercions With -dsuppress-coercions, it's still good to be able to see the type of the coercion. This patch prints the type. Maybe we should have a flag to control this too. - - - - - 5d3d9925 by Gleb Popov at 2021-06-18T12:27:36-04:00 Pass -DLIBICONV_PLUG when building base library on FreeBSD. If libiconv is installed from packages on the build machine, there is a high chance that the build system will pick up /usr/local/include/iconv.h instead of base /usr/include/iconv.h This additional preprocessor define makes package's libiconv header compatible with system one, fixing the build. Closes issue #19958 - - - - - 1e2ba8a4 by Matthew Pickering at 2021-06-19T12:22:27-04:00 CI: Keep the value of PERF_NOTE_KEY in darwin environments This fixes the performance test tracking for all darwin environments. - - - - - 028b9474 by Simon Peyton Jones at 2021-06-19T12:23:02-04:00 Add comments explaining why #19833 is wrong I realised that the suggestion in #19833 doesn't work, and documented why in Note [Zapping Used Once info in WorkWrap] - - - - - 6b2952cf by Sylvain Henry at 2021-06-19T12:23:39-04:00 RTS: fix indentation warning - - - - - a6548a66 by David at 2021-06-19T12:24:15-04:00 Correct haddock annotations in GetOpt - - - - - 23bb09c9 by Sylvain Henry at 2021-06-19T12:24:52-04:00 Perf: fix appendFS To append 2 FastString we don't need to convert them into ByteString: use ShortByteString's Semigroup instance instead. - - - - - 1c79ddc8 by Matthew Pickering at 2021-06-19T12:25:26-04:00 RTS: Fix flag parsing for --eventlog-flush-interval Fixes #20006 - - - - - fc8ad5f3 by Simon Peyton Jones at 2021-06-19T12:26:01-04:00 Fix type and strictness signature of fork# When working eta-expansion and reduction, I found that fork# had a weaker strictness signature than it should have (#19992). In particular, it didn't record that it applies its argument exactly once. To this I needed to give it a proper type (its first argument is always a function, which in turn entailed a small change to the call in GHC.Conc.Sync This patch fixes it. - - - - - 217b4dcc by Krzysztof Gogolewski at 2021-06-19T12:26:35-04:00 Deprecate -Wmissing-monadfail-instances (#17875) Also document deprecation of Wnoncanonical-monadfail-instances and -Wimplicit-kind-vars - - - - - 8838241f by Sylvain Henry at 2021-06-19T12:27:12-04:00 Fix naturalToFloat/Double * move naturalToFloat/Double from ghc-bignum to base:GHC.Float and make them wired-in (as their integerToFloat/Double counterparts) * use the same rounding method as integerToFloat/Double. This is an oversight of 540fa6b2cff3802877ff56a47ab3611e33a9ac86 * add passthrough rules for intToFloat, intToDouble, wordToFloat, wordToDouble. - - - - - 3f60a7e5 by Vladislav Zavialov at 2021-06-19T22:58:33-04:00 Do not reassociate lexical negation (#19838) - - - - - 4c87a3d1 by Ryan Scott at 2021-06-19T22:59:08-04:00 Simplify pprLHsContext This removes an _ad hoc_ special case for empty `LHsContext`s in `pprLHsContext`, fixing #20011. To avoid regressions in pretty-printing data types and classes constructed via TH, we now apply a heuristic where we convert empty datatype contexts and superclasses to a `Nothing` (rather than `Just` an empty context). This will, for instance, avoid pretty-printing every TH-constructed data type as `data () => Blah ...`. - - - - - a6a8d3f5 by Moritz Angermann at 2021-06-20T07:11:58-04:00 Guard Allocate Exec via LIBFFI by LIBFFI We now have two darwin flavours. AArch64-Darwin, and x86_64-darwin, the latter one which has proper custom adjustor support, the former though relies on libffi. Mixing both leads to odd crashes, as the closures might not fit the size of the libffi closures. Hence this needs to be guarded by the USE_LBFFI_FOR_ADJUSTORS guard. Original patch by Hamish Mackenzie - - - - - 689016dc by Matthew Pickering at 2021-06-20T07:12:32-04:00 Darwin CI: Don't explicitly pass ncurses/iconv paths Passing --with-ncurses-libraries means the path which gets backed in progagate into the built binaries. This is incorrect when we want to distribute the binaries because the user might not have the library in that specific place. It's the user's reponsibility to direct the dynamic linker to the right place. Fixes #19968 - - - - - 4a65c0f8 by Matthew Pickering at 2021-06-20T07:12:32-04:00 rts: Pass -Wl,_U,___darwin_check_fd_set_overflow on Darwin Note [fd_set_overflow] ~~~~~~~~~~~~~~~~~~~~~~ In this note is the very sad tale of __darwin_fd_set_overflow. The 8.10.5 release was broken because it was built in an environment where the libraries were provided by XCode 12.*, these libraries introduced a reference to __darwin_fd_set_overflow via the FD_SET macro which is used in Select.c. Unfortunately, this symbol is not available with XCode 11.* which led to a linker error when trying to link anything. This is almost certainly a bug in XCode but we still have to work around it. Undefined symbols for architecture x86_64: "___darwin_check_fd_set_overflow", referenced from: _awaitEvent in libHSrts.a(Select.o) ld: symbol(s) not found for architecture x86_64 One way to fix this is to upgrade your version of xcode, but this would force the upgrade on users prematurely. Fortunately it also seems safe to pass the linker option "-Wl,-U,___darwin_check_fd_set_overflow" because the usage of the symbol is guarded by a guard to check if it's defined. __header_always_inline int __darwin_check_fd_set(int _a, const void *_b) { if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) { return __darwin_check_fd_set_overflow(_a, _b, 1); return __darwin_check_fd_set_overflow(_a, _b, 0); } else { return 1; } Across the internet there are many other reports of this issue See: https://github.com/mono/mono/issues/19393 , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 The issue was originally reported in #19950 Fixes #19950 - - - - - 6c783817 by Zubin Duggal at 2021-06-20T07:13:07-04:00 Set min LLVM version to 9 and make version checking use a non-inclusive upper bound. We use a non-inclusive upper bound so that setting the upper bound to 13 for example means that all 12.x versions are accepted. - - - - - 6281a333 by Matthew Pickering at 2021-06-20T07:13:41-04:00 Linker/darwin: Properly honour -fno-use-rpaths The specification is now simple * On linux, use `-Xlinker -rpath -Xlinker` to set the rpath of the executable * On darwin, never use `-Xlinker -rpath -Xlinker`, always inject the rpath afterwards, see `runInjectRPaths`. * If `-fno-use-rpaths` is passed then *never* inject anything into the rpath. Fixes #20004 - - - - - 5abf5997 by Fraser Tweedale at 2021-06-20T07:14:18-04:00 hadrian/README.md: update bignum options - - - - - 65bad0de by Matthew Pickering at 2021-06-22T02:33:00-04:00 CI: Don't set EXTRA_HC_OPTS in head.hackage job Upstream environment variables take precedance over downstream variables. It is more consistent (and easier to modify) if the variables are all set in the head.hackage CI file rather than setting this here. [skip ci] - - - - - 14956cb8 by Sylvain Henry at 2021-06-22T02:33:38-04:00 Put tracing functions into their own module Now that Outputable is independent of DynFlags, we can put tracing functions using SDocs into their own module that doesn't transitively depend on any GHC.Driver.* module. A few modules needed to be moved to avoid loops in DEBUG mode. - - - - - 595dfbb0 by Matthew Pickering at 2021-06-22T02:34:13-04:00 rts: Document --eventlog-flush-interval in RtsFlags Fixes #19995 - - - - - 362f078e by Krzysztof Gogolewski at 2021-06-22T02:34:49-04:00 Typos, minor comment fixes - Remove fstName, sndName, fstIdKey, sndIdKey - no longer used, removed from basicKnownKeyNames - Remove breakpointId, breakpointCondId, opaqueTyCon, unknownTyCon - they were used in the old implementation of the GHCi debugger - Fix typos in comments - Remove outdated comment in Lint.hs - Use 'LitRubbish' instead of 'RubbishLit' for consistency - Remove comment about subkinding - superseded by Note [Kind Constraint and kind Type] - Mention ticket ID in a linear types error message - Fix formatting in using-warnings.rst and linear-types.rst - Remove comment about 'Any' in Dynamic.hs - Dynamic now uses Typeable + existential instead of Any - Remove codeGen/should_compile/T13233.hs This was added by accident, it is not used and T13233 is already in should_fail - - - - - f7e41d78 by Matthew Pickering at 2021-06-22T02:35:24-04:00 ghc-bignum: trimed ~> trimmed Just a small typo which propagated through ghc-bignum - - - - - 62d720db by Potato Hatsue at 2021-06-22T02:36:00-04:00 Fix a typo in pattern synonyms doc - - - - - 87f57ecf by Adam Sandberg Ericsson at 2021-06-23T02:58:00-04:00 ci: fix ci.sh by creating build.mk in one place Previously `prepare_build_mk` created a build.mk that was overwritten right after. This makes the BIGNUM_BACKEND choice take effect, fixing #19953, and causing the metric increase below in the integer-simple job. Metric Increase: space_leak_001 - - - - - 7f6454fb by Matthew Pickering at 2021-06-23T02:58:35-04:00 Optimiser: Correctly deal with strings starting with unicode characters in exprConApp_maybe For example: "\0" is encoded to "C0 80", then the rule would correct use a decoding function to work out the first character was "C0 80" but then just used BS.tail so the rest of the string was "80". This resulted in "\0" being transformed into '\C0\80' : unpackCStringUTF8# "80" Which is obviously bogus. I rewrote the function to call utf8UnconsByteString directly and avoid the roundtrip through Faststring so now the head/tail is computed by the same call. Fixes #19976 - - - - - e14b893a by Matthew Pickering at 2021-06-23T02:59:09-04:00 testsuite: Don't try to run tests with missing libraries As noticed by sgraf, we were still running reqlib tests, even if the library was not available. The reasons for this were not clear to me as they would never work and it was causing some issues with empty stderr files being generated if you used --test-accept. Now if the required library is not there, the test is just skipped, and a counter increased to mark the fact. Perhaps in the future it would be nicer to explicitly record why certain tests are skipped. Missing libraries causing a skip is a special case at the moment. Fixes #20005 - - - - - aa1d0eb3 by sheaf at 2021-06-23T02:59:48-04:00 Enable TcPlugin tests on Windows - - - - - d8e5b274 by Matthew Pickering at 2021-06-23T03:00:23-04:00 ghci: Correct free variable calculation in StgToByteCode Fixes #20019 - - - - - 6bf82316 by Matthew Pickering at 2021-06-23T03:00:57-04:00 hadrian: Pass correct leading_underscore configuration to tests - - - - - 8fba28ec by Moritz Angermann at 2021-06-23T03:01:32-04:00 [testsuite] mark T3007 broken on darwin. Cabal explicitly passes options to set the rpath, which we then also try to set using install_name_tool. Cabal should also pass `-fno-use-rpaths` to suppress the setting of the rpath from within GHC. - - - - - 633bbc1f by Douglas Wilson at 2021-06-23T08:52:26+01:00 ci: Don't allow the nightly pipeline to be interrupted. Since 58cfcc65 the default for jobs has been "interruptible", this means that when new commits are pushed to a branch which already has a running pipeline then the old pipelines for this branch are cancelled. This includes the master branch, and in particular, new commits merged to the master branch will cancel the nightly job. The semantics of pipeline cancelling are actually a bit more complicated though. The interruptible flag is *per job*, but once a pipeline has run *any* non-interruptible job, then the whole pipeline is considered non-interruptible (ref https://gitlab.com/gitlab-org/gitlab/-/issues/32837). This leads to the hack in this MR where by default all jobs are `interruptible: True`, but for pipelines we definitely want to run, there is a dummy job which happens first, which is `interreuptible: False`. This has the effect of dirtying the whole pipeline and preventing another push to master from cancelling it. For now, this patch solves the immediate problem of making sure nightly jobs are not cancelled. In the future, we may want to enable this job also for the master branch, making that change might mean we need more CI capacity than currently available. [skip ci] Ticket: #19554 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 8191785e by Aaron Allen at 2021-06-23T20:33:48-04:00 Converts diagnostics for two errors in Ghc.Tc.Module (#19926) This adds constructors to TcRnMessage to replace use of TcRnUnknownMessage in Ghc.Tc.Module. Adds a test case for the UnsafeDueToPlugin warning. Closes #19926 - - - - - e2d8023d by Sylvain Henry at 2021-06-23T20:34:23-04:00 Add some tests for sized primops - - - - - d79530d1 by Moritz Angermann at 2021-06-23T20:34:23-04:00 [aarch64 NCG] Add better support for sub-word primops During the intial NCG development, GHC did not have support for anything below Words. As such the NCG didn't support any of this either. AArch64-Darwin however needs support for subword, as arguments in excess of the first eight (8) passed via registers are passed on the stack, and there in a packed fashion. Thus ghc learned about subword sizes. This than lead us to gain subword primops, and these subsequently highlighted deficiencies in the AArch64 NCG. This patch rectifies the ones I found through via the test-suite. I do not claim this to be exhaustive. Fixes: #19993 Metric Increase: T10421 T13035 T13719 T14697 T1969 T9203 T9872a T9872b T9872c T9872d T9961 haddock.Cabal haddock.base parsing001 - - - - - 38a6d8b8 by Viktor Dukhovni at 2021-06-23T20:34:58-04:00 Fix typo in Note [Quick Look for particular Ids] Fixes #20029 - - - - - 74c87414 by Tamar Christina at 2021-06-24T12:01:58-04:00 rts: move xxxHash out of the user namespace - - - - - 4023d4d9 by Krzysztof Gogolewski at 2021-06-24T12:02:33-04:00 Fix desugaring with unboxed types (#19883) - - - - - 4c6af6be by Alan Zimmerman at 2021-06-24T12:03:10-04:00 EPA: Bringing over tests and updates from ghc-exactprint - - - - - d6ab9c60 by Moritz Angermann at 2021-06-24T12:03:45-04:00 [aarch64-macho] Fix off-by-one error in the linker We need to be careful about the sign bit for BR26 relocation otherwise we end up encoding a large positive number and reading back a large negative number. - - - - - 48171833 by Matthew Pickering at 2021-06-24T12:04:19-04:00 CI: Fix the cabal_test job to compile the Distribution.Simple target The "Cabal test" was previously testing the compilation of the very advanced Setup.hs file. Now we compile the whole library, as the test intended. - - - - - 171413c6 by Matthew Pickering at 2021-06-24T12:04:19-04:00 cabal_test: Make output more like head.hackage output This helps with the import of the results into the performance database. - - - - - 138b7a57 by Viktor Dukhovni at 2021-06-24T12:04:54-04:00 There's no "errorWithCallStack", just use "error". There's no `errorWithCallStack`, only `errorWithStackTrace`, but the latter is now deprecated, since `error` now defaults to returning a stack strace. So rather than change this to the intended deprecated function we replace `errorWithCallStack` with `error` instead. - - - - - 4d5967b5 by Krzysztof Gogolewski at 2021-06-24T20:35:56-04:00 Fixes around incomplete guards (#20023, #20024) - Fix linearity error with incomplete MultiWayIf (#20023) - Fix partial pattern binding error message (#20024) - Remove obsolete test LinearPolyTest It tested the special typing rule for ($), which was removed during the implementation of Quick Look 97cff9190d3. - Fix ticket numbers in linear/*/all.T, they referred to linear types issue tracker - - - - - c1c29808 by Christian Takle at 2021-06-24T20:36:32-04:00 Update quantified_constraints.rst - - - - - 1c811959 by Moritz Angermann at 2021-06-24T20:37:07-04:00 [iserv] learn -wait cli flag Often times when attaching a debugger to iserv it's helpful to have iserv wait a few seconds for the debugger to attach. -wait can be passed via -opti-wait if needed. - - - - - f926ecfd by Matthew Pickering at 2021-06-24T20:37:42-04:00 linker: Replace one missed usage of Opt_RPath with useXLinkerRPath Thanks to @wz1000 for spotting this oversight. - - - - - fa6451b7 by Luite Stegeman at 2021-06-24T20:38:18-04:00 fix sdist for base library config.sub and config.guess aren't used anymore, so they should be removed from the base.cabal file - - - - - d1f59540 by sheaf at 2021-06-25T05:19:18-04:00 Make reallyUnsafePtrEquality# levity-polymorphic fixes #17126, updates containers submodule - - - - - 30afb381 by Matthew Pickering at 2021-06-25T05:19:53-04:00 ghci: Add test for #18330 This test was fixed by 25977ab542a30df4ae71d9699d015bcdd1ab7cfb Fixes #18330 - - - - - f43a11d7 by Matthew Pickering at 2021-06-25T05:19:53-04:00 driver: Add test for #17481 Fixed in 25977ab542a30df4ae71d9699d015bcdd1ab7cfb Fixes #17481 - - - - - eb39981a by Matthew Pickering at 2021-06-25T05:19:53-04:00 driver: Add test for T14923 - - - - - 83dce402 by Zubin Duggal at 2021-06-25T05:20:27-04:00 Add regression test for #19921 - - - - - 0bb78838 by Vladislav Zavialov at 2021-06-25T15:41:24-04:00 Suggest similar names when reporting types in terms (#19978) This fixes an error message regression. - - - - - 6cc80766 by Matthew Pickering at 2021-06-25T15:41:58-04:00 driver: Add implicit package dependencies for template-haskell package When TemplateHaskellQuotes is enabled, we also generate programs which mention symbols from the template-haskell module. So that package is added conditionally if the extension is turned on. We should really do the same for other wired-in packages: * base * ghc-bignum * ghc-prim * rts When we link an executable, we must also link against these libraries. In accordance with every other package, these dependencies should be added into the direct dependencies for a module automatically and end up in the interface file to record the fact the object file was created by linking against these packages. Unfortunately it is not so easy to work out when symbols from each of these libraries ends up in the generated program. You might think that `base` would always be used but the `ghc-prim` package doesn't depend on `base`, so you have to be a bit careful and this futher enhancement is left to a future patch. - - - - - 221a104f by GHC GitLab CI at 2021-06-26T22:42:03-04:00 codeGen: Fix header size for array write barriers Previously the code generator's logic for invoking the nonmoving write barrier was inconsistent with the write barrier itself. Namely, the code generator treated the header size argument as being in words whereas the barrier expected bytes. This was the cause of #19715. Fixes #19715. - - - - - 30f233fe by GHC GitLab CI at 2021-06-26T22:42:03-04:00 rts: Eliminate redundant branch Previously we branched unnecessarily on IF_NONMOVING_WRITE_BARRIER_ENABLED on every trip through the array barrier push loop. - - - - - 9b776cbb by sheaf at 2021-06-26T22:42:39-04:00 Re-export UnliftedRep and UnliftedType from GHC.Exts - - - - - b1792fef by Zubin Duggal at 2021-06-27T06:14:36-04:00 user-guide: Improve documentation of NumDecimals - - - - - 3e71874b by Jakob Brünker at 2021-06-27T06:15:11-04:00 Tc: Allow Typeable in quantified constraints Previously, when using Typeable in a quantified constraint, GHC would complain that user-specified instances of Typeable aren't allowed. This was because checking for SigmaCtxt was missing from a check for whether an instance head is a hand-written binding. Fixes #20033 - - - - - d7758da4 by Sebastian Graf at 2021-06-27T14:57:39-04:00 Simplifier: Do Cast W/W for INLINE strong loop-breakers Strong loop-breakers never inline, INLINE pragma or not. Hence they should be treated as if there was no INLINE pragma on them. Also not doing Cast W/W for INLINE strong loop-breakers will trip up Strictness W/W, because it treats them as if there was no INLINE pragma. Subsequently, that will lead to a panic once Strictness W/W will no longer do eta-expansion, as we discovered while implementing !5814. I also renamed to `unfoldingInfo` to `realUnfoldingInfo` and redefined `unfoldingInfo` to zap the unfolding it returns in case of a strong loop-breaker. Now the naming and semantics is symmetrical to `idUnfolding`/`realIdUnfolding`. Now there was no more reason for `hasInlineUnfolding` to operate on `Id`, because the zapping of strong loop-breaker unfoldings moved from `idUnfolding` to `unfoldingInfo`, so I refactored it to take `IdInfo` and call it both from the Simplifier and WorkWrap, making it utterly clear that both checks are equivalent. - - - - - eee498bf by Sebastian Graf at 2021-06-27T14:57:39-04:00 WorkWrap: Remove mkWWargs (#19874) `mkWWargs`'s job was pushing casts inwards and doing eta expansion to match the arity with the number of argument demands we w/w for. Nowadays, we use the Simplifier to eta expand to arity. In fact, in recent years we have even seen the eta expansion done by w/w as harmful, see Note [Don't eta expand in w/w]. If a function hasn't enough manifest lambdas, don't w/w it! What purpose does `mkWWargs` serve in this world? Not a great one, it turns out! I could remove it by pulling some important bits, notably Note [Freshen WW arguments] and Note [Join points and beta-redexes]. Result: We reuse the freshened binder names of the wrapper in the worker where possible (see testuite changes), much nicer! In order to avoid scoping errors due to lambda-bound unfoldings in worker arguments, we zap those unfoldings now. In doing so, we fix #19766. Fixes #19874. - - - - - 37472a10 by Sebastian Graf at 2021-06-27T14:57:39-04:00 WorkWrap: Make mkWWstr and mkWWcpr generate fewer let bindings In https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5814#note_355144, Simon noted that `mkWWstr` and `mkWWcpr` could generate fewer let bindings and be implemented less indirectly by returning the rebuilt expressions directly, e.g. instead of ``` f :: (Int, Int) -> Int f (x, y) = x+y ==> f :: (Int, Int) -> Int f p = case p of (x, y) -> case x of I# x' -> case y of I# y' -> case $wf x' y' of r' -> let r = I# r' -- immediately returned in r f :: Int# -> Int# -> Int# $wf x' y' = let x = I# x' in -- only used in p let y = I# y' in -- only used in p let p = (x, y) in -- only used in the App below case (\(x,y) -> x+y) p of I# r' -> r' ``` we know generate ``` f :: (Int, Int) -> Int f p = case p of (x, y) -> case x of I# x' -> case y of I# y' -> case $wf x' y' of r' -> I# r' -- 1 fewer let f :: Int# -> Int# -> Int# $wf x' y' = case (\(x,y) -> x+y) (I# x, I# y) of I# r' -> -- 3 fewer lets r' ``` Which is much nicer and makes it easier to comprehend the output of worker-wrapper pre-Simplification as well as puts less strain on the Simplifier. I had to drop support for #18983, but we found that it's broken anyway. Simon is working on a patch that provides a bit more justification. - - - - - e69d070b by Sebastian Graf at 2021-06-27T14:57:39-04:00 Add regression test for #17819 The only item left in #17819. Fixes #17819. - - - - - b92479f9 by Sebastian Graf at 2021-06-27T14:57:39-04:00 Inliner: Regard LitRubbish as TrivArg and not ConLike Part of fixing #19766 required the emission of `LitRubbish` as absent filler in places where we used `absentError` before. In WWRec we have the situation that such bindings occur in the argument to functions. With `LitRubbish` we inlined those functions, because 1. The absent binding was regarded as ConLike. So I fixed `exprIsHNFLike` to respond `False` to `LitRubbish`. 2. The other source of inlining was that after inlining such an absent binding, `LitRubbish` itself was regarded `ValueArg` by `interestingArg`, leading to more inlining. It now responds `TrivArg` to `LitRubbish`. Fixes #20035. There's one slight 1.6% ghc/alloc regression left in T15164 that is due to an additional specialisation `$s$cget`. I've no idea why that happens; the Core output before is identical and has the call site that we specialise for. Metric Decrease: WWRec - - - - - 43bbf4b2 by Sebastian Graf at 2021-06-27T14:57:39-04:00 testsuite: Widen acceptance window of T12545 (#19414) In a sequel of #19414, I wrote a script that measures min and max allocation bounds of T12545 based on randomly modifying -dunique-increment. I got a spread of as much as 4.8%. But instead of widening the acceptance window further (to 5%), I committed the script as part of this commit, so that false positive increases can easily be diagnosed by comparing min and max bounds to HEAD. Indeed, for !5814 we have seen T12545 go from -0.3% to 3.3% after a rebase. I made sure that the min and max bounds actually stayed the same. In the future, this kind of check can very easily be done in a matter of a minute. Maybe we should increase the acceptance threshold if we need to check often (leave a comment on #19414 if you had to check), but I've not been bitten by it for half a year, which seems OK. Metric Increase: T12545 - - - - - 469126b3 by Matthew Pickering at 2021-06-27T14:58:14-04:00 Revert "Make reallyUnsafePtrEquality# levity-polymorphic" This reverts commit d1f59540e8b7be96b55ab4b286539a70bc75416c. This commit breaks the build of unordered-containers ``` [3 of 9] Compiling Data.HashMap.Internal.Array ( Data/HashMap/Internal/Array.hs, dist/build/Data/HashMap/Internal/Array.o, dist/build/Data/HashMap/Internal/Array.dyn_o ) *** Parser [Data.HashMap.Internal.Array]: Parser [Data.HashMap.Internal.Array]: alloc=21043544 time=13.621 *** Renamer/typechecker [Data.HashMap.Internal.Array]: Renamer/typechecker [Data.HashMap.Internal.Array]: alloc=151218672 time=187.083 *** Desugar [Data.HashMap.Internal.Array]: ghc: panic! (the 'impossible' happened) GHC version 9.3.20210625: expectJust splitFunTy CallStack (from HasCallStack): error, called at compiler/GHC/Data/Maybe.hs:68:27 in ghc:GHC.Data.Maybe expectJust, called at compiler/GHC/Core/Type.hs:1247:14 in ghc:GHC.Core.Type ``` Revert containers submodule update - - - - - 46c2d0b0 by Peter Trommler at 2021-06-28T10:45:54-04:00 Fix libffi on PowerPC Update submodule libffi-tarballs to upstream commit 4f9e20a. Remove C compiler flags that suppress warnings in the RTS. Those warnings have been fixed by libffi upstream. Fixes #19885 - - - - - d4c43df1 by Zubin Duggal at 2021-06-28T10:46:29-04:00 Update docs for change in parsing behaviour of infix operators like in GHC 9 - - - - - 755cb2b0 by Alfredo Di Napoli at 2021-06-28T16:57:28-04:00 Try to simplify zoo of functions in `Tc.Utils.Monad` This commit tries to untangle the zoo of diagnostic-related functions in `Tc.Utils.Monad` so that we can have the interfaces mentions only `TcRnMessage`s while we push the creation of these messages upstream. It also ports TcRnMessage diagnostics to use the new API, in particular this commit switch to use TcRnMessage in the external interfaces of the diagnostic functions, and port the old SDoc to be wrapped into TcRnUnknownMessage. - - - - - a7f9670e by Ryan Scott at 2021-06-28T16:58:03-04:00 Fix type and strictness signature of forkOn# This is a follow-up to #19992, which fixes the type and strictness signature for `fork#`. The `forkOn#` primop also needs analogous changes, which this patch accomplishes. - - - - - b760c1f7 by Sebastian Graf at 2021-06-29T15:35:29-04:00 Demand: Better representation (#19050) In #19050, we identified several ways in which we could make more illegal states irrepresentable. This patch introduces a few representation changes around `Demand` and `Card` with a better and earlier-failing API exported through pattern synonyms. Specifically, 1. The old enum definition of `Card` led to severely bloated code of operations on it. I switched to a bit vector representation; much nicer overall IMO. See Note [Bit vector representation for Card]. Most of the gripes with the old representation were related to where which kind of `Card` was allowed and the fact that it doesn't make sense for an absent or bottoming demand to carry a `SubDemand` that describes an evaluation context that is never realised. 2. So I refactored the `Demand` representation so that it has two new data constructors for `AbsDmd` and `BotDmd`. The old `(:*)` data constructor becomes a pattern synonym which expands absent demands as needed, so that it still forms a complete match and a versatile builder. The new `Demand` data constructor now carries a `CardNonAbs` and only occurs in a very limited number of internal call sites. 3. Wherever a full-blown `Card` might end up in a `CardNonAbs` field (like that of `D` or `Call`), I assert the consistency. When the smart builder of `(:*)` is called with an absent `Card`, I assert that the `SubDemand` is the same that we would expand to in the matcher. 4. `Poly` now takes a `CardNonOnce` and encodes the previously noticed invariant that we never produce `Poly C_11` or `Poly C_01`. I made sure that we never construct a `Poly` with `C_11` or `C_01`. Fixes #19050. We lose a tiny bit of anal perf overall, probably because the new `Demand` definition can't be unboxed. The biggest loser is WWRec, where allocations go from 16MB to 26MB in DmdAnal, making up for a total increase of (merely) 1.6%. It's all within acceptance thresholds. There are even two ghc/alloc metric decreases. T11545 decreases by *67%*! Metric Decrease: T11545 T18304 - - - - - 4e9f58c7 by sheaf at 2021-06-29T15:36:08-04:00 Use HsExpansion for overloaded list patterns Fixes #14380, #19997 - - - - - 2ce7c515 by Matthew Pickering at 2021-06-29T15:36:42-04:00 ci: Don't allow aarch64-darwin to fail Part way to #20013 - - - - - f79615d2 by Roland Senn at 2021-07-01T03:29:58-04:00 Add testcase for #19460 Avoid an other regression. - - - - - b51b4b97 by Sylvain Henry at 2021-07-01T03:30:36-04:00 Make withException use SDocContext instead of DynFlags - - - - - 6f097a81 by Sylvain Henry at 2021-07-01T03:30:36-04:00 Remove useless .hs-boot - - - - - 6d712150 by Sylvain Henry at 2021-07-01T03:30:36-04:00 Dynflags: introduce DiagOpts Use DiagOpts for diagnostic options instead of directly querying DynFlags (#17957). Surprising performance improvements on CI: T4801(normal) ghc/alloc 313236344.0 306515216.0 -2.1% GOOD T9961(normal) ghc/alloc 384502736.0 380584384.0 -1.0% GOOD ManyAlternatives(normal) ghc/alloc 797356128.0 786644928.0 -1.3% ManyConstructors(normal) ghc/alloc 4389732432.0 4317740880.0 -1.6% T783(normal) ghc/alloc 408142680.0 402812176.0 -1.3% Metric Decrease: T4801 T9961 T783 ManyAlternatives ManyConstructors Bump haddock submodule - - - - - d455c39e by Emily Martins at 2021-07-01T03:31:13-04:00 Unify primary and secondary GHCi prompt Fixes #20042 Signed-off-by: Emily Martins <emily.flakeheart at gmail.com> Signed-off-by: Hécate Moonlight <hecate at glitchbra.in> - - - - - 05ae4772 by Emily Martins at 2021-07-01T03:31:13-04:00 Unify remaining GHCi prompt example Signed-off-by: Emily Martins <emily.flakeheart at gmail.com> - - - - - c22761fa by Moritz Angermann at 2021-07-01T03:31:48-04:00 [ci] don't allow aarch64-linux (ncg) to fail by accepting the current state of metrics (and the NCG is new, so this seems prudent to do), we can require aarch64-linux (ncg) to build without permitting failure. Metric Increase: T13035 T13719 T14697 T1969 T9203 T9872a T9872b T9872c T9872d T9961 WWRec haddock.Cabal haddock.base parsing001 - - - - - 82e6a4d2 by Moritz Angermann at 2021-07-01T03:31:48-04:00 [ci] Separate llvm and NCG test metrics for aarch64-linux - - - - - e8192ae4 by Moritz Angermann at 2021-07-01T03:31:48-04:00 [Parser: Lexer] Fix !6132 clang's cpp injects spaces prior to #!/. - - - - - 66bd5931 by Moritz Angermann at 2021-07-01T03:31:48-04:00 [ci] Enable T6132 across all targets We should have fixed clangs mess now. - - - - - 66834286 by Marco Zocca at 2021-07-01T10:23:52+00:00 float out some docstrings and comment some function parameters - - - - - a3c451be by Roland Senn at 2021-07-01T16:05:21-04:00 Remove redundant test case print036. The test case `print036` was marked `broken` by #9046. Issue #9046 is a duplicate of #12449. However the test case `T12449` contains several test that are similar to those in `print036`. Hence test case `print036` is redundant and can be deleted. - - - - - 6ac9ea86 by Simon Peyton Jones at 2021-07-02T00:27:04-04:00 One-shot changes (#20008) I discovered that GHC.Core.Unify.bindTv was getting arity 2, rather than 3, in one of my builds. In HEAD it does get the right arity, but only because CallArity (just) manages to spot it. In my situation it (just) failed to discover this. Best to make it robust, which this patch does. See Note [INLINE pragmas and (>>)] in GHC.Utils.Monad. There a bunch of other modules that probably should have the same treatment: GHC.CmmToAsm.Reg.Linear.State GHC.Tc.Solver.Monad GHC.Tc.Solver.Rewrite GHC.Utils.Monad.State.Lazy GHC.Utils.Monad.State.Strict but doing so is not part of this patch - - - - - a820f900 by Sylvain Henry at 2021-07-02T00:27:42-04:00 Detect underflow in fromIntegral/Int->Natural rule Fix #20066 - - - - - bb716a93 by Viktor Dukhovni at 2021-07-02T04:28:34-04:00 Fix cut/paste typo foldrM should be foldlM - - - - - 39d665e4 by Moritz Angermann at 2021-07-02T04:29:09-04:00 Revert "Move validate-x86_64-linux-deb9-hadrian back to quick-build" This reverts commit a0622459f1d9a7068e81b8a707ffc63e153444f8. - - - - - c1c98800 by Moritz Angermann at 2021-07-02T04:29:09-04:00 Move aarch64-linux-llvm to nightly This job takes by far the longest time on its own, we now have a NCG. Once we have fast aarch64 machines, we can consider putting this one back. - - - - - 5e30451d by Luite Stegeman at 2021-07-02T23:24:38-04:00 Support unlifted datatypes in GHCi fixes #19628 - - - - - 9b1d9cbf by Sebastian Graf at 2021-07-02T23:25:13-04:00 Arity: Handle shadowing properly In #20070, we noticed that `findRhsArity` copes badly with shadowing. A simple function like `g_123 x_123 = x_123`, where the labmda binder shadows, already regressed badly. Indeed, the whole `arityType` function wasn't thinking about shadowing *at all*. I rectified that and established the invariant that `ae_join` and `am_sigs` should always be disjoint. That entails deleting bindings from `ae_join` whenever we add something to `am_sigs` and vice versa, which would otherwise be a bug in the making. That *should* fix (but I don't want to close it) #20070. - - - - - 4b4c5e43 by Fraser Tweedale at 2021-07-06T13:36:46-04:00 Implement improved "get executable path" query System.Environment.getExecutablePath has some problems: - Some system-specific implementations throw an exception in some scenarios, e.g. when the executable file has been deleted - The Linux implementation succeeds but returns an invalid FilePath when the file has been deleted. - The fallback implementation returns argv[0] which is not necessarily an absolute path, and is subject to manipulation. - The documentation does not explain any of this. Breaking the getExecutablePath API or changing its behaviour is not an appealing direction. So we will provide a new API. There are two facets to the problem of querying the executable path: 1. Does the platform provide a reliable way to do it? This is statically known. 2. If so, is there a valid answer, and what is it? This may vary, even over the runtime of a single process. Accordingly, the type of the new mechanism is: Maybe (IO (Maybe FilePath)) This commit implements this mechanism, defining the query action for FreeBSD, Linux, macOS and Windows. Fixes: #10957 Fixes: #12377 - - - - - a4e742c5 by Fraser Tweedale at 2021-07-06T13:36:46-04:00 Add test for executablePath - - - - - 4002bd1d by Ethan Kiang at 2021-07-06T13:37:24-04:00 Pass '-x c++' and '-std=c++11' to `cc` for cpp files, in Hadrian '-x c++' was found to be required on Darwin Clang 11 and 12. '-std=c++' was found to be needed on Clang 12 but not 11. - - - - - 354ac99d by Sylvain Henry at 2021-07-06T13:38:06-04:00 Use target platform in guessOutputFile - - - - - 17091114 by Edward at 2021-07-06T13:38:42-04:00 Fix issue 20038 - Change 'variable' -> 'variables' - - - - - 6618008b by Andreas Klebinger at 2021-07-06T21:17:37+00:00 Fix #19889 - Invalid BMI2 instructions generated. When arguments are 8 *or 16* bits wide, then truncate before/after and use the 32bit operation. - - - - - 421beb3f by Matthew Pickering at 2021-07-07T11:56:36-04:00 driver: Convert runPipeline to use a free monad This patch converts the runPipeline function to be implemented in terms of a free monad rather than the previous CompPipeline. The advantages of this are three-fold: 1. Different parts of the pipeline can return different results, the limits of runPipeline were being pushed already by !5555, this opens up futher fine-grainedism of the pipeline. 2. The same mechanism can be extended to build-plan at the module level so the whole build plan can be expressed in terms of one computation which can then be treated uniformly. 3. The pipeline monad can now be interpreted in different ways, for example, you may want to interpret the `TPhase` action into the monad for your own build system (such as shake). That bit will probably require a bit more work, but this is a step in the right directin. There are a few more modules containing useful functions for interacting with the pipelines. * GHC.Driver.Pipeline: Functions for building pipelines at a high-level * GHC.Driver.Pipeline.Execute: Functions for providing the default interpretation of TPhase, in terms of normal IO. * GHC.Driver.Pipeline.Phases: The home for TPhase, the typed phase data type which dictates what the phases are. * GHC.Driver.Pipeline.Monad: Definitions to do with the TPipelineClass and MonadUse class. Hooks consumers may notice the type of the `phaseHook` has got slightly more restrictive, you can now no longer control the continuation of the pipeline by returning the next phase to execute but only override individual phases. If this is a problem then please open an issue and we will work out a solution. ------------------------- Metric Decrease: T4029 ------------------------- - - - - - 5a31abe3 by Matthew Pickering at 2021-07-07T11:56:36-04:00 driver: Add test for #12983 This test has worked since 8.10.2 at least but was recently broken and is now working again after this patch. Closes #12983 - - - - - 56eb57a6 by Alfredo Di Napoli at 2021-07-08T08:13:23+02:00 Rename getErrorMessages and getMessages function in parser code This commit renames the `getErrorMessages` and `getMessages` function in the parser code to `getPsErrorMessages` and `getPsMessages`, to avoid import conflicts, as we have already `getErrorMessages` and `getMessages` defined in `GHC.Types.Error`. Fixes #19920. Update haddock submodule - - - - - 82284ba1 by Matthew Pickering at 2021-07-09T08:46:09-04:00 Remove reqlib from cgrun025 test - - - - - bc38286c by Matthew Pickering at 2021-07-09T08:46:09-04:00 Make throwto002 a normal (not reqlib) test - - - - - 573012c7 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add the TcRnShadowedName constructor to TcRnMessage This commit adds the TcRnShadowedName to the TcRnMessage type and it uses it in GHC.Rename.Utils. - - - - - 55872423 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add the TcRnDuplicateWarningDecls to TcRnMessage - - - - - 1e805517 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnSimplifierTooManyIterations to TcRnMessage - - - - - bc2c00dd by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalPatSynDecl to TcRnMessage - - - - - 52353476 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnEmptyRecordUpdate to TcRnMessage - - - - - f0a02dcc by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalFieldPunning to TcRnMessage - - - - - 5193bd06 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalWildCardsInRecord to TcRnMessage - - - - - e17850c4 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnDuplicateFieldName to TcRnMessage - - - - - 6b4f3a99 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalViewPattern to TcRnMessage - - - - - 8d28b481 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnCharLiteralOutOfRange to TcRnMessage - - - - - 64e20521 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Remove redundant patSigErr - - - - - 60fabd7e by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalWildcardsInConstructor to TcRnMessage - - - - - 2d4cdfda by Sylvain Henry at 2021-07-09T08:47:22-04:00 Avoid unsafePerformIO for getProgName getProgName was used to append the name of the program (e.g. "ghc") to printed error messages in the Show instance of GhcException. It doesn't belong here as GHCi and GHC API users may want to override this behavior by setting a different error handler. So we now call it in the defaultErrorHandler instead. - - - - - 901f0e1b by sheaf at 2021-07-10T13:29:03+02:00 Don't return unitExpr in dsWhenNoErrs - fixes #18149 and #14765 dsWhenNoErrs now returns "runtimeError @ty" when disallowed representation polymorphism is detected, where ty is the type of the result CoreExpr. "ty" is passed as an additional argument to dsWhenNoErrs, and is used only in the case of such an error. The calls to dsWhenNoErrs must now compute the type of the CoreExpr they are trying to build, so that an error of the right type can be used in case of a representation polymorphism failure. - - - - - c38bce73 by Matthew Pickering at 2021-07-10T19:59:34-04:00 ci: Copy the cache from inside the nix-shell where $HOME is different on darwin Hopefully fixes the flaky CI failures we have seen recently. Co-authored-by: Moritz Angerman <moritz.angermann at gmail.com> - - - - - a181313e by Alfredo Di Napoli at 2021-07-12T14:19:22+02:00 Add proper GHCHints for most PsMessage constructors This commit adds proper hints to most diagnostic types in the `GHC.Parser.Errors.Types` module. By "proper" we mean that previous to this commit the hints were bundled together with the diagnostic message, whereas now we moved most of them as proper `[GhcHint]` in the implementation of `diagnosticHints`. More specifically, this is the list of constructors which now has proper hints: * PsErrIllegalBangPattern * PsWarnOperatorWhitespaceExtConflict * PsErrLambdaCase * PsErrIllegalPatSynExport * PsWarnOperatorWhitespace * PsErrMultiWayIf * PsErrIllegalQualifiedDo * PsErrNumUnderscores * PsErrLinearFunction * PsErrIllegalTraditionalRecordSyntax * PsErrIllegalExplicitNamespace * PsErrOverloadedRecordUpdateNotEnabled * PsErrIllegalDataTypeContext * PsErrSemiColonsInCondExpr * PsErrSemiColonsInCondCmd * PsWarnStarIsType * PsWarnImportPreQualified * PsErrImportPostQualified * PsErrEmptyDoubleQuotes * PsErrIllegalRoleName * PsWarnStarBinder For some reason, this patch increases the peak_megabyte_allocated of the T11545 test to 90 (from a baseline of 80) but that particular test doesn't emit any parsing diagnostic or hint and the metric increase happens only for the `aarch64-linux-deb10`. Metric Increase: T11545 - - - - - aef7d513 by Matthew Pickering at 2021-07-13T15:16:19-04:00 driver: Fix interaction of -Wunused-packages and reexported-modules Spurious warnings were previously emitted if an import came from a reexport due to how -Wunused-packages were implemented. Removing the dependency would cause compilation to fail. The fix is to reimplement the warning a bit more directly, by searching for which package each import comes from using the normal module finding functions rather than consulting the EPS. This has the advantage that the check could be performed at any time after downsweep rather than also relying on a populated EPS. Fixes #19518 and #19777 - - - - - bb8e0df8 by Adrien at 2021-07-13T15:16:56-04:00 Added a hopefully clarificatory sentence about the notion of "atomicity" presupposed in the documentation on MVar. - - - - - 99921593 by Zubin Duggal at 2021-07-13T20:45:44+00:00 Don't panic on 'no skolem info' and add failing tests - - - - - de98a0ce by Sylvain Henry at 2021-07-15T23:29:09-04:00 Additional constant-folding rule for binary AND/OR Add a constant folding rule allowing the subsumption of an application if the same argument is applied twice, e.g. (v .&. 0xFF) .&. 0xFF ~~> v .&. 0xFF (v .|. 0xFF) .|. 0xFF ~~> v .|. 0xFF - - - - - 41d6cfc4 by Sylvain Henry at 2021-07-15T23:29:09-04:00 Add Word64#/Int64# primops Word64#/Int64# are only used on 32-bit architectures. Before this patch, operations on these types were directly using the FFI. Now we use real primops that are then lowered into ccalls. The advantage of doing this is that we can now perform constant folding on Word64#/Int64# (#19024). Most of this work was done by John Ericson in !3658. However this patch doesn't go as far as e.g. changing Word64 to always be using Word64#. Noticeable performance improvements T9203(normal) run/alloc 89870808.0 66662456.0 -25.8% GOOD haddock.Cabal(normal) run/alloc 14215777340.8 12780374172.0 -10.1% GOOD haddock.base(normal) run/alloc 15420020877.6 13643834480.0 -11.5% GOOD Metric Decrease: T9203 haddock.Cabal haddock.base - - - - - 5b187575 by Simon Peyton Jones at 2021-07-19T10:59:38+01:00 Better sharing of join points (#19996) This patch, provoked by regressions in the text package (#19557), improves sharing of join points. This also fixes the terrible behaviour in #20049. See Note [Duplicating join points] in GHC.Core.Opt.Simplify. * In the StrictArg case of mkDupableContWithDmds, don't use Plan A for data constructors * In postInlineUnconditionally, don't inline JoinIds Avoids inlining join $j x = Just x in case blah of A -> $j x1 B -> $j x2 C -> $j x3 * In mkDupableStrictBind and mkDupableStrictAlt, create join points (much) more often: exprIsTrivial rather than exprIsDupable. This may be much, but we'll see. Metric Decrease: T12545 T13253-spj T13719 T18140 T18282 T18304 T18698a T18698b Metric Increase: T16577 T18923 T9961 - - - - - e5a4cfa5 by Sylvain Henry at 2021-07-19T19:36:37-04:00 Bignum: don't allocate in bignat_mul (#20028) We allocated the recursively entered `mul` helper function because it captures some args. - - - - - 952ba18e by Matthew Pickering at 2021-07-19T19:37:12-04:00 th: Weaken return type of myCoreToStgExpr The previous code assumed properties of the CoreToStg translation, namely that a core let expression which be translated to a single non-recursive top-level STG binding. This assumption was false, as evidenced by #20060. The consequence of this was the need to modify the call sites of `myCoreToStgExpr`, the main one being in hscCompileCoreExpr', which the meant we had to use byteCodeGen instead of stgExprToBCOs to convert the returned value to bytecode. I removed the `stgExprToBCOs` function as it is no longer used in the compiler. There is still some partiallity with this patch (the lookup in hscCompileCoreExpr') but this should be more robust that before. Fixes #20060 - - - - - 3e8b39ea by Alfredo Di Napoli at 2021-07-19T19:37:47-04:00 Rename RecordPuns to NamedFieldPuns in LangExt.Extension This commit renames the `RecordPuns` type constructor inside `GHC.LanguageExtensions.Type.hs` to `NamedFieldPuns`. The rationale is that the `RecordPuns` language extension was deprecated a long time ago, but it was still present in the AST, introducing an annoying mismatch between what GHC suggested (i.e. "use NamedFieldPuns") and what that translated into in terms of Haskell types. - - - - - 535123e4 by Simon Peyton Jones at 2021-07-19T19:38:21-04:00 Don't duplicate constructors in the simplifier Ticket #20125 showed that the Simplifier could sometimes duplicate a constructor binding. CSE would often eliminate it later, but doing it in the first place was utterly wrong. See Note [Do not duplicate constructor applications] in Simplify.hs I also added a short-cut to Simplify.simplNonRecX for the case when the RHS is trivial. I don't think this will change anything, just make the compiler run a tiny bit faster. - - - - - 58b960d2 by Sylvain Henry at 2021-07-19T19:38:59-04:00 Make TmpFs independent of DynFlags This is small step towards #19877. We want to make the Loader/Linker interface more abstract to be easily reused (i.e. don't pass it DynFlags) but the system linker uses TmpFs which required a DynFlags value to get its temp directory. We explicitly pass the temp directory now. Similarly TmpFs was consulting the DynFlags to decide whether to clean or: this is now done by the caller in the driver code. - - - - - d706fd04 by Matthew Pickering at 2021-07-20T09:22:46+01:00 hadrian: Update docs targets documentation [skip ci] The README had got a little out of sync with the current state of affairs. - - - - - 9eb1641e by Matthew Pickering at 2021-07-21T02:45:39-04:00 driver: Fix recompilation for modules importing GHC.Prim The GHC.Prim module is quite special as there is no interface file, therefore it doesn't appear in ms_textual_imports, but the ghc-prim package does appear in the direct package dependencies. This confused the recompilation checking which couldn't find any modules from ghc-prim and concluded that the package was no longer a dependency. The fix is to keep track of whether GHC.Prim is imported separately in the relevant places. Fixes #20084 - - - - - 06d1ca85 by Alfredo Di Napoli at 2021-07-21T02:46:13-04:00 Refactor SuggestExtension constructor in GhcHint This commit refactors the SuggestExtension type constructor of the GhcHint to be more powerful and flexible. In particular, we can now embed extra user information (essentially "sugar") to help clarifying the suggestion. This makes the following possible: Suggested fix: Perhaps you intended to use GADTs or a similar language extension to enable syntax: data T where We can still give to IDEs and tools a `LangExt.Extension` they can use, but in the pretty-printed message we can tell the user a bit more on why such extension is needed. On top of that, we now have the ability to express conjuctions and disjunctons, for those cases where GHC suggests to enable "X or Y" and for the cases where we need "X and Y". - - - - - 5b157eb2 by Fendor at 2021-07-21T02:46:50-04:00 Use Ways API instead of Set specific functions - - - - - 10124b16 by Mario Blažević at 2021-07-21T02:47:25-04:00 template-haskell: Add support for default declarations Fixes #19373 - - - - - 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`. - - - - - 3820387b by Ben Gamari at 2022-08-25T10:08:03-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 46101141 by Ben Gamari at 2022-08-25T10:08:11-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - 3b0785ca by Ben Gamari at 2022-08-25T10:08:11-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 2be785d1 by Ben Gamari at 2022-08-25T10:08:11-04:00 rts: Refactor IPE tracing support - - - - - 80f59ae4 by Ben Gamari at 2022-08-25T15:34:35-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. - - - - - f932de0a by Ben Gamari at 2022-08-25T15:34:35-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. - - - - - 1067ea6f by Ben Gamari at 2022-09-05T13:05:16-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`. - - - - - 16 changed files: - + .editorconfig - .ghcid - + .git-ignore-revs - .gitattributes - .gitignore - .gitlab-ci.yml - + .gitlab/ci.sh - + .gitlab/common.sh - − .gitlab/darwin-init.sh - + .gitlab/darwin/nix/sources.json - + .gitlab/darwin/nix/sources.nix - + .gitlab/darwin/toolchain.nix - + .gitlab/gen_ci.hs - + .gitlab/generate_jobs - + .gitlab/issue_templates/documentation_issue.md - .gitlab/issue_templates/feature_request.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e600bc3b6e179d1040bdb09e395e1f718ad87017...1067ea6f7f252ee28838305c26ce412136e59b44 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e600bc3b6e179d1040bdb09e395e1f718ad87017...1067ea6f7f252ee28838305c26ce412136e59b44 You're receiving 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 Sep 5 17:10:27 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Sep 2022 13:10:27 -0400 Subject: [Git][ghc/ghc][wip/fix-ci] 27 commits: Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <63162d83bb3c_2f2e5813a03c9c1577521@gitlab.mail> Ben Gamari pushed to branch wip/fix-ci at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1f72693c by Ben Gamari at 2022-09-05T13:10:21-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`. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − bindisttest/ghc.mk - boot - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatOut.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1067ea6f7f252ee28838305c26ce412136e59b44...1f72693cfb48af543977b4d8a7534e5381d986de -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1067ea6f7f252ee28838305c26ce412136e59b44...1f72693cfb48af543977b4d8a7534e5381d986de You're receiving 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 Sep 5 21:30:08 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Sep 2022 17:30:08 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Change Ord defaults per CLC proposal Message-ID: <63166a604c772_869eb514a0385c9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 7352946e by Sebastian Graf at 2022-09-05T17:29:47-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. - - - - - 7bd21f2e by Ben Gamari at 2022-09-05T17:29:48-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`. - - - - - 8 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - docs/users_guide/9.6.1-notes.rst - libraries/base/changelog.md - libraries/ghc-prim/GHC/Classes.hs - + testsuite/tests/stranal/should_compile/T22039.hs - testsuite/tests/stranal/should_compile/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -267,7 +267,7 @@ lint-ci-config: - mkdir -p ~/.cabal - cp -Rf cabal-cache/* ~/.cabal || true script: - - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install -c cabal update + - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install nixpkgs#ghc -c cabal update - .gitlab/generate_jobs # 1 if .gitlab/generate_jobs changed the output of the generated config - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#git -c git diff --exit-code ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -455,8 +455,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) !(!bndrs', !scrut_sd) | DataAlt _ <- alt_con -- See Note [Demand on the scrutinee of a product case] + , let !scrut_sd = scrutSubDmd case_bndr_sd fld_dmds -- See Note [Demand on case-alternative binders] - , (!scrut_sd, fld_dmds') <- addCaseBndrDmd case_bndr_sd fld_dmds + , let !fld_dmds' = fieldBndrDmds scrut_sd (length fld_dmds) , let !bndrs' = setBndrsDemandInfo bndrs fld_dmds' = (bndrs', scrut_sd) | otherwise @@ -560,7 +561,6 @@ forcesRealWorld fam_envs ty = False dmdAnalSumAlts :: AnalEnv -> SubDemand -> Id -> [CoreAlt] -> WithDmdType [CoreAlt] - dmdAnalSumAlts _ _ _ [] = WithDmdType botDmdType [] -- Base case is botDmdType, for empty case alternatives -- This is a unit for lubDmdType, and the right result @@ -580,28 +580,29 @@ 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 = scrutSubDmd case_bndr_sd dmds + dmds' = fieldBndrDmds scrut_sd (length dmds) -- Do not put a thunk into the Alt !new_ids = setBndrsDemandInfo bndrs dmds' = -- pprTrace "dmdAnalSumAlt" (ppr con $$ ppr case_bndr $$ ppr dmd $$ ppr alt_ty) $ 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]) - -- 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 - -- , pprTrace "addCaseBndrDmd" (ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) True - = (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 fld_dmds +scrutSubDmd :: SubDemand -> [Demand] -> SubDemand +scrutSubDmd case_sd fld_dmds = + -- pprTraceWith "scrutSubDmd" (\scrut_sd -> ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) $ + case_sd `plusSubDmd` mkProd Unboxed fld_dmds + +-- See Note [Demand on case-alternative binders] +fieldBndrDmds :: SubDemand -- on the scrutinee + -> Arity + -> [Demand] -- Final demands for the components of the DataCon +fieldBndrDmds scrut_sd n_flds = + case viewProd n_flds scrut_sd of + Just (_, ds) -> ds + Nothing -> replicate n_flds topDmd + -- Either an arity mismatch or scrut_sd was a call demand. + -- See Note [Untyped demand on case-alternative binders] {- Note [Anticipating ANF in demand analysis] @@ -830,6 +831,44 @@ thunk for a let binder that was an an absent case-alt binder during DmdAnal. This is needed even for non-product types, in case the case-binder is used but the components of the case alternative are not. +Note [Untyped demand on case-alternative binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +With unsafeCoerce, #8037 and #22039 taught us that the demand on the case binder +may be a call demand or have a different number of fields than the constructor +of the case alternative it is used in. From T22039: + + blarg :: (Int, Int) -> Int + blarg (x,y) = x+y + -- blarg :: <1!P(1L,1L)> + + f :: Either Int Int -> Int + f Left{} = 0 + f e = blarg (unsafeCoerce e) + ==> { desugars to } + f = \ (ds_d1nV :: Either Int Int) -> + case ds_d1nV of wild_X1 { + Left ds_d1oV -> lvl_s1Q6; + Right ipv_s1Pl -> + blarg + (case unsafeEqualityProof @(*) @(Either Int Int) @(Int, Int) of + { UnsafeRefl co_a1oT -> + wild_X1 `cast` (Sub (Sym co_a1oT) :: Either Int Int ~R# (Int, Int)) + }) + } + +The case binder `e`/`wild_X1` has demand 1!P(1L,1L), with two fields, from the call +to `blarg`, but `Right` only has one field. Although the code will crash when +executed, we must be able to analyse it in 'fieldBndrDmds' and conservatively +approximate with Top instead of panicking because of the mismatch. +In #22039, this kind of code was guarded behind a safe `cast` and thus dead +code, but nevertheless led to a panic of the compiler. + +You might wonder why the same problem doesn't come up when scrutinising a +product type instead of a sum type. It appears that for products, `wild_X1` +will be inlined before DmdAnal. + +See also Note [mkWWstr and unsafeCoerce] for a related issue. + Note [Aggregated demand for cardinality] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FIXME: This Note should be named [LetUp vs. LetDown] and probably predates ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {- ToDo [Oct 2013] ~~~~~~~~~~~~~~~ @@ -974,6 +975,14 @@ lookupHowBound env id = lookupVarEnv (sc_how_bound env) id scSubstId :: ScEnv -> InId -> OutExpr scSubstId env v = lookupIdSubst (sc_subst env) v + +-- Solo is only defined in base starting from ghc-9.2 +#if !(MIN_VERSION_base(4, 16, 0)) + +data Solo a = Solo a + +#endif + -- The !subst ensures that we force the selection `(sc_subst env)`, which avoids -- retaining all of `env` when we only need `subst`. The `Solo` means that the -- substitution itself is lazy, because that type is often discarded. ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -94,6 +94,10 @@ This can be convenient when pasting large multi-line blocks of code into GHCi. label (:base-ref:`GHC.Conc.threadLabel`) and status (:base-ref:`GHC.Conc.threadStatus`). +- Change default ``Ord`` implementation of ``(>=)``, ``(>)``, and ``(<)`` to use + ``(<=)`` instead of ``compare`` per CLC proposal: + https://github.com/haskell/core-libraries-committee/issues/24 + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/changelog.md ===================================== @@ -22,6 +22,9 @@ * `GHC.Conc.Sync.threadLabel` was added, allowing the user to query the label of a given `ThreadId`. * Add `inits1` and `tails1` to `Data.List.NonEmpty`. + * Change default `Ord` implementation of `(>=)`, `(>)`, and `(<)` to use + `(<=)` instead of `compare` per + [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/24). ## 4.17.0.0 *August 2022* ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -333,10 +333,11 @@ class (Eq a) => Ord a where else if x <= y then LT else GT - x < y = case compare x y of { LT -> True; _ -> False } x <= y = case compare x y of { GT -> False; _ -> True } - x > y = case compare x y of { GT -> True; _ -> False } - x >= y = case compare x y of { LT -> False; _ -> True } + x >= y = y <= x + x > y = not (x <= y) + x < y = not (y <= x) + -- These two default methods use '<=' rather than 'compare' -- because the latter is often more expensive ===================================== testsuite/tests/stranal/should_compile/T22039.hs ===================================== @@ -0,0 +1,59 @@ +{-# LANGUAGE ExistentialQuantification #-} + +module Bug where + +import Control.Exception +import Data.Typeable +import Unsafe.Coerce + +data Error + = Error Int String + | forall e . Exception e => SomeError Int e + deriving (Typeable) + +fromError :: Exception e => Error -> Maybe e +fromError e@(Error _ _) = cast e +fromError (SomeError _ e) = cast e +-- {-# NOINLINE fromError #-} + +instance Eq Error where + Error i s == Error i' s' = i == i' && s == s' + SomeError i e == SomeError i' e' = i == i' && show e == show e' + _ == _ = False + +instance Show Error where + show _ = "" + +instance Exception Error + +-- newtype +data + UniquenessError = UniquenessError [((String, String), Int)] + deriving (Show, Eq) + +instance Exception UniquenessError + +test :: SomeException -> IO () +test e = case fromError =<< fromException e :: Maybe UniquenessError of + Just err -> print err + _ -> pure () + +-- +-- Smaller reproducer by sgraf +-- + +blarg :: (Int,Int) -> Int +blarg (x,y) = x+y +{-# NOINLINE blarg #-} + +f :: Either Int Int -> Int +f Left{} = 0 +f e = blarg (unsafeCoerce e) + +blurg :: (Int -> Int) -> Int +blurg f = f 42 +{-# NOINLINE blurg #-} + +g :: Either Int Int -> Int +g Left{} = 0 +g e = blurg (unsafeCoerce e) ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -85,3 +85,4 @@ test('T21150', [ grep_errmsg(r'( t\d? :: Int)') ], compile, ['-dsuppress-uniques test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', '-v0 -dsuppress-uniques -dsuppress-all -ddump-simpl']) test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) +test('T22039', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44a6a9caf7c3c6daa5cd61654046bdc868278953...7bd21f2e8d2424f02152c99f7ae3a381284d066e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44a6a9caf7c3c6daa5cd61654046bdc868278953...7bd21f2e8d2424f02152c99f7ae3a381284d066e You're receiving 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 Sep 5 23:00:28 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 05 Sep 2022 19:00:28 -0400 Subject: [Git][ghc/ghc][wip/T21623] 89 commits: Pmc: consider any 2 dicts of the same type equal Message-ID: <63167f8c37596_869eb5148c43734@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - b06fa8c3 by Simon Peyton Jones at 2022-09-05T20:06:44+01:00 Start work Not ready for review - - - - - c4b59a45 by Simon Peyton Jones at 2022-09-05T20:06:44+01:00 More progress - - - - - 618cb025 by Simon Peyton Jones at 2022-09-05T20:06:44+01:00 Wibbles - - - - - 5f498bdf by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Stage1 compiles - - - - - 92ac4cad by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 More wibbles - - - - - b9f17737 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 More wibbles - - - - - 49783f5b by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 More -- almost working - - - - - 011848ae by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Comments - - - - - 2a8f0d03 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibbles - - - - - 69576ce1 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibbles - - - - - 7029f7d1 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble inlineId - - - - - 501e7a73 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibbles - - - - - a6b061ed by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Infinite loop somewhere - - - - - 1b2b8ba0 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 More wibbles. Maybe can build stage2 - - - - - bb5271d7 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Make FuNCo a thing by itself - - - - - 0d820c27 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble - - - - - bcbd591e by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble - - - - - 30177e05 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibbles - - - - - 36a50ee1 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Fix OptCoercion - - - - - 27879045 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble - - - - - ee2407bf by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble to optCoercion - - - - - f82370c5 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Replace SORT with TYPE and CONSTRAINT - - - - - 07af5c04 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble - - - - - 89ffa253 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Delete unused import - - - - - 160e6dd7 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Delete TypeOrConstraint from ghc-prim:GHC.Types - - - - - 2fe6836c by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Move from NthCo to SelCo - - - - - fc9b6044 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibbles - - - - - 2c8e63e4 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibbles in RepType - - - - - ce819d2b by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Wibble - - - - - 316cc764 by Simon Peyton Jones at 2022-09-05T20:06:45+01:00 Add mkWpEta - - - - - 6d7b37e7 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Really add mkWpEta - - - - - ef2b4dcb by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Wibble Typeable binds etc - - - - - dbadfefa by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Improve error messages - - - - - b19c1fe1 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 More wibbles, mainly to error messages - - - - - 4be94658 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Wibbles - - - - - 8ec0904f by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Wibbles to errors - - - - - 308f5612 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Wibbles But especially: treat Constraint as Typeable - - - - - 6ef5f6a2 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 More wibbles - - - - - 7ffc3a4f by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends - - - - - 99ac0d72 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Unused variable - - - - - de91afaa by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Wibbles - - - - - d49ddb4d by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Wibble - - - - - aa67ee13 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Accept error message changes - - - - - 5f4ba6b3 by Simon Peyton Jones at 2022-09-05T20:06:46+01:00 Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. - - - - - c02392ca by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Introduce GHC.Core.TyCo.Compare Lots of import changes! - - - - - a9dc3187 by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Update haddock submodule (I hope) - - - - - 5b9394a1 by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Wibbles (notably: actually add GHC.Core.TyCo.Compare) - - - - - e1234d76 by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Wibbles - - - - - 22492032 by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Wibble output of T16575 - - - - - 8a4d59db by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Wibbles - - - - - ba47a0f9 by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 More wibbles - - - - - d376886f by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Remove infinite loop in T1946 See Note [ForAllTy and type equality] - - - - - 97c34663 by Simon Peyton Jones at 2022-09-05T20:07:40+01:00 Deal with rejigConRes Needs a Note to be written by Richard - - - - - acbc8835 by Simon Peyton Jones at 2022-09-05T23:52:47+01:00 Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag - - - - - 14bb809d by Simon Peyton Jones at 2022-09-06T00:00:33+01:00 Update haddock submodule - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - boot - 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/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7183bcc0d725688254b508908b1003429d648fd3...14bb809d309e0959191bc7efd2a022dd356c1df6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7183bcc0d725688254b508908b1003429d648fd3...14bb809d309e0959191bc7efd2a022dd356c1df6 You're receiving 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 Sep 6 00:52:26 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Sep 2022 20:52:26 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <631699cac732e_869eb5148c545c2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: bc800dfe by Sebastian Graf at 2022-09-05T20:52:09-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. - - - - - eb1bfb11 by Ben Gamari at 2022-09-05T20:52:10-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`. - - - - - 4 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/DmdAnal.hs - + testsuite/tests/stranal/should_compile/T22039.hs - testsuite/tests/stranal/should_compile/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -267,7 +267,7 @@ lint-ci-config: - mkdir -p ~/.cabal - cp -Rf cabal-cache/* ~/.cabal || true script: - - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install -c cabal update + - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install nixpkgs#ghc -c cabal update - .gitlab/generate_jobs # 1 if .gitlab/generate_jobs changed the output of the generated config - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#git -c git diff --exit-code ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -455,8 +455,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) !(!bndrs', !scrut_sd) | DataAlt _ <- alt_con -- See Note [Demand on the scrutinee of a product case] + , let !scrut_sd = scrutSubDmd case_bndr_sd fld_dmds -- See Note [Demand on case-alternative binders] - , (!scrut_sd, fld_dmds') <- addCaseBndrDmd case_bndr_sd fld_dmds + , let !fld_dmds' = fieldBndrDmds scrut_sd (length fld_dmds) , let !bndrs' = setBndrsDemandInfo bndrs fld_dmds' = (bndrs', scrut_sd) | otherwise @@ -560,7 +561,6 @@ forcesRealWorld fam_envs ty = False dmdAnalSumAlts :: AnalEnv -> SubDemand -> Id -> [CoreAlt] -> WithDmdType [CoreAlt] - dmdAnalSumAlts _ _ _ [] = WithDmdType botDmdType [] -- Base case is botDmdType, for empty case alternatives -- This is a unit for lubDmdType, and the right result @@ -580,28 +580,29 @@ 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 = scrutSubDmd case_bndr_sd dmds + dmds' = fieldBndrDmds scrut_sd (length dmds) -- Do not put a thunk into the Alt !new_ids = setBndrsDemandInfo bndrs dmds' = -- pprTrace "dmdAnalSumAlt" (ppr con $$ ppr case_bndr $$ ppr dmd $$ ppr alt_ty) $ 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]) - -- 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 - -- , pprTrace "addCaseBndrDmd" (ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) True - = (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 fld_dmds +scrutSubDmd :: SubDemand -> [Demand] -> SubDemand +scrutSubDmd case_sd fld_dmds = + -- pprTraceWith "scrutSubDmd" (\scrut_sd -> ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) $ + case_sd `plusSubDmd` mkProd Unboxed fld_dmds + +-- See Note [Demand on case-alternative binders] +fieldBndrDmds :: SubDemand -- on the scrutinee + -> Arity + -> [Demand] -- Final demands for the components of the DataCon +fieldBndrDmds scrut_sd n_flds = + case viewProd n_flds scrut_sd of + Just (_, ds) -> ds + Nothing -> replicate n_flds topDmd + -- Either an arity mismatch or scrut_sd was a call demand. + -- See Note [Untyped demand on case-alternative binders] {- Note [Anticipating ANF in demand analysis] @@ -830,6 +831,44 @@ thunk for a let binder that was an an absent case-alt binder during DmdAnal. This is needed even for non-product types, in case the case-binder is used but the components of the case alternative are not. +Note [Untyped demand on case-alternative binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +With unsafeCoerce, #8037 and #22039 taught us that the demand on the case binder +may be a call demand or have a different number of fields than the constructor +of the case alternative it is used in. From T22039: + + blarg :: (Int, Int) -> Int + blarg (x,y) = x+y + -- blarg :: <1!P(1L,1L)> + + f :: Either Int Int -> Int + f Left{} = 0 + f e = blarg (unsafeCoerce e) + ==> { desugars to } + f = \ (ds_d1nV :: Either Int Int) -> + case ds_d1nV of wild_X1 { + Left ds_d1oV -> lvl_s1Q6; + Right ipv_s1Pl -> + blarg + (case unsafeEqualityProof @(*) @(Either Int Int) @(Int, Int) of + { UnsafeRefl co_a1oT -> + wild_X1 `cast` (Sub (Sym co_a1oT) :: Either Int Int ~R# (Int, Int)) + }) + } + +The case binder `e`/`wild_X1` has demand 1!P(1L,1L), with two fields, from the call +to `blarg`, but `Right` only has one field. Although the code will crash when +executed, we must be able to analyse it in 'fieldBndrDmds' and conservatively +approximate with Top instead of panicking because of the mismatch. +In #22039, this kind of code was guarded behind a safe `cast` and thus dead +code, but nevertheless led to a panic of the compiler. + +You might wonder why the same problem doesn't come up when scrutinising a +product type instead of a sum type. It appears that for products, `wild_X1` +will be inlined before DmdAnal. + +See also Note [mkWWstr and unsafeCoerce] for a related issue. + Note [Aggregated demand for cardinality] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FIXME: This Note should be named [LetUp vs. LetDown] and probably predates ===================================== testsuite/tests/stranal/should_compile/T22039.hs ===================================== @@ -0,0 +1,59 @@ +{-# LANGUAGE ExistentialQuantification #-} + +module Bug where + +import Control.Exception +import Data.Typeable +import Unsafe.Coerce + +data Error + = Error Int String + | forall e . Exception e => SomeError Int e + deriving (Typeable) + +fromError :: Exception e => Error -> Maybe e +fromError e@(Error _ _) = cast e +fromError (SomeError _ e) = cast e +-- {-# NOINLINE fromError #-} + +instance Eq Error where + Error i s == Error i' s' = i == i' && s == s' + SomeError i e == SomeError i' e' = i == i' && show e == show e' + _ == _ = False + +instance Show Error where + show _ = "" + +instance Exception Error + +-- newtype +data + UniquenessError = UniquenessError [((String, String), Int)] + deriving (Show, Eq) + +instance Exception UniquenessError + +test :: SomeException -> IO () +test e = case fromError =<< fromException e :: Maybe UniquenessError of + Just err -> print err + _ -> pure () + +-- +-- Smaller reproducer by sgraf +-- + +blarg :: (Int,Int) -> Int +blarg (x,y) = x+y +{-# NOINLINE blarg #-} + +f :: Either Int Int -> Int +f Left{} = 0 +f e = blarg (unsafeCoerce e) + +blurg :: (Int -> Int) -> Int +blurg f = f 42 +{-# NOINLINE blurg #-} + +g :: Either Int Int -> Int +g Left{} = 0 +g e = blurg (unsafeCoerce e) ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -85,3 +85,4 @@ test('T21150', [ grep_errmsg(r'( t\d? :: Int)') ], compile, ['-dsuppress-uniques test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', '-v0 -dsuppress-uniques -dsuppress-all -ddump-simpl']) test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) +test('T22039', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bd21f2e8d2424f02152c99f7ae3a381284d066e...eb1bfb1135d40cb377f7b0c1c39f93b01f34d7a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bd21f2e8d2424f02152c99f7ae3a381284d066e...eb1bfb1135d40cb377f7b0c1c39f93b01f34d7a4 You're receiving 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 Sep 6 03:12:35 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Sep 2022 23:12:35 -0400 Subject: [Git][ghc/ghc][master] DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <6316baa3103de_869eb5143c701c4@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 3 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - + testsuite/tests/stranal/should_compile/T22039.hs - testsuite/tests/stranal/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -455,8 +455,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) !(!bndrs', !scrut_sd) | DataAlt _ <- alt_con -- See Note [Demand on the scrutinee of a product case] + , let !scrut_sd = scrutSubDmd case_bndr_sd fld_dmds -- See Note [Demand on case-alternative binders] - , (!scrut_sd, fld_dmds') <- addCaseBndrDmd case_bndr_sd fld_dmds + , let !fld_dmds' = fieldBndrDmds scrut_sd (length fld_dmds) , let !bndrs' = setBndrsDemandInfo bndrs fld_dmds' = (bndrs', scrut_sd) | otherwise @@ -560,7 +561,6 @@ forcesRealWorld fam_envs ty = False dmdAnalSumAlts :: AnalEnv -> SubDemand -> Id -> [CoreAlt] -> WithDmdType [CoreAlt] - dmdAnalSumAlts _ _ _ [] = WithDmdType botDmdType [] -- Base case is botDmdType, for empty case alternatives -- This is a unit for lubDmdType, and the right result @@ -580,28 +580,29 @@ 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 = scrutSubDmd case_bndr_sd dmds + dmds' = fieldBndrDmds scrut_sd (length dmds) -- Do not put a thunk into the Alt !new_ids = setBndrsDemandInfo bndrs dmds' = -- pprTrace "dmdAnalSumAlt" (ppr con $$ ppr case_bndr $$ ppr dmd $$ ppr alt_ty) $ 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]) - -- 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 - -- , pprTrace "addCaseBndrDmd" (ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) True - = (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 fld_dmds +scrutSubDmd :: SubDemand -> [Demand] -> SubDemand +scrutSubDmd case_sd fld_dmds = + -- pprTraceWith "scrutSubDmd" (\scrut_sd -> ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) $ + case_sd `plusSubDmd` mkProd Unboxed fld_dmds + +-- See Note [Demand on case-alternative binders] +fieldBndrDmds :: SubDemand -- on the scrutinee + -> Arity + -> [Demand] -- Final demands for the components of the DataCon +fieldBndrDmds scrut_sd n_flds = + case viewProd n_flds scrut_sd of + Just (_, ds) -> ds + Nothing -> replicate n_flds topDmd + -- Either an arity mismatch or scrut_sd was a call demand. + -- See Note [Untyped demand on case-alternative binders] {- Note [Anticipating ANF in demand analysis] @@ -830,6 +831,44 @@ thunk for a let binder that was an an absent case-alt binder during DmdAnal. This is needed even for non-product types, in case the case-binder is used but the components of the case alternative are not. +Note [Untyped demand on case-alternative binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +With unsafeCoerce, #8037 and #22039 taught us that the demand on the case binder +may be a call demand or have a different number of fields than the constructor +of the case alternative it is used in. From T22039: + + blarg :: (Int, Int) -> Int + blarg (x,y) = x+y + -- blarg :: <1!P(1L,1L)> + + f :: Either Int Int -> Int + f Left{} = 0 + f e = blarg (unsafeCoerce e) + ==> { desugars to } + f = \ (ds_d1nV :: Either Int Int) -> + case ds_d1nV of wild_X1 { + Left ds_d1oV -> lvl_s1Q6; + Right ipv_s1Pl -> + blarg + (case unsafeEqualityProof @(*) @(Either Int Int) @(Int, Int) of + { UnsafeRefl co_a1oT -> + wild_X1 `cast` (Sub (Sym co_a1oT) :: Either Int Int ~R# (Int, Int)) + }) + } + +The case binder `e`/`wild_X1` has demand 1!P(1L,1L), with two fields, from the call +to `blarg`, but `Right` only has one field. Although the code will crash when +executed, we must be able to analyse it in 'fieldBndrDmds' and conservatively +approximate with Top instead of panicking because of the mismatch. +In #22039, this kind of code was guarded behind a safe `cast` and thus dead +code, but nevertheless led to a panic of the compiler. + +You might wonder why the same problem doesn't come up when scrutinising a +product type instead of a sum type. It appears that for products, `wild_X1` +will be inlined before DmdAnal. + +See also Note [mkWWstr and unsafeCoerce] for a related issue. + Note [Aggregated demand for cardinality] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FIXME: This Note should be named [LetUp vs. LetDown] and probably predates ===================================== testsuite/tests/stranal/should_compile/T22039.hs ===================================== @@ -0,0 +1,59 @@ +{-# LANGUAGE ExistentialQuantification #-} + +module Bug where + +import Control.Exception +import Data.Typeable +import Unsafe.Coerce + +data Error + = Error Int String + | forall e . Exception e => SomeError Int e + deriving (Typeable) + +fromError :: Exception e => Error -> Maybe e +fromError e@(Error _ _) = cast e +fromError (SomeError _ e) = cast e +-- {-# NOINLINE fromError #-} + +instance Eq Error where + Error i s == Error i' s' = i == i' && s == s' + SomeError i e == SomeError i' e' = i == i' && show e == show e' + _ == _ = False + +instance Show Error where + show _ = "" + +instance Exception Error + +-- newtype +data + UniquenessError = UniquenessError [((String, String), Int)] + deriving (Show, Eq) + +instance Exception UniquenessError + +test :: SomeException -> IO () +test e = case fromError =<< fromException e :: Maybe UniquenessError of + Just err -> print err + _ -> pure () + +-- +-- Smaller reproducer by sgraf +-- + +blarg :: (Int,Int) -> Int +blarg (x,y) = x+y +{-# NOINLINE blarg #-} + +f :: Either Int Int -> Int +f Left{} = 0 +f e = blarg (unsafeCoerce e) + +blurg :: (Int -> Int) -> Int +blurg f = f 42 +{-# NOINLINE blurg #-} + +g :: Either Int Int -> Int +g Left{} = 0 +g e = blurg (unsafeCoerce e) ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -85,3 +85,4 @@ test('T21150', [ grep_errmsg(r'( t\d? :: Int)') ], compile, ['-dsuppress-uniques test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', '-v0 -dsuppress-uniques -dsuppress-all -ddump-simpl']) test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) +test('T22039', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2be80fd9b222963e8dd09a30f78c106e00da7f9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2be80fd9b222963e8dd09a30f78c106e00da7f9 You're receiving 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 Sep 6 03:12:56 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Sep 2022 23:12:56 -0400 Subject: [Git][ghc/ghc][master] gitlab-ci: Ensure that ghc derivation is in scope Message-ID: <6316bab8e5cf4_869eb51464703ab@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -267,7 +267,7 @@ lint-ci-config: - mkdir -p ~/.cabal - cp -Rf cabal-cache/* ~/.cabal || true script: - - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install -c cabal update + - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install nixpkgs#ghc -c cabal update - .gitlab/generate_jobs # 1 if .gitlab/generate_jobs changed the output of the generated config - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#git -c git diff --exit-code View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25f68acedf822e9ea21d1659b1f897fcfc96e5d4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25f68acedf822e9ea21d1659b1f897fcfc96e5d4 You're receiving 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 Sep 6 10:42:56 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 06 Sep 2022 06:42:56 -0400 Subject: [Git][ghc/ghc][wip/T21623] 58 commits: DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <63172430e6d1e_869eb514781163b9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - 406f2c05 by Simon Peyton Jones at 2022-09-06T09:04:05+01:00 Start work Not ready for review - - - - - 1ae9330f by Simon Peyton Jones at 2022-09-06T09:04:05+01:00 More progress - - - - - 67a7d6ee by Simon Peyton Jones at 2022-09-06T09:04:05+01:00 Wibbles - - - - - a3ea44bf by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Stage1 compiles - - - - - 81db4bad by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 More wibbles - - - - - ebafcf3d by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 More wibbles - - - - - ddf72103 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 More -- almost working - - - - - c2423616 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Comments - - - - - a03d809d by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles - - - - - 32a2f662 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles - - - - - 2b82267f by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble inlineId - - - - - ad6cebe8 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles - - - - - 0a0a47b3 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Infinite loop somewhere - - - - - 21209b0e by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 More wibbles. Maybe can build stage2 - - - - - ccf22783 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Make FuNCo a thing by itself - - - - - 17a38bfb by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble - - - - - b839b1c1 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble - - - - - 53f2bbbd by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles - - - - - 63b4d300 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Fix OptCoercion - - - - - 971b7d7f by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble - - - - - e71b490b by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble to optCoercion - - - - - e148c1af by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Replace SORT with TYPE and CONSTRAINT - - - - - 566cad71 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble - - - - - 3a38a326 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Delete unused import - - - - - 060b4fbc by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Delete TypeOrConstraint from ghc-prim:GHC.Types - - - - - b654d457 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Move from NthCo to SelCo - - - - - 73d36b2c by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles - - - - - 9f09f6b2 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles in RepType - - - - - a249caea by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble - - - - - 778d1bff by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Add mkWpEta - - - - - 4a3f7981 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Really add mkWpEta - - - - - f422268d by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibble Typeable binds etc - - - - - c97f269a by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Improve error messages - - - - - 09644fed by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 More wibbles, mainly to error messages - - - - - 835c071e by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles - - - - - 925f3210 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles to errors - - - - - 314f74c1 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 Wibbles But especially: treat Constraint as Typeable - - - - - 518ae921 by Simon Peyton Jones at 2022-09-06T09:04:06+01:00 More wibbles - - - - - 7a14baf9 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends - - - - - dda19363 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Unused variable - - - - - 75eb5a7b by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Wibbles - - - - - a10b695b by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Wibble - - - - - 41985d6f by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Accept error message changes - - - - - 6b78e5b3 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. - - - - - c0dfbb3b by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Introduce GHC.Core.TyCo.Compare Lots of import changes! - - - - - cc55c51d by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Update haddock submodule (I hope) - - - - - dfe3bcf9 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Wibbles (notably: actually add GHC.Core.TyCo.Compare) - - - - - 9d12de0b by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Wibbles - - - - - 335b2c2f by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Wibble output of T16575 - - - - - cc101625 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Wibbles - - - - - 762cda45 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 More wibbles - - - - - e0c1373a by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Remove infinite loop in T1946 See Note [ForAllTy and type equality] - - - - - 148960a4 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Deal with rejigConRes Needs a Note to be written by Richard - - - - - d675145e by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag - - - - - cc8e27a6 by Simon Peyton Jones at 2022-09-06T09:04:07+01:00 Update haddock submodule - - - - - 424ba753 by Simon Peyton Jones at 2022-09-06T11:43:04+01:00 Rename TyCoBinder to ForAllTyBinder - - - - - 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/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.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/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CallArity.hs - compiler/GHC/Core/Opt/ConstantFold.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14bb809d309e0959191bc7efd2a022dd356c1df6...424ba7535cc035375934063481d8647f07351e74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14bb809d309e0959191bc7efd2a022dd356c1df6...424ba7535cc035375934063481d8647f07351e74 You're receiving 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 Sep 6 13:43:05 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 06 Sep 2022 09:43:05 -0400 Subject: [Git][ghc/ghc][wip/T21623] 2 commits: Wibbles Message-ID: <63174e69d63da_869eb514dc16224e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 1080be15 by Simon Peyton Jones at 2022-09-06T14:42:36+01:00 Wibbles - - - - - b8a53071 by Simon Peyton Jones at 2022-09-06T14:42:44+01:00 Update haddock - - - - - 8 changed files: - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Type.hs-boot - compiler/GHC/Tc/TyCl.hs - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -131,20 +131,24 @@ import {-# SOURCE #-} GHC.Builtin.Types import {-# SOURCE #-} GHC.Types.TyThing( mkATyCon ) import {-# SOURCE #-} GHC.Core.Type ( mkTyConApp, getLevity ) +import GHC.Core.TyCon +import GHC.Core.TyCo.Rep -- Doesn't need special access, but this is easier to avoid + -- import loops which show up if you import Type instead + import GHC.Types.Var ( TyVarBinder, TyVar , mkTyVar, mkTyVarBinder, mkTyVarBinders ) import GHC.Types.Name -import GHC.Core.TyCon import GHC.Types.SrcLoc import GHC.Types.Unique import GHC.Types.Basic( TypeOrConstraint(..) ) + import GHC.Builtin.Uniques import GHC.Builtin.Names -import GHC.Data.FastString import GHC.Utils.Misc ( changeLast ) -import GHC.Core.TyCo.Rep -- Doesn't need special access, but this is easier to avoid - -- import loops which show up if you import Type instead +import GHC.Utils.Panic ( assertPpr ) +import GHC.Utils.Outputable +import GHC.Data.FastString import Data.Char {- ********************************************************************* @@ -610,7 +614,7 @@ isArrowTyCon :: TyCon -> Bool -- We don't bother to look for plain (->), because this function -- should only be used after unwrapping synonyms isArrowTyCon tc - = assertPpr (not (isSynonymTyCon tc)) (ppr tc) + = assertPpr (not (isTypeSynonymTyCon tc)) (ppr tc) getUnique tc `elem` [fUNTyConKey, ctArrowTyConKey, ccArrowTyConKey, tcArrowTyConKey] ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -20,7 +20,6 @@ module GHC.Core.DataCon ( -- ** Equality specs EqSpec, mkEqSpec, eqSpecTyVar, eqSpecType, eqSpecPair, eqSpecPreds, - substEqSpec, -- ** Field labels FieldLabel(..), FieldLabelString, @@ -787,15 +786,6 @@ eqSpecPreds :: [EqSpec] -> ThetaType eqSpecPreds spec = [ mkPrimEqPred (mkTyVarTy tv) ty | EqSpec tv ty <- spec ] --- | Substitute in an 'EqSpec'. Precondition: if the LHS of the EqSpec --- is mapped in the substitution, it is mapped to a type variable, not --- a full type. -substEqSpec :: Subst -> EqSpec -> EqSpec -substEqSpec subst (EqSpec tv ty) - = EqSpec tv' (substTy subst ty) - where - tv' = getTyVar (substTyVar subst tv) - instance Outputable EqSpec where ppr (EqSpec tv ty) = ppr (tv, ty) ===================================== compiler/GHC/Core/TyCo/Ppr.hs ===================================== @@ -27,7 +27,7 @@ module GHC.Core.TyCo.Ppr import GHC.Prelude import {-# SOURCE #-} GHC.CoreToIface - ( toIfaceTypeX, toIfaceTyLit, toIfaceForAllBndrx + ( toIfaceTypeX, toIfaceTyLit, toIfaceForAllBndrs , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX ) import {-# SOURCE #-} GHC.Core.DataCon ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -44,9 +44,9 @@ module GHC.Core.TyCo.Subst substVarBndr, substVarBndrs, substTyVarBndr, substTyVarBndrs, substCoVarBndr, - substTyVar, substTyVars, substTyCoVars, - substTyCoBndr, - substForAllCoBndr, + substTyVar, substTyVars, substTyVarToTyVar, + substTyCoVars, + substTyCoBndr, substForAllCoBndr, substVarBndrUsing, substForAllCoBndrUsing, checkValidSubst, isValidTCvSubst, ) where @@ -54,7 +54,7 @@ module GHC.Core.TyCo.Subst import GHC.Prelude import {-# SOURCE #-} GHC.Core.Type - ( mkCastTy, mkAppTy, isCoercionTy, mkTyConApp ) + ( mkCastTy, mkAppTy, isCoercionTy, mkTyConApp, getTyVar_maybe ) import {-# SOURCE #-} GHC.Core.Coercion ( mkCoVarCo, mkKindCo, mkSelCo, mkTransCo , mkNomReflCo, mkSubCo, mkSymCo @@ -815,6 +815,16 @@ substTyVar (Subst _ _ tenv _) tv Just ty -> ty Nothing -> TyVarTy tv +substTyVarToTyVar :: Subst -> TyVar -> TyVar +-- Apply the substitution, expecing the result to be a TyVarTy +substTyVarToTyVar (Subst _ _ tenv _) tv + = assert (isTyVar tv) $ + case lookupVarEnv tenv tv of + Just ty -> case getTyVar_maybe ty of + Just tv -> tv + Nothing -> pprPanic "substTyVarToTyVar" (ppr tv $$ ppr ty) + Nothing -> tv + substTyVars :: Subst -> [TyVar] -> [Type] substTyVars subst = map $ substTyVar subst ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -219,7 +219,7 @@ module GHC.Core.Type ( substCoUnchecked, substCoWithUnchecked, substTyVarBndr, substTyVarBndrs, substTyVar, substTyVars, substVarBndr, substVarBndrs, - substTyCoBndr, + substTyCoBndr, substTyVarToTyVar, cloneTyVarBndr, cloneTyVarBndrs, lookupTyVar, -- * Tidying type related things up for printing @@ -1032,7 +1032,7 @@ mapTyCoX (TyCoMapper { tcm_tyvar = tyvar -- | Attempts to obtain the type variable underlying a 'Type', and panics with the -- given message if this is not a type variable type. See also 'getTyVar_maybe' -getTyVar :: Type -> TyVar +getTyVar :: HasDebugCallStack => Type -> TyVar getTyVar ty = case getTyVar_maybe ty of Just tv -> tv Nothing -> pprPanic "getTyVar" (ppr ty) ===================================== compiler/GHC/Core/Type.hs-boot ===================================== @@ -6,7 +6,7 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Core.TyCon import {-# SOURCE #-} GHC.Core.TyCo.Rep( Type, Coercion ) import GHC.Utils.Misc -import GHC.Types.Var( FunTyFlag ) +import GHC.Types.Var( FunTyFlag, TyVar ) import GHC.Types.Basic( TypeOrConstraint ) isPredTy :: HasDebugCallStack => Type -> Bool @@ -30,6 +30,7 @@ isLiftedTypeKind :: Type -> Bool splitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) tyConAppTyCon_maybe :: Type -> Maybe TyCon +getTyVar_maybe :: Type -> Maybe TyVar getLevity :: HasDebugCallStack => Type -> Type ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3831,10 +3831,12 @@ rejigConRes tc_tvbndrs res_tmpl dc_tvbndrs res_ty -- since the dcUserTyVarBinders invariant guarantees that the -- substitution has *all* the tyvars in its domain. -- See Note [DataCon user type variable binders] in GHC.Core.DataCon. - subst_user_tvs = mapVarBndrs (getTyVar . substTyVar arg_subst) + subst_user_tvs = mapVarBndrs (substTyVarToTyVar arg_subst) substed_tvbndrs = subst_user_tvs dc_tvbndrs - substed_eqs = map (substEqSpec arg_subst) raw_eqs + substed_eqs = [ mkEqSpec (substTyVarToTyVar subst tv) + (substTy subst ty) + | (tv,ty) <- raw_eqs ] in (univ_tvs, substed_ex_tvs, substed_tvbndrs, substed_eqs, arg_subst) @@ -4000,7 +4002,7 @@ mkGADTVars :: [TyVar] -- ^ The tycon vars -> Subst -- ^ The matching between the template result type -- and the actual result type -> ( [TyVar] - , [EqSpec] + , [(TyVar,Type)] -- The un-substituted eq-spec , Subst ) -- ^ The univ. variables, the GADT equalities, -- and a subst to apply to the GADT equalities -- and existentials. @@ -4011,13 +4013,13 @@ mkGADTVars tmpl_tvs dc_tvs subst `unionInScope` getSubstInScope subst empty_subst = mkEmptySubst in_scope - choose :: [TyVar] -- accumulator of univ tvs, reversed - -> [EqSpec] -- accumulator of GADT equalities, reversed + choose :: [TyVar] -- accumulator of univ tvs, reversed + -> [(TyVar,Type)] -- accumulator of GADT equalities, reversed -> Subst -- template substitution -> Subst -- res. substitution -> [TyVar] -- template tvs (the univ tvs passed in) -> ( [TyVar] -- the univ_tvs - , [EqSpec] -- GADT equalities + , [(TyVar,Type)] -- GADT equalities , Subst ) -- a substitution to fix kinds in ex_tvs choose univs eqs _t_sub r_sub [] @@ -4049,7 +4051,7 @@ mkGADTVars tmpl_tvs dc_tvs subst tv_kind' = substTy t_sub tv_kind t_tv' = setTyVarKind t_tv tv_kind' eqs' | isConstraintLikeKind (typeKind tv_kind') = eqs - | otherwise = mkEqSpec t_tv' r_ty : eqs + | otherwise = (t_tv', r_ty) : eqs | otherwise = pprPanic "mkGADTVars" (ppr tmpl_tvs $$ ppr subst) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit d9f258ff173f5294661603128ac1c6bbb3a71b5f +Subproject commit 65570f984d536bef4e250680d2663b858a6f7838 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/424ba7535cc035375934063481d8647f07351e74...b8a53071d33b76922588cc890c347167f2889de5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/424ba7535cc035375934063481d8647f07351e74...b8a53071d33b76922588cc890c347167f2889de5 You're receiving 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 Sep 6 14:46:08 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Sep 2022 10:46:08 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <63175d30c92a2_869eb514a01738b4@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 841eaf36 by Cheng Shao at 2022-09-06T10:45:51-04:00 ci: remove unused build_make/test_make in ci script - - - - - 6 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Core/Opt/DmdAnal.hs - docs/users_guide/exts/instances.rst - + testsuite/tests/stranal/should_compile/T22039.hs - testsuite/tests/stranal/should_compile/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -267,7 +267,7 @@ lint-ci-config: - mkdir -p ~/.cabal - cp -Rf cabal-cache/* ~/.cabal || true script: - - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install -c cabal update + - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#cabal-install nixpkgs#ghc -c cabal update - .gitlab/generate_jobs # 1 if .gitlab/generate_jobs changed the output of the generated config - nix shell --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs#git -c git diff --exit-code ===================================== .gitlab/ci.sh ===================================== @@ -50,11 +50,6 @@ Common Modes: shell Run an interactive shell with a configured build environment. save_cache Preserve the cabal cache -Make build system: - - build_make Build GHC via the make build system - test_make Test GHC via the make build system - Hadrian build system build_hadrian Build GHC via the Hadrian build system test_hadrian Test GHC via the Hadrian build system @@ -436,23 +431,6 @@ function configure() { end_section "configuring" } -function build_make() { - check_release_build - prepare_build_mk - if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then - fail "BIN_DIST_PREP_TAR_COMP is not set" - fi - if [[ -n "${VERBOSE:-}" ]]; then - MAKE_ARGS="${MAKE_ARGS:-} V=1" - else - MAKE_ARGS="${MAKE_ARGS:-} V=0" - fi - - run "$MAKE" -j"$cores" "$MAKE_ARGS" - run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 - ls -lh "$BIN_DIST_PREP_TAR_COMP" -} - function fetch_perf_notes() { info "Fetching perf notes..." "$TOP/.gitlab/test-metrics.sh" pull @@ -508,23 +486,6 @@ function check_release_build() { fi } -function test_make() { - if [ -n "${CROSS_TARGET:-}" ]; then - info "Can't test cross-compiled build." - return - fi - - check_msys2_deps inplace/bin/ghc-stage2 --version - check_release_build - - run "$MAKE" test_bindist TEST_PREP=YES TEST_PROF=${RELEASE_JOB:-} - (unset $(compgen -v | grep CI_*); - run "$MAKE" V=0 VERBOSE=1 test \ - THREADS="$cores" \ - JUNIT_FILE=../../junit.xml \ - EXTRA_RUNTEST_OPTS="${RUNTEST_ARGS:-}") -} - function build_hadrian() { if [ -z "${BIN_DIST_NAME:-}" ]; then fail "BIN_DIST_NAME not set" @@ -842,13 +803,6 @@ case $1 in usage) usage ;; setup) setup && cleanup_submodules ;; configure) time_it "configure" configure ;; - build_make) time_it "build" build_make ;; - test_make) - fetch_perf_notes - res=0 - time_it "test" test_make || res=$? - push_perf_notes - exit $res ;; build_hadrian) time_it "build" build_hadrian ;; # N.B. Always push notes, even if the build fails. This is okay to do as the # testsuite driver doesn't record notes for tests that fail due to ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -455,8 +455,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt_con bndrs rhs]) !(!bndrs', !scrut_sd) | DataAlt _ <- alt_con -- See Note [Demand on the scrutinee of a product case] + , let !scrut_sd = scrutSubDmd case_bndr_sd fld_dmds -- See Note [Demand on case-alternative binders] - , (!scrut_sd, fld_dmds') <- addCaseBndrDmd case_bndr_sd fld_dmds + , let !fld_dmds' = fieldBndrDmds scrut_sd (length fld_dmds) , let !bndrs' = setBndrsDemandInfo bndrs fld_dmds' = (bndrs', scrut_sd) | otherwise @@ -560,7 +561,6 @@ forcesRealWorld fam_envs ty = False dmdAnalSumAlts :: AnalEnv -> SubDemand -> Id -> [CoreAlt] -> WithDmdType [CoreAlt] - dmdAnalSumAlts _ _ _ [] = WithDmdType botDmdType [] -- Base case is botDmdType, for empty case alternatives -- This is a unit for lubDmdType, and the right result @@ -580,28 +580,29 @@ 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 = scrutSubDmd case_bndr_sd dmds + dmds' = fieldBndrDmds scrut_sd (length dmds) -- Do not put a thunk into the Alt !new_ids = setBndrsDemandInfo bndrs dmds' = -- pprTrace "dmdAnalSumAlt" (ppr con $$ ppr case_bndr $$ ppr dmd $$ ppr alt_ty) $ 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]) - -- 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 - -- , pprTrace "addCaseBndrDmd" (ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) True - = (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 fld_dmds +scrutSubDmd :: SubDemand -> [Demand] -> SubDemand +scrutSubDmd case_sd fld_dmds = + -- pprTraceWith "scrutSubDmd" (\scrut_sd -> ppr case_sd $$ ppr fld_dmds $$ ppr scrut_sd) $ + case_sd `plusSubDmd` mkProd Unboxed fld_dmds + +-- See Note [Demand on case-alternative binders] +fieldBndrDmds :: SubDemand -- on the scrutinee + -> Arity + -> [Demand] -- Final demands for the components of the DataCon +fieldBndrDmds scrut_sd n_flds = + case viewProd n_flds scrut_sd of + Just (_, ds) -> ds + Nothing -> replicate n_flds topDmd + -- Either an arity mismatch or scrut_sd was a call demand. + -- See Note [Untyped demand on case-alternative binders] {- Note [Anticipating ANF in demand analysis] @@ -830,6 +831,44 @@ thunk for a let binder that was an an absent case-alt binder during DmdAnal. This is needed even for non-product types, in case the case-binder is used but the components of the case alternative are not. +Note [Untyped demand on case-alternative binders] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +With unsafeCoerce, #8037 and #22039 taught us that the demand on the case binder +may be a call demand or have a different number of fields than the constructor +of the case alternative it is used in. From T22039: + + blarg :: (Int, Int) -> Int + blarg (x,y) = x+y + -- blarg :: <1!P(1L,1L)> + + f :: Either Int Int -> Int + f Left{} = 0 + f e = blarg (unsafeCoerce e) + ==> { desugars to } + f = \ (ds_d1nV :: Either Int Int) -> + case ds_d1nV of wild_X1 { + Left ds_d1oV -> lvl_s1Q6; + Right ipv_s1Pl -> + blarg + (case unsafeEqualityProof @(*) @(Either Int Int) @(Int, Int) of + { UnsafeRefl co_a1oT -> + wild_X1 `cast` (Sub (Sym co_a1oT) :: Either Int Int ~R# (Int, Int)) + }) + } + +The case binder `e`/`wild_X1` has demand 1!P(1L,1L), with two fields, from the call +to `blarg`, but `Right` only has one field. Although the code will crash when +executed, we must be able to analyse it in 'fieldBndrDmds' and conservatively +approximate with Top instead of panicking because of the mismatch. +In #22039, this kind of code was guarded behind a safe `cast` and thus dead +code, but nevertheless led to a panic of the compiler. + +You might wonder why the same problem doesn't come up when scrutinising a +product type instead of a sum type. It appears that for products, `wild_X1` +will be inlined before DmdAnal. + +See also Note [mkWWstr and unsafeCoerce] for a related issue. + Note [Aggregated demand for cardinality] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FIXME: This Note should be named [LetUp vs. LetDown] and probably predates ===================================== docs/users_guide/exts/instances.rst ===================================== @@ -591,16 +591,15 @@ Instance signatures: type signatures in instance declarations Allow type signatures for members in instance definitions. -In Haskell, you can't write a type signature in an instance declaration, -but it is sometimes convenient to do so, and the language extension -:extension:`InstanceSigs` allows you to do so. For example: :: +The :extension:`InstanceSigs` extension allows users to give type signatures +to the class methods in a class instance declaration. For example: :: data T a = MkT a a instance Eq a => Eq (T a) where - (==) :: T a -> T a -> Bool -- The signature + (==) :: T a -> T a -> Bool -- The instance signature (==) (MkT x1 x2) (MkTy y1 y2) = x1==y1 && x2==y2 -Some details +Some details: - The type signature in the instance declaration must be more polymorphic than (or the same as) the one in the class declaration, @@ -613,11 +612,37 @@ Some details Here the signature in the instance declaration is more polymorphic than that required by the instantiated class method. + Note that, to check that the instance signature is more polymorphic, + GHC performs a sub-type check, which can solve constraints using available + top-level instances. + This means that the following instance signature is accepted: :: + + instance Eq (T Int) where + (==) :: Eq Int => T Int -> T Int -> Bool + (==) (MkT x1 _) (MkT y1 _) = x1 == y1 + + The ``Eq Int`` constraint in the instance signature will be solved + by the top-level ``Eq Int`` instance, from which it follows that the + instance signature is indeed as general as the instantiated class + method type ``T Int -> T Int -> Bool``. + - The code for the method in the instance declaration is typechecked against the type signature supplied in the instance declaration, as you would expect. So if the instance signature is more polymorphic than required, the code must be too. +- The instance signature is purely local to the class instance + declaration. It only affects the typechecking of the method in + the instance; it does not affect anything outside the class + instance. In this way, it is similar to an inline type signature: + + instance Eq a => Eq (T a) where + (==) = (\ x y -> True) :: forall b. b -> b -> Bool + + In particular, adding constraints such as `HasCallStack` to the + instance signature will not have an effect; they need to be added + to the class instead. + - One stylistic reason for wanting to write a type signature is simple documentation. Another is that you may want to bring scoped type variables into scope. For example: :: ===================================== testsuite/tests/stranal/should_compile/T22039.hs ===================================== @@ -0,0 +1,59 @@ +{-# LANGUAGE ExistentialQuantification #-} + +module Bug where + +import Control.Exception +import Data.Typeable +import Unsafe.Coerce + +data Error + = Error Int String + | forall e . Exception e => SomeError Int e + deriving (Typeable) + +fromError :: Exception e => Error -> Maybe e +fromError e@(Error _ _) = cast e +fromError (SomeError _ e) = cast e +-- {-# NOINLINE fromError #-} + +instance Eq Error where + Error i s == Error i' s' = i == i' && s == s' + SomeError i e == SomeError i' e' = i == i' && show e == show e' + _ == _ = False + +instance Show Error where + show _ = "" + +instance Exception Error + +-- newtype +data + UniquenessError = UniquenessError [((String, String), Int)] + deriving (Show, Eq) + +instance Exception UniquenessError + +test :: SomeException -> IO () +test e = case fromError =<< fromException e :: Maybe UniquenessError of + Just err -> print err + _ -> pure () + +-- +-- Smaller reproducer by sgraf +-- + +blarg :: (Int,Int) -> Int +blarg (x,y) = x+y +{-# NOINLINE blarg #-} + +f :: Either Int Int -> Int +f Left{} = 0 +f e = blarg (unsafeCoerce e) + +blurg :: (Int -> Int) -> Int +blurg f = f 42 +{-# NOINLINE blurg #-} + +g :: Either Int Int -> Int +g Left{} = 0 +g e = blurg (unsafeCoerce e) ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -85,3 +85,4 @@ test('T21150', [ grep_errmsg(r'( t\d? :: Int)') ], compile, ['-dsuppress-uniques test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', '-v0 -dsuppress-uniques -dsuppress-all -ddump-simpl']) test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) +test('T22039', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb1bfb1135d40cb377f7b0c1c39f93b01f34d7a4...841eaf3608769f2a4caa48c4f7bc82d1ceb24ce6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb1bfb1135d40cb377f7b0c1c39f93b01f34d7a4...841eaf3608769f2a4caa48c4f7bc82d1ceb24ce6 You're receiving 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 Sep 6 14:51:13 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 06 Sep 2022 10:51:13 -0400 Subject: [Git][ghc/ghc][wip/T21623] Wibble Message-ID: <63175e61c22a_869eb514a01795b3@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 33295998 by Simon Peyton Jones at 2022-09-06T15:52:20+01:00 Wibble - - - - - 2 changed files: - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Tc/TyCl.hs Changes: ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -815,7 +815,7 @@ substTyVar (Subst _ _ tenv _) tv Just ty -> ty Nothing -> TyVarTy tv -substTyVarToTyVar :: Subst -> TyVar -> TyVar +substTyVarToTyVar :: HasDebugCallStack => Subst -> TyVar -> TyVar -- Apply the substitution, expecing the result to be a TyVarTy substTyVarToTyVar (Subst _ _ tenv _) tv = assert (isTyVar tv) $ ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3834,8 +3834,8 @@ rejigConRes tc_tvbndrs res_tmpl dc_tvbndrs res_ty subst_user_tvs = mapVarBndrs (substTyVarToTyVar arg_subst) substed_tvbndrs = subst_user_tvs dc_tvbndrs - substed_eqs = [ mkEqSpec (substTyVarToTyVar subst tv) - (substTy subst ty) + substed_eqs = [ mkEqSpec (substTyVarToTyVar arg_subst tv) + (substTy arg_subst ty) | (tv,ty) <- raw_eqs ] in (univ_tvs, substed_ex_tvs, substed_tvbndrs, substed_eqs, arg_subst) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33295998c12f4aa50da2ac17545eaa1837ef451a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33295998c12f4aa50da2ac17545eaa1837ef451a You're receiving 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 Sep 6 16:12:15 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 06 Sep 2022 12:12:15 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 243 commits: Pmc: consider any 2 dicts of the same type equal Message-ID: <6317715fe802c_869eb514dc20024d@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 065fd535 by Josh Meredith at 2022-09-02T13:54:25-04: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 - - - - - 9762485d by doyougnu at 2022-09-02T13:54:25-04: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 - - - - - 3c99540c by doyougnu at 2022-09-02T13:54:26-04: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 - - - - - 586ba4fe by Sylvain Henry at 2022-09-02T13:54:26-04:00 Doc has been moved into GHC.StgToJs top-level module - - - - - 75a7c97b by Sylvain Henry at 2022-09-02T13:54:26-04: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 - - - - - 7010dd86 by Sylvain Henry at 2022-09-02T13:54:26-04: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... - - - - - 540998e9 by Sylvain Henry at 2022-09-02T13:54:26-04: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) - - - - - cb200177 by Sylvain Henry at 2022-09-02T13:56:01-04:00 Configure: preliminary support for triple js-unknown-ghcjs - - - - - 66034a4d by Sylvain Henry at 2022-09-02T13:56:05-04:00 Driver: enable JS backend by default for JS arch - - - - - 2e80872b by doyougnu at 2022-09-02T13:56:05-04: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 - - - - - 4cb13e11 by Sylvain Henry at 2022-09-02T13:56:05-04:00 Minor panic fix - - - - - 3952ebf6 by Sylvain Henry at 2022-09-02T13:56:05-04:00 Linker: fix stage2 build - - - - - 5d2a2c9b by Sylvain Henry at 2022-09-02T13:56:05-04: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... - - - - - 7ec5119d by doyougnu at 2022-09-02T13:56:05-04: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 - - - - - 5232f4f9 by Sylvain Henry at 2022-09-02T13:56:06-04: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 - - - - - 0a6fb369 by Sylvain Henry at 2022-09-02T13:56:06-04:00 Force creation of rts library with dummy file - - - - - 6908c5ba by Sylvain Henry at 2022-09-02T13:56:06-04:00 ghc-prim: avoid building C files - - - - - d04071fc by Sylvain Henry at 2022-09-02T13:56:06-04:00 Hadrian: disable -fllvm - - - - - 2065d331 by Sylvain Henry at 2022-09-02T13:56:06-04:00 JS: fix caches Note that the fact that we need index 0 may hide another issue... - - - - - d1e9cce0 by Sylvain Henry at 2022-09-02T13:56:06-04:00 codegen: enhance genCon debug message - - - - - 747ee15f by Sylvain Henry at 2022-09-02T13:56:07-04:00 RTS: fix stupid comment - - - - - 32e8edf3 by Sylvain Henry at 2022-09-02T13:56:07-04:00 RTS: embed headers - - - - - 5fd02f46 by Sylvain Henry at 2022-09-02T13:56:07-04:00 JS.StgToJS: add documentation header for JS Types - - - - - 28457e78 by Sylvain Henry at 2022-09-02T13:56:07-04:00 CodeGen: refactor ExprCtx code - - - - - e81fad7d by Sylvain Henry at 2022-09-02T13:56:07-04:00 CodeGen: cache LNE frame size - - - - - 4d116eee by doyougnu at 2022-09-02T13:56:07-04:00 JS.Types: Add Outputable for TypedExpr - - - - - 14653f81 by doyougnu at 2022-09-02T13:56:07-04:00 JS.CoreUtils: handle IOPort case - - - - - 02e8d573 by doyougnu at 2022-09-02T13:56:08-04:00 JS.Expr: Fix unhandled datacon for RuntimeRep - - - - - ba1e9780 by doyougnu at 2022-09-02T13:56:08-04:00 JS.Literals: Adapt genLit to new Literal domain - - - - - 9e95fd31 by Sylvain Henry at 2022-09-02T13:56:08-04:00 RTS: expose more headers (required to build base) - - - - - 3e66ea50 by Sylvain Henry at 2022-09-02T13:56:08-04:00 Base: don't build C and Cmm sources with ghcjs - - - - - e63f5555 by Sylvain Henry at 2022-09-02T13:56:08-04:00 Tentatively set NO_REGS for JS platforms - - - - - e784966d by Sylvain Henry at 2022-09-02T13:56:08-04:00 CodeGen: output LitRubbish as null JS values - - - - - bbadd7ee by Sylvain Henry at 2022-09-02T13:56:09-04:00 base: disable forkOS and bound thread machinery - - - - - 1aeb2547 by Sylvain Henry at 2022-09-02T13:56:09-04:00 CodeGen: support StackSnapshot# in primTypeVt - - - - - 53a5de26 by Sylvain Henry at 2022-09-02T13:56:09-04:00 CodeGen: better debug message for assignCoerce1 - - - - - 996a61b2 by Sylvain Henry at 2022-09-02T13:56:09-04:00 Misc: enable HasDebugCallStack for zipWithEqual* - - - - - 68526023 by Sylvain Henry at 2022-09-02T13:56:09-04:00 CodeGen: remove useless imports - - - - - e3f1ea73 by Sylvain Henry at 2022-09-02T13:56:09-04:00 Stg: expose pprStgAlt - - - - - 23974fe0 by Sylvain Henry at 2022-09-02T13:56:09-04:00 CodeGen: restore assignAll (instead of assignAllEqual) - - - - - 1a7a5534 by Sylvain Henry at 2022-09-02T13:56:10-04:00 CodeGen: handle proxy# - - - - - 47b4962c by doyougnu at 2022-09-02T13:56:10-04:00 ghc-heap: Don't compile Cmm file for JS-Backend - - - - - 0d45ac9f by doyougnu at 2022-09-02T13:56:10-04:00 Driver.Main: minor refactor do_code_gen To clearly separate the JS-Backend from any other backend - - - - - 67435f6c by Sylvain Henry at 2022-09-02T13:56:10-04:00 Configure: fix echo on Mac, add ghcjs target OS - - - - - 1a582ea1 by Sylvain Henry at 2022-09-02T13:56:10-04:00 Configure: fix previous commit - - - - - b0e19b6f by Luite Stegeman at 2022-09-02T13:56:10-04:00 fix package name in module name field of system dependencies - - - - - e3e44e40 by Luite Stegeman at 2022-09-02T13:56:11-04:00 fix duplicate module name in symbols - - - - - 539ce494 by doyougnu at 2022-09-02T13:56:11-04:00 GHCi.FFI: ignore ffi.h and friends for js-backend - - - - - 0dc4e2b0 by Sylvain Henry at 2022-09-02T13:56:11-04:00 RTS: fix build of native rts - - - - - 76c525e3 by Sylvain Henry at 2022-09-02T13:56:11-04:00 Remove temporary -fjavascript flag - - - - - dc83f226 by Sylvain Henry at 2022-09-02T13:56:11-04:00 Codegen: fix symbol names ppr - - - - - a7041cf3 by Sylvain Henry at 2022-09-02T13:56:11-04:00 Outputable: add ShortText instance - - - - - a18946f4 by Sylvain Henry at 2022-09-02T13:56:12-04:00 Linker: enhance debugging message - - - - - 17a5dfe4 by Sylvain Henry at 2022-09-02T13:56:12-04:00 Remove unused ghcjs unit related code - - - - - f7dab371 by Sylvain Henry at 2022-09-02T13:56:12-04:00 ghci: Avoid unused-xyz warnings - - - - - e43e75c0 by Sylvain Henry at 2022-09-02T13:56:12-04:00 Linker: remove wiring of ghcjs-prim and ghcjs-th They will be replaced by ghc-prim, base, template-haskell, etc. - - - - - 649f249a by Sylvain Henry at 2022-09-02T13:56:12-04:00 Add outputable instance for Deps - - - - - f476af90 by doyougnu at 2022-09-02T13:56:12-04: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 - - - - - c62745d0 by Sylvain Henry at 2022-09-02T13:56:12-04:00 Rename u_env into unit_env (more common) - - - - - ba7f9ac6 by Sylvain Henry at 2022-09-02T13:56:13-04:00 Linker: deduplication + fixes - deduplicate code that was copied from old GHC - explicitly add preloadUnits to the link - avoid calling getShims - - - - - 7fe6118f by Sylvain Henry at 2022-09-02T13:56:13-04:00 Linker: reenable packStrings (not yet implemented though) - - - - - e16f4035 by Sylvain Henry at 2022-09-02T13:56:13-04:00 ShortText: add singleton - - - - - 6f4c21a8 by Sylvain Henry at 2022-09-02T13:56:13-04:00 Linker: force less efficient (but working) static encoding - - - - - 679ee90a by Luite Stegeman at 2022-09-02T13:56:13-04:00 add GHCJS modules to base package - - - - - 5747dd6a by Sylvain Henry at 2022-09-02T13:56:13-04:00 Linker: remove JS Shims,tiny GHC.Linker refactor - - - - - ee77e1bd by doyougnu at 2022-09-02T13:56:14-04:00 Hadrian: QuickJS ways [] --> Set - - - - - 5a0ec856 by doyougnu at 2022-09-02T13:56:14-04: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. - - - - - 6e4593b5 by doyougnu at 2022-09-02T13:56:14-04:00 JS: silence haddock warnings JS Backend: remove misc. warnings - - - - - f3ba1a3b by doyougnu at 2022-09-02T13:56:14-04:00 JS Backend: ghcjs_HOST_OS --> js_HOST_ARCH - - - - - b75abfe4 by Sylvain Henry at 2022-09-02T13:56:14-04: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 - - - - - d7968ae0 by Sylvain Henry at 2022-09-02T13:56:14-04:00 CPP: disable line markers CPP: move option before input filename (to be squashed) - - - - - 3d9a8372 by Sylvain Henry at 2022-09-02T13:56:15-04: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 - - - - - b33084f5 by Sylvain Henry at 2022-09-02T13:56:15-04: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) - - - - - e208a734 by Sylvain Henry at 2022-09-02T13:56:15-04: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 - - - - - 996dbb71 by doyougnu at 2022-09-02T13:56:15-04: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. - - - - - 27edc6d3 by Sylvain Henry at 2022-09-02T13:56:15-04: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 - - - - - 8aff4bfa by Sylvain Henry at 2022-09-02T13:56:15-04:00 Add primops Add primop - - - - - 475a9161 by doyougnu at 2022-09-02T13:56:15-04: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 - - - - - e689c385 by doyougnu at 2022-09-02T13:56:16-04:00 Base: Adapt primitives to JS backend, add base.js - - - - - 6ddcd5cc by doyougnu at 2022-09-02T13:56:16-04:00 Base: Remove binding forms in JS ffi - - - - - cec7567b by Josh Meredith at 2022-09-02T13:56:16-04:00 Replace GHCJS Objectable with GHC Binary - - - - - 992527fb by Sylvain Henry at 2022-09-02T13:56:16-04:00 Binary: remove unused Map instance - - - - - 852b3d3a by Sylvain Henry at 2022-09-02T13:56:16-04:00 CodeGen: Add export list - - - - - 6d6171b1 by Sylvain Henry at 2022-09-02T13:56:16-04:00 Primops: add some Int64/Word64 primops - - - - - ae37661a by Sylvain Henry at 2022-09-02T13:56:16-04:00 base: fix one ffi import - - - - - 49ea149d by doyougnu at 2022-09-02T13:56:17-04: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. - - - - - bf66fef8 by doyougnu at 2022-09-02T13:56:17-04:00 fixup: remove redundant struct.js.pp in js_base - - - - - 8164eb37 by doyougnu at 2022-09-02T13:56:17-04:00 JS.Linker: enable linker RTS symbols - - - - - d32519b7 by doyougnu at 2022-09-02T13:56:17-04:00 base.GHCJS: adapt Prim to direct call FFI format - - - - - 9816a788 by doyougnu at 2022-09-02T13:56:17-04:00 Linker: Load JSVal from base not ghc-prim - - - - - 610b63d4 by doyougnu at 2022-09-02T13:56:17-04:00 fixup: caught one more reference to JSVal in prim - - - - - 6d4d8950 by Sylvain Henry at 2022-09-02T13:56:18-04:00 base: match on js arch , not ghcjs os - - - - - 2201126c by Sylvain Henry at 2022-09-02T13:56:18-04:00 Fix MK_JSVAL - - - - - 5232b6d7 by doyougnu at 2022-09-02T13:56:18-04:00 Prim: cleanup comments - - - - - ffe433a4 by doyougnu at 2022-09-02T13:56:18-04:00 JS.Prim: add Int64 PrimOps - - - - - 1cfe04d1 by Sylvain Henry at 2022-09-02T13:56:18-04:00 Vendor MD5 lib - - - - - 10e0b643 by Sylvain Henry at 2022-09-02T13:56:18-04:00 More 64-bit primops - - - - - 61e7cd9f by Sylvain Henry at 2022-09-02T13:56:18-04:00 CodeGen: use if10 helper - - - - - e6d50b36 by Sylvain Henry at 2022-09-02T13:56:19-04:00 Ppr: fix selector to avoid adding a newline - - - - - d80d27cb by doyougnu at 2022-09-02T13:56:19-04:00 base: GHCJS.Prim make ffi imports use anon funcs - - - - - 1233ee96 by Sylvain Henry at 2022-09-02T13:56:19-04:00 Linker: disable invalid constructors again - - - - - 287073ca by Sylvain Henry at 2022-09-02T13:56:19-04:00 More 64-bits primops - - - - - b69ccb7b by Sylvain Henry at 2022-09-02T13:56:19-04:00 Fix base_write function - - - - - 4c0703d1 by Sylvain Henry at 2022-09-02T13:56:19-04:00 Fix base_write for 32-bit size_t - - - - - 1e5d590e by Sylvain Henry at 2022-09-02T13:56:19-04:00 Configure: fix detection of the target toolchain - - - - - 2fe91a4c by Sylvain Henry at 2022-09-02T13:56:20-04:00 Remove js_base directory - - - - - ab173ffa by Sylvain Henry at 2022-09-02T13:56:20-04:00 Kill Node when the main loop reports an unhandled exception - - - - - c7d3540e by Sylvain Henry at 2022-09-02T13:56:20-04:00 CodeGen: preparation to make match on primops complete - - - - - 81657fcf by Sylvain Henry at 2022-09-02T13:56:20-04:00 Primops: fix Compact primops - - - - - a7008c5a by Sylvain Henry at 2022-09-02T13:56:20-04:00 Ignore result arity for some exception primops - - - - - d2e5e21b by Sylvain Henry at 2022-09-02T13:56:20-04:00 Fix more primops. Bump array submodule! - - - - - 01d998db by Sylvain Henry at 2022-09-02T13:56:21-04:00 Compact: fix return of 3 values - - - - - 754c04a7 by Sylvain Henry at 2022-09-02T13:56:21-04:00 Configure: switch to absolute path - - - - - ced9b3d3 by Sylvain Henry at 2022-09-02T13:56:21-04:00 Add a few primops - - - - - f735343f by Sylvain Henry at 2022-09-02T13:56:21-04:00 Primop: implement WordAdd2 - - - - - 8cefca27 by Luite Stegeman at 2022-09-02T13:56:22-04: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 - - - - - cf910c3e by Josh Meredith at 2022-09-02T13:56:22-04:00 Replace ShortText with (Lexical)FastString in GHCJS backend - - - - - 11309b1b by Sylvain Henry at 2022-09-02T13:56:22-04:00 Primops: add arithmetic ops Primops: add decodeDoubleInt64 back Primop: added timesInt2# Primop: add mulWord32 and mul2Word32 - - - - - da2ce640 by Sylvain Henry at 2022-09-02T13:56:22-04:00 Reduce dependency on goog - - - - - a5133296 by Sylvain Henry at 2022-09-02T13:56:22-04:00 Primop: implement quotWord32, remWord32, and quotRemWord32 - - - - - 7f886dbb by Sylvain Henry at 2022-09-02T13:56:22-04:00 Primop: Implement quotRem2Word32, misc fixes Primop: implement quotRem2Word32 Primop: fix timesInt2# Primop: fix some shifting primops - - - - - e4b92460 by Sylvain Henry at 2022-09-02T13:56:23-04:00 Fix bug in upd_frame I've introduced this bug when I've refactored the code to use helpers to assign closures. - - - - - 0a39963a by Sylvain Henry at 2022-09-02T13:56:23-04:00 Primop: throw an exception for unimplemented primops - - - - - 60842d1a by Sylvain Henry at 2022-09-02T13:56:23-04:00 Primop: fix remWord32 - - - - - ad19322a by Josh Meredith at 2022-09-02T13:56:23-04: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 - - - - - 9b28fb46 by Sylvain Henry at 2022-09-02T13:56:23-04:00 resultSize: correctly handle Void# - - - - - 8dc2cf22 by Sylvain Henry at 2022-09-02T13:56:23-04: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! - - - - - 7d4c0769 by Sylvain Henry at 2022-09-02T13:56:23-04:00 StgToJS.Apply: Docs Doc Doc - - - - - 7ef32c4c by Josh Meredith at 2022-09-02T13:56:24-04:00 Fix EMSDK configure condition - - - - - 5f8e4009 by doyougnu at 2022-09-02T13:56:24-04:00 StgToJS.Arg: Unboxable Literal Optimization note - - - - - 47050654 by Sylvain Henry at 2022-09-02T13:56:24-04:00 Fix Outputable instances for JExpr/JVal - Put orphan instances in JS.Ppr - Also fix some redundant imports - - - - - 9a6b0e26 by doyougnu at 2022-09-02T13:56:24-04:00 configure: avoid CXX stdlib check for js backend and some cleanup for a previously mis-applied commit during rebasing - - - - - 79c6e1c3 by doyougnu at 2022-09-02T13:56:24-04:00 fixup: misc. fixes post rebase - - - - - de3764cf by Sylvain Henry at 2022-09-02T13:56:24-04:00 PrimOps: add more 64-bit primops PrimOp: implement more 64-bit primops + PM fix Ensure that we cover every primop explicitly - - - - - 121c1320 by Sylvain Henry at 2022-09-02T13:56:25-04:00 PrimOp: correclty (un)handle new thread related primops - - - - - d3e7e350 by Sylvain Henry at 2022-09-02T13:56:25-04:00 PrimOp: disable LabelThreadOp for now - - - - - 7b4dd4be by Sylvain Henry at 2022-09-02T13:56:25-04:00 Minor doc/cleanup Fix more redundant imports - - - - - c3ac5ad6 by doyougnu at 2022-09-02T13:56:25-04:00 base: GHCJS.Prim directory --> GHC.JS.Prim - - - - - fc001c05 by Luite Stegeman at 2022-09-02T13:56:25-04:00 implement KeepAlive primop - - - - - e682fd45 by Sylvain Henry at 2022-09-02T13:56:25-04:00 Remove orphan instance for StaticArg - - - - - a93bebde by Sylvain Henry at 2022-09-02T13:56:25-04:00 Remove redundant jsIdIdent' function - - - - - a1abcd8f by Sylvain Henry at 2022-09-02T13:56:26-04:00 Split StgToJS.Monad into StgToJS.{Monad,Ids,Stack} - - - - - 1277324e by Sylvain Henry at 2022-09-02T13:56:26-04:00 Apply: remove commented case (wasn't optimized either in latest ghcjs) - - - - - fd3df88b by Sylvain Henry at 2022-09-02T13:56:26-04:00 Doc: Apply Apply: doc and refactoring - use new types instead of Bool/Int - factorize some code - - - - - f25a234c by Sylvain Henry at 2022-09-02T13:56:26-04: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 - - - - - 144503cf by doyougnu at 2022-09-02T13:56:26-04: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 - - - - - 591fbc7d by Sylvain Henry at 2022-09-02T13:56:26-04:00 GHCJS.Prim leftovers - - - - - bbab94fd by Sylvain Henry at 2022-09-02T13:56:27-04:00 Linker: fix linking issue for tuples - - - - - 61d0c8d4 by Sylvain Henry at 2022-09-02T13:56:27-04:00 FFI: remove narrowing Fix tests such as cgrun015 (Core lint error) - - - - - 9e3a01af by Sylvain Henry at 2022-09-02T13:56:27-04:00 Linker: disable logs with default verbosity - - - - - 78a8c813 by Sylvain Henry at 2022-09-02T13:56:27-04:00 Append program name in top-level exception handler - - - - - b5ac1005 by doyougnu at 2022-09-02T13:56:27-04:00 GHC.JS: Remove FIXMEs JS.Syntax: Remove FIXMEs JS.Make: remove FIXMEs JS.Ppr/Transform: Remove FIXMEs - - - - - 3c5b0b0f by Sylvain Henry at 2022-09-02T13:56:27-04:00 Primop: fix timesInt2# Pass arith003 test - - - - - 51195227 by doyougnu at 2022-09-02T13:56:27-04:00 JS.Linker.Linker: remove FIXMEs, clean dead code - - - - - d5879132 by Sylvain Henry at 2022-09-02T13:56:28-04:00 Linker: link platform shim before the others - - - - - 9ea976d6 by Sylvain Henry at 2022-09-02T13:56:28-04: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 - - - - - 941d3d05 by Sylvain Henry at 2022-09-02T13:56:28-04:00 PrimOp: fixup previous commit... - - - - - fe39292b by Sylvain Henry at 2022-09-02T13:56:28-04:00 Primop: fixup previous commit - - - - - eda39542 by Sylvain Henry at 2022-09-02T13:56:28-04:00 Doc: minor changes - - - - - 184fcc03 by Sylvain Henry at 2022-09-02T13:56:28-04:00 Add debug option to watch for insertion of undefined/null in the stack - - - - - 14c59412 by Sylvain Henry at 2022-09-02T13:56:28-04:00 Apply: fix tag generation - - - - - d61dd4fd by Sylvain Henry at 2022-09-02T13:56:29-04:00 Remove redundant import - - - - - b162293c by Sylvain Henry at 2022-09-02T13:56:29-04:00 Testsuite: disable Cmm tests with the JS backend - - - - - dee5667b by Sylvain Henry at 2022-09-02T13:56:29-04:00 Base: fix c_interruptible_open - - - - - 54f187bb by Sylvain Henry at 2022-09-02T13:56:29-04:00 Base: fix typo in long_from_number - - - - - ff32742c by Sylvain Henry at 2022-09-02T13:56:29-04:00 Env: only add program name to errors, not to traces - - - - - 62836536 by Sylvain Henry at 2022-09-02T13:56:29-04:00 Testsuite: disable more Cmm tests - - - - - 8c0db5cf by doyougnu at 2022-09-02T13:56:30-04: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 - - - - - 66c61c66 by doyougnu at 2022-09-02T13:56:30-04:00 JS RTS: remove FIXMEs StgToJS.Rts.Types: Remove FIXMEs - - - - - ca9784d5 by Sylvain Henry at 2022-09-02T13:56:30-04:00 Primop: fix bswap32/64 (cf cgrun072) - - - - - 58fbd2de by Sylvain Henry at 2022-09-02T13:56:30-04:00 Testsuite: normalise ghc program name - - - - - c50c19dd by doyougnu at 2022-09-02T13:56:30-04:00 JS Backend: Remove FIXMEs StgToJS.Apply: Remove FIXMEs StgToJS.FFI: remove FIXMEs StgToJS.Expr: remove FIXMEs StgToJS: Remove FIXMEs - - - - - bb53e0b3 by Sylvain Henry at 2022-09-02T13:56:30-04:00 Enable RTS args filtering (cf cgrun025) - - - - - a89bc41a by Sylvain Henry at 2022-09-02T13:56:30-04:00 Remove trailing whitespaces (whitespace test) - - - - - 4d8445e9 by Sylvain Henry at 2022-09-02T13:56:31-04:00 Testsuite: remove platform prefix for unlit tool - - - - - 6b633fbe by Sylvain Henry at 2022-09-02T13:56:31-04:00 Primop: fix Int64 conversion/negate (integerConversions test) - - - - - 5de80523 by Sylvain Henry at 2022-09-02T13:56:31-04:00 Linker: remove message with default verbosity - - - - - eccaea2b by Sylvain Henry at 2022-09-02T13:56:31-04:00 Testsuite: normalise .jsexe suffix - - - - - 2903d22b by Sylvain Henry at 2022-09-02T13:56:31-04:00 Remove warning about orphan instance - - - - - dd4a9d18 by Sylvain Henry at 2022-09-02T13:56:31-04:00 Compactor: disable dead code - - - - - 246a2027 by Sylvain Henry at 2022-09-02T13:56:32-04:00 Exception: implement raiseUnderflow etc. as primops - - - - - 3d923e71 by Sylvain Henry at 2022-09-02T13:56:32-04:00 Primop: fix Int8/18 quot/rem - - - - - a808202b by Sylvain Henry at 2022-09-02T13:56:32-04:00 Linker: refactor wired-in deps - - - - - d8cf02f9 by Sylvain Henry at 2022-09-02T13:56:32-04:00 Ppr: remove useless left padding for functions in JS dumps - - - - - 841ad3fd by Josh Meredith at 2022-09-02T13:56:32-04:00 Disable llvm ways and ghci for JS backend testsuite - - - - - ab3e10e6 by Sylvain Henry at 2022-09-02T13:56:32-04:00 StaticPtr: don't generate CStubs for the JS backend - - - - - 18ea6b48 by Sylvain Henry at 2022-09-02T13:56:32-04:00 StaticPtr: fix hs_spt_lookup after upstream change - - - - - 4a84ce49 by Sylvain Henry at 2022-09-02T13:56:33-04: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). - - - - - bfbddebe by Sylvain Henry at 2022-09-02T13:56:33-04: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. - - - - - 619f3ad5 by Sylvain Henry at 2022-09-02T13:56:33-04:00 CPP: fix LINE markers. Only disable them for JS - - - - - de7ba6af by Luite Stegeman at 2022-09-02T13:56:33-04:00 add JavaScript files listed in js-sources to package archives - - - - - 349e2fe3 by Luite Stegeman at 2022-09-02T13:56:33-04:00 update rts js files to include recent fixes - - - - - b9d89233 by Luite Stegeman at 2022-09-02T13:56:33-04:00 fix definitions in js/rts.h - - - - - 3d2e122f by Josh Meredith at 2022-09-02T13:56:34-04:00 stopgap fix for missing ghc-pkg in cross-compiler tests - - - - - c2b269ac by Sylvain Henry at 2022-09-02T13:56:34-04:00 Testsuite: better fix for finding prefixed tools - - - - - 562249f9 by Sylvain Henry at 2022-09-02T13:56:34-04:00 Ppr: add hangBrace helper - - - - - d7af64ac by Sylvain Henry at 2022-09-02T13:56:34-04:00 Only declare ccs var in profiling mode - - - - - d878b3b7 by Sylvain Henry at 2022-09-02T13:56:34-04:00 Don't consider recursive bindings as inline nor as evaluated Fix mdo001 - - - - - 13505746 by Sylvain Henry at 2022-09-02T13:56:34-04:00 Hadrian: disable shared libs for JS target - - - - - 72166909 by Sylvain Henry at 2022-09-02T13:56:34-04:00 Support -ddump-stg-final with the JS backend - - - - - b281d6b9 by Sylvain Henry at 2022-09-02T13:56:35-04:00 Add ticky_ghc0 flavour transformer to ticky stage1 - - - - - b6ffebf5 by Sylvain Henry at 2022-09-02T13:56:35-04:00 Don't read object file when -ddump-js isn't passed - - - - - 1464f304 by Sylvain Henry at 2022-09-02T13:56:35-04:00 Object: remove dead code + renaming - - - - - 8df7f336 by Sylvain Henry at 2022-09-02T13:56:35-04:00 Object: replace SymbolTableR with Dictionary - - - - - 66d01077 by Sylvain Henry at 2022-09-02T13:56:35-04:00 Object: refactoring - - - - - 7655423f by Sylvain Henry at 2022-09-02T13:56:35-04:00 RTS: link platform.js before the others! - - - - - e0316e24 by Sylvain Henry at 2022-09-02T13:56:35-04:00 Hadrian: treat JS objects similarly to other objects - - - - - fb0662a0 by Luite Stegeman at 2022-09-02T13:56:36-04:00 fix javascript FFI calls for read and write - - - - - a606f872 by doyougnu at 2022-09-02T14:34:23-04:00 propagate ppr code changes to JS backend - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - boot - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/Tidy.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/add3cfd9bf129cfd8eeddafc17116c3b99beb91d...a606f87203a1c249437b1f182df091743e6c3194 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/add3cfd9bf129cfd8eeddafc17116c3b99beb91d...a606f87203a1c249437b1f182df091743e6c3194 You're receiving 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 Sep 6 16:16:57 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 06 Sep 2022 12:16:57 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Switch from Data.Binary and ByteString to BinHandle Message-ID: <63177279ca87d_869eb5143c200433@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 9956e89c by Sylvain Henry at 2022-09-06T18:17:15+02:00 Switch from Data.Binary and ByteString to BinHandle - - - - - 24773ce8 by Sylvain Henry at 2022-09-06T18:17:15+02:00 Perf: use Ppr's LeftMode to output JS - - - - - 11 changed files: - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/JS/Ppr.hs - compiler/GHC/StgToJS/CodeGen.hs - compiler/GHC/StgToJS/Linker/Archive.hs - compiler/GHC/StgToJS/Linker/Dynamic.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Linker/Types.hs - compiler/GHC/StgToJS/Object.hs - compiler/GHC/StgToJS/Types.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -15,7 +15,6 @@ module GHC.Iface.Binary ( readBinIface, readBinIfaceHeader, getSymtabName, - getDictFastString, CheckHiWay(..), TraceBinIFace(..), getWithUserData, @@ -24,11 +23,8 @@ module GHC.Iface.Binary ( -- * Internal serialisation functions getSymbolTable, putName, - putDictionary, - putFastString, putSymbolTable, BinSymbolTable(..), - BinDictionary(..) ) where import GHC.Prelude @@ -48,7 +44,6 @@ import GHC.Utils.Outputable import GHC.Types.Name.Cache import GHC.Types.SrcLoc import GHC.Platform -import GHC.Data.FastString import GHC.Settings.Constants import GHC.Utils.Fingerprint @@ -153,31 +148,28 @@ readBinIface profile name_cache checkHiWay traceBinIface hi_path = do -- Names or FastStrings. getWithUserData :: Binary a => NameCache -> BinHandle -> IO a getWithUserData name_cache bh = do + bh <- getTables name_cache bh + get bh + +-- | Setup a BinHandle to read something written using putWithTables +-- +-- Reading names has the side effect of adding them into the given NameCache. +getTables :: NameCache -> BinHandle -> IO BinHandle +getTables name_cache bh = do -- Read the dictionary -- The next word in the file is a pointer to where the dictionary is -- (probably at the end of the file) - dict_p <- Binary.get bh - data_p <- tellBin bh -- Remember where we are now - seekBin bh dict_p - dict <- getDictionary bh - seekBin bh data_p -- Back to where we were before + dict <- Binary.forwardGet bh (getDictionary bh) -- Initialise the user-data field of bh - bh <- do - bh <- return $ setUserData bh $ newReadState (error "getSymtabName") - (getDictFastString dict) - symtab_p <- Binary.get bh -- Get the symtab ptr - data_p <- tellBin bh -- Remember where we are now - seekBin bh symtab_p - symtab <- getSymbolTable bh name_cache - seekBin bh data_p -- Back to where we were before - - -- It is only now that we know how to get a Name - return $ setUserData bh $ newReadState (getSymtabName name_cache dict symtab) - (getDictFastString dict) - - -- Read the interface file - get bh + let bh_fs = setUserData bh $ newReadState (error "getSymtabName") + (getDictFastString dict) + + symtab <- Binary.forwardGet bh_fs (getSymbolTable bh_fs name_cache) + + -- It is only now that we know how to get a Name + return $ setUserData bh $ newReadState (getSymtabName name_cache dict symtab) + (getDictFastString dict) -- | Write an interface file writeBinIface :: Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () @@ -211,64 +203,63 @@ writeBinIface profile traceBinIface hi_path mod_iface = do -- This segment should be read using `getWithUserData`. putWithUserData :: Binary a => TraceBinIFace -> BinHandle -> a -> IO () putWithUserData traceBinIface bh payload = do - -- Remember where the dictionary pointer will go - dict_p_p <- tellBin bh - -- Placeholder for ptr to dictionary - put_ bh dict_p_p - - -- Remember where the symbol table pointer will go - symtab_p_p <- tellBin bh - put_ bh symtab_p_p - -- Make some initial state + (name_count, fs_count, _b) <- putWithTables bh (\bh' -> put bh' payload) + + case traceBinIface of + QuietBinIFace -> return () + TraceBinIFace printer -> do + printer (text "writeBinIface:" <+> int name_count + <+> text "Names") + printer (text "writeBinIface:" <+> int fs_count + <+> text "dict entries") + +-- | Write name/symbol tables +-- +-- 1. setup the given BinHandle with Name/FastString table handling +-- 2. write the following +-- - FastString table pointer +-- - Name table pointer +-- - payload +-- - Name table +-- - FastString table +-- +-- It returns (number of names, number of FastStrings, payload write result) +-- +putWithTables :: BinHandle -> (BinHandle -> IO b) -> IO (Int,Int,b) +putWithTables bh put_payload = do + -- initialize state for the name table and the FastString table. symtab_next <- newFastMutInt 0 symtab_map <- newIORef emptyUFM - let bin_symtab = BinSymbolTable { - bin_symtab_next = symtab_next, - bin_symtab_map = symtab_map } - dict_next_ref <- newFastMutInt 0 - dict_map_ref <- newIORef emptyUFM - let bin_dict = BinDictionary { - bin_dict_next = dict_next_ref, - bin_dict_map = dict_map_ref } - - -- Put the main thing, - bh <- return $ setUserData bh $ newWriteState (putName bin_dict bin_symtab) - (putName bin_dict bin_symtab) - (putFastString bin_dict) - put_ bh payload - - -- Write the symtab pointer at the front of the file - symtab_p <- tellBin bh -- This is where the symtab will start - putAt bh symtab_p_p symtab_p -- Fill in the placeholder - seekBin bh symtab_p -- Seek back to the end of the file - - -- Write the symbol table itself - symtab_next <- readFastMutInt symtab_next - symtab_map <- readIORef symtab_map - putSymbolTable bh symtab_next symtab_map - case traceBinIface of - QuietBinIFace -> return () - TraceBinIFace printer -> - printer (text "writeBinIface:" <+> int symtab_next - <+> text "Names") - - -- NB. write the dictionary after the symbol table, because - -- writing the symbol table may create more dictionary entries. - - -- Write the dictionary pointer at the front of the file - dict_p <- tellBin bh -- This is where the dictionary will start - putAt bh dict_p_p dict_p -- Fill in the placeholder - seekBin bh dict_p -- Seek back to the end of the file - - -- Write the dictionary itself - dict_next <- readFastMutInt dict_next_ref - dict_map <- readIORef dict_map_ref - putDictionary bh dict_next dict_map - case traceBinIface of - QuietBinIFace -> return () - TraceBinIFace printer -> - printer (text "writeBinIface:" <+> int dict_next - <+> text "dict entries") + let bin_symtab = BinSymbolTable + { bin_symtab_next = symtab_next + , bin_symtab_map = symtab_map + } + + (bh_fs, bin_dict, put_dict) <- initBinDictionary bh + + (fs_count,(name_count,r)) <- forwardPut bh (const put_dict) $ do + + -- NB. write the dictionary after the symbol table, because + -- writing the symbol table may create more dictionary entries. + let put_symtab = do + name_count <- readFastMutInt symtab_next + symtab_map <- readIORef symtab_map + putSymbolTable bh_fs name_count symtab_map + pure name_count + + forwardPut bh_fs (const put_symtab) $ do + + -- BinHandle with FastString and Name writing support + let ud_fs = getUserData bh_fs + let ud_name = ud_fs + { ud_put_nonbinding_name = putName bin_dict bin_symtab + , ud_put_binding_name = putName bin_dict bin_symtab + } + let bh_name = setUserData bh ud_name + + put_payload bh_name + + return (name_count, fs_count, r) @@ -287,9 +278,9 @@ binaryInterfaceMagic platform -- putSymbolTable :: BinHandle -> Int -> UniqFM Name (Int,Name) -> IO () -putSymbolTable bh next_off symtab = do - put_ bh next_off - let names = elems (array (0,next_off-1) (nonDetEltsUFM symtab)) +putSymbolTable bh name_count symtab = do + put_ bh name_count + let names = elems (array (0,name_count-1) (nonDetEltsUFM symtab)) -- It's OK to use nonDetEltsUFM here because the elements have -- indices that array uses to create order mapM_ (\n -> serialiseName bh n symtab) names @@ -392,30 +383,3 @@ data BinSymbolTable = BinSymbolTable { -- indexed by Name } -putFastString :: BinDictionary -> BinHandle -> FastString -> IO () -putFastString dict bh fs = allocateFastString dict fs >>= put_ bh - -allocateFastString :: BinDictionary -> FastString -> IO Word32 -allocateFastString BinDictionary { bin_dict_next = j_r, - bin_dict_map = out_r} f = do - out <- readIORef out_r - let !uniq = getUnique f - case lookupUFM_Directly out uniq of - Just (j, _) -> return (fromIntegral j :: Word32) - Nothing -> do - j <- readFastMutInt j_r - writeFastMutInt j_r (j + 1) - writeIORef out_r $! addToUFM_Directly out uniq (j, f) - return (fromIntegral j :: Word32) - -getDictFastString :: Dictionary -> BinHandle -> IO FastString -getDictFastString dict bh = do - j <- get bh - return $! (dict ! fromIntegral (j :: Word32)) - -data BinDictionary = BinDictionary { - bin_dict_next :: !FastMutInt, -- The next index to use - bin_dict_map :: !(IORef (UniqFM FastString (Int,FastString))) - -- indexed by FastString - } - ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -21,7 +21,6 @@ import GHC.Settings.Utils ( maybeRead ) import GHC.Settings.Config ( cProjectVersion ) import GHC.Prelude import GHC.Utils.Binary -import GHC.Iface.Binary ( getDictFastString ) import GHC.Data.FastMutInt import GHC.Data.FastString ( FastString ) import GHC.Types.Name ===================================== compiler/GHC/JS/Ppr.hs ===================================== @@ -63,10 +63,10 @@ renderJs' :: (JsToDoc a, JMacro a) => RenderJs -> a -> Doc renderJs' r = jsToDocR r . jsSaturate Nothing data RenderJs = RenderJs - { renderJsS :: RenderJs -> JStat -> Doc - , renderJsE :: RenderJs -> JExpr -> Doc - , renderJsV :: RenderJs -> JVal -> Doc - , renderJsI :: RenderJs -> Ident -> Doc + { renderJsS :: !(RenderJs -> JStat -> Doc) + , renderJsE :: !(RenderJs -> JExpr -> Doc) + , renderJsV :: !(RenderJs -> JVal -> Doc) + , renderJsI :: !(RenderJs -> Ident -> Doc) } defaultRenderJs :: RenderJs ===================================== compiler/GHC/StgToJS/CodeGen.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE BlockArguments #-} +{-# LANGUAGE LambdaCase #-} -- | JavaScript code generator module GHC.StgToJS.CodeGen @@ -52,16 +53,13 @@ import GHC.Utils.Encoding import GHC.Utils.Logger import GHC.Utils.Panic import GHC.Utils.Misc +import GHC.Utils.Binary import qualified Control.Monad.Trans.State.Strict as State import GHC.Utils.Outputable hiding ((<>)) import qualified Data.Set as S -import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as BL import Data.Monoid import Control.Monad -import Control.Monad.Trans.Class -import Data.Bifunctor -- | Code generator for JavaScript stgToJS @@ -82,26 +80,21 @@ stgToJS logger config stg_binds0 this_mod spt_entries foreign_stubs cccs output_ -- TODO: add dump pass for optimized STG ast for JS - obj <- runG config this_mod unfloated_binds $ do - ifProfilingM $ initCostCentres cccs - (sym_table, lus) <- genUnits this_mod stg_binds spt_entries foreign_stubs - - -- (exported symbol names, javascript statements) for each linkable unit - p <- forM lus \u -> do - ts <- mapM (fmap (\(TxtI i) -> i) . identForId) (luIdExports u) - return (ts ++ luOtherExports u, luStat u) - - deps <- genDependencyData this_mod lus - lift $ Object.writeObject' (moduleName this_mod) sym_table deps (map (second BL.fromStrict) p) + (deps,lus) <- runG config this_mod unfloated_binds $ do + ifProfilingM $ initCostCentres cccs + lus <- genUnits this_mod stg_binds spt_entries foreign_stubs + deps <- genDependencyData this_mod lus + pure (deps,lus) -- Doc to dump when -ddump-js is enabled - let mod_name = renderWithContext defaultSDocContext (ppr this_mod) when (logHasDumpFlag logger Opt_D_dump_js) $ do - o <- Object.readObject mod_name obj putDumpFileMaybe logger Opt_D_dump_js "JavaScript code" FormatJS - $ vcat (fmap (docToSDoc . jsToDoc . Object.oiStat) o) + $ vcat (fmap (docToSDoc . jsToDoc . oiStat . luObjUnit) lus) - BL.writeFile output_fn obj + -- Write the object file + bh <- openBinMem (4 * 1024 * 1000) -- a bit less than 4kB + Object.putObject bh (moduleName this_mod) deps (map luObjUnit lus) + writeBinMem bh output_fn @@ -111,53 +104,59 @@ genUnits :: HasDebugCallStack -> [CgStgTopBinding] -> [SptEntry] -> ForeignStubs - -> G (Object.SymbolTable, [LinkableUnit]) -- ^ the final symbol table and the linkable units -genUnits m ss spt_entries foreign_stubs - = generateGlobalBlock =<< - generateExportsBlock =<< - go 2 Object.emptySymbolTable ss + -> G [LinkableUnit] -- ^ the linkable units +genUnits m ss spt_entries foreign_stubs = do + gbl <- generateGlobalBlock + exports <- generateExportsBlock + others <- go 2 ss + pure (gbl:exports:others) where go :: HasDebugCallStack => Int -- the block we're generating (block 0 is the global unit for the module) - -> Object.SymbolTable -- the shared symbol table -> [CgStgTopBinding] - -> G (Object.SymbolTable, [LinkableUnit]) - go !n st (x:xs) = do - (st', mlu) <- generateBlock st x n - (st'', lus) <- go (n+1) st' xs - return (st'', maybe lus (:lus) mlu) - go _ st [] = return (st, []) + -> G [LinkableUnit] + go !n = \case + [] -> pure [] + (x:xs) -> do + mlu <- generateBlock x n + lus <- go (n+1) xs + return (maybe lus (:lus) mlu) -- Generate the global unit that all other blocks in the module depend on -- used for cost centres and static initializers -- the global unit has no dependencies, exports the moduleGlobalSymbol - generateGlobalBlock :: HasDebugCallStack - => (Object.SymbolTable, [LinkableUnit]) - -> G (Object.SymbolTable, [LinkableUnit]) - generateGlobalBlock (st, lus) = do + generateGlobalBlock :: HasDebugCallStack => G LinkableUnit + generateGlobalBlock = do glbl <- State.gets gsGlobal staticInit <- initStaticPtrs spt_entries - (st', _, bs) <- serializeLinkableUnit m st [] [] [] - ( -- O.optimize . - jsSaturate (Just $ modulePrefix m 1) - $ mconcat (reverse glbl) <> staticInit) "" [] [] - return ( st' - , LinkableUnit bs - [] - [moduleGlobalSymbol m] - [] - [] - [] - False - [] - : lus - ) - - generateExportsBlock :: HasDebugCallStack - => (Object.SymbolTable, [LinkableUnit]) - -> G (Object.SymbolTable, [LinkableUnit]) - generateExportsBlock (st, lus) = do + let stat = ( -- O.optimize . + jsSaturate (Just $ modulePrefix m 1) + $ mconcat (reverse glbl) <> staticInit) + let syms = [moduleGlobalSymbol m] + let oi = ObjUnit + { oiSymbols = syms + , oiClInfo = [] + , oiStatic = [] + , oiStat = stat + , oiRaw = mempty + , oiFExports = [] + , oiFImports = [] + } + let lu = LinkableUnit + { luObjUnit = oi + , luIdExports = [] + , luOtherExports = syms + , luIdDeps = [] + , luPseudoIdDeps = [] + , luOtherDeps = [] + , luRequired = False + , luForeignRefs = [] + } + pure lu + + generateExportsBlock :: HasDebugCallStack => G LinkableUnit + generateExportsBlock = do let (f_hdr, f_c) = case foreign_stubs of NoStubs -> (empty, empty) ForeignStubs hdr c -> (getCHeader hdr, getCStub c) @@ -165,87 +164,107 @@ genUnits m ss spt_entries foreign_stubs mkUniqueDep (tag:xs) = mkUnique tag (read xs) mkUniqueDep [] = panic "mkUniqueDep" - (st', _, bs) <- serializeLinkableUnit m - st - [] - [] - [] - mempty - (mkFastString $ renderWithContext defaultSDocContext f_c) - [] - [] - return ( st' - , LinkableUnit bs - [] - [moduleExportsSymbol m] - [] -- id deps - unique_deps -- pseudo id deps - [] - True - [] - : lus - ) + let syms = [moduleExportsSymbol m] + let raw = utf8EncodeByteString $ renderWithContext defaultSDocContext f_c + let oi = ObjUnit + { oiSymbols = syms + , oiClInfo = [] + , oiStatic = [] + , oiStat = mempty + , oiRaw = raw + , oiFExports = [] + , oiFImports = [] + } + let lu = LinkableUnit + { luObjUnit = oi + , luIdExports = [] + , luOtherExports = syms + , luIdDeps = [] + , luPseudoIdDeps = unique_deps + , luOtherDeps = [] + , luRequired = True + , luForeignRefs = [] + } + pure lu -- Generate the linkable unit for one binding or group of -- mutually recursive bindings generateBlock :: HasDebugCallStack - => Object.SymbolTable - -> CgStgTopBinding + => CgStgTopBinding -> Int - -> G (Object.SymbolTable, Maybe LinkableUnit) - generateBlock st (StgTopStringLit bnd str) n = do - bids <- identsForId bnd - case bids of - [(TxtI b1t),(TxtI b2t)] -> do - -- [e1,e2] <- genLit (MachStr str) - emitStatic b1t (StaticUnboxed (StaticUnboxedString str)) Nothing - emitStatic b2t (StaticUnboxed (StaticUnboxedStringOffset str)) Nothing - _extraTl <- State.gets (ggsToplevelStats . gsGroup) - si <- State.gets (ggsStatic . gsGroup) - let stat = mempty -- mconcat (reverse extraTl) <> b1 ||= e1 <> b2 ||= e2 - (st', _ss, bs) <- serializeLinkableUnit m st [bnd] [] si - (jsSaturate (Just $ modulePrefix m n) stat) "" [] [] - pure (st', Just $ LinkableUnit bs [bnd] [] [] [] [] False []) - _ -> panic "generateBlock: invalid size" - generateBlock st (StgTopLifted decl) n = do - tl <- genToplevel decl - extraTl <- State.gets (ggsToplevelStats . gsGroup) - ci <- State.gets (ggsClosureInfo . gsGroup) - si <- State.gets (ggsStatic . gsGroup) - unf <- State.gets gsUnfloated - extraDeps <- State.gets (ggsExtraDeps . gsGroup) - fRefs <- State.gets (ggsForeignRefs . gsGroup) - resetGroup - let allDeps = collectIds unf decl - topDeps = collectTopIds decl - required = hasExport decl - stat = -- Opt.optimize . - jsSaturate (Just $ modulePrefix m n) - $ mconcat (reverse extraTl) <> tl - (st', _ss, bs) <- serializeLinkableUnit m st topDeps ci si stat mempty [] fRefs - return $! seqList topDeps `seq` seqList allDeps `seq` st' `seq` - (st', Just $ LinkableUnit bs topDeps [] allDeps [] (S.toList extraDeps) required fRefs) - --- | serialize the payload of a linkable unit in the object file, adding strings --- to the SymbolTable where necessary -serializeLinkableUnit :: HasDebugCallStack - => Module - -> Object.SymbolTable -- symbol table to start with - -> [Id] -- id's exported by unit - -> [ClosureInfo] - -> [StaticInfo] - -> JStat -- generated code for the unit - -> FastString - -> [Object.ExpFun] - -> [ForeignJSRef] - -> G (Object.SymbolTable, [FastString], BS.ByteString) -serializeLinkableUnit _m st i ci si stat rawStat fe fi = do - !i' <- mapM idStr i - !(!st', !lo) <- lift $ Object.runPutS st $ \bh -> Object.putLinkableUnit bh ci si stat rawStat fe fi - let !o = BL.toStrict lo - return (st', i', o) -- deepseq results? - where - idStr i = itxt <$> identForId i + -> G (Maybe LinkableUnit) + generateBlock top_bind n = case top_bind of + StgTopStringLit bnd str -> do + bids <- identsForId bnd + case bids of + [(TxtI b1t),(TxtI b2t)] -> do + -- [e1,e2] <- genLit (MachStr str) + emitStatic b1t (StaticUnboxed (StaticUnboxedString str)) Nothing + emitStatic b2t (StaticUnboxed (StaticUnboxedStringOffset str)) Nothing + _extraTl <- State.gets (ggsToplevelStats . gsGroup) + si <- State.gets (ggsStatic . gsGroup) + let body = mempty -- mconcat (reverse extraTl) <> b1 ||= e1 <> b2 ||= e2 + let stat = jsSaturate (Just $ modulePrefix m n) body + let ids = [bnd] + syms <- (\(TxtI i) -> [i]) <$> identForId bnd + let oi = ObjUnit + { oiSymbols = syms + , oiClInfo = [] + , oiStatic = si + , oiStat = stat + , oiRaw = "" + , oiFExports = [] + , oiFImports = [] + } + let lu = LinkableUnit + { luObjUnit = oi + , luIdExports = ids + , luOtherExports = [] + , luIdDeps = [] + , luPseudoIdDeps = [] + , luOtherDeps = [] + , luRequired = False + , luForeignRefs = [] + } + pure (Just lu) + _ -> panic "generateBlock: invalid size" + + StgTopLifted decl -> do + tl <- genToplevel decl + extraTl <- State.gets (ggsToplevelStats . gsGroup) + ci <- State.gets (ggsClosureInfo . gsGroup) + si <- State.gets (ggsStatic . gsGroup) + unf <- State.gets gsUnfloated + extraDeps <- State.gets (ggsExtraDeps . gsGroup) + fRefs <- State.gets (ggsForeignRefs . gsGroup) + resetGroup + let allDeps = collectIds unf decl + topDeps = collectTopIds decl + required = hasExport decl + stat = -- Opt.optimize . + jsSaturate (Just $ modulePrefix m n) + $ mconcat (reverse extraTl) <> tl + syms <- mapM (fmap (\(TxtI i) -> i) . identForId) topDeps + let oi = ObjUnit + { oiSymbols = syms + , oiClInfo = ci + , oiStatic = si + , oiStat = stat + , oiRaw = "" + , oiFExports = [] + , oiFImports = fRefs + } + let lu = LinkableUnit + { luObjUnit = oi + , luIdExports = topDeps + , luOtherExports = [] + , luIdDeps = allDeps + , luPseudoIdDeps = [] + , luOtherDeps = S.toList extraDeps + , luRequired = required + , luForeignRefs = fRefs + } + pure $! seqList topDeps `seq` seqList allDeps `seq` Just lu -- | variable prefix for the nth block in module modulePrefix :: Module -> Int -> FastString ===================================== compiler/GHC/StgToJS/Linker/Archive.hs ===================================== @@ -1,6 +1,5 @@ -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE LambdaCase #-} ----------------------------------------------------------------------------- -- | @@ -17,174 +16,133 @@ ----------------------------------------------------------------------------- module GHC.StgToJS.Linker.Archive ( Entry(..), Index, IndexEntry(..), Meta(..) - , buildArchive + , writeArchive , readMeta, readIndex - , readSource, readAllSources - , readObject, withObject, withAllObjects + , getArchiveEntries + , getArchiveEntry ) where -import Control.Monad - -import Data.Binary -import Data.Binary.Get -import Data.Binary.Put -import Data.ByteString.Lazy (ByteString) -import qualified Data.ByteString.Lazy as B -import Data.Data -import Data.Int -import GHC.Data.ShortText (ShortText) -import qualified GHC.Data.ShortText as T - -import GHC.Generics hiding (Meta) - -import System.IO import Prelude +import Data.ByteString (ByteString) +import Data.Word +import Control.Monad -import GHC.Unit.Module - -import GHC.StgToJS.Object ( versionTag, versionTagLength ) +import GHC.Unit.Module +import GHC.Utils.Binary +import GHC.Utils.Panic +import GHC.Utils.Monad +import GHC.Settings.Constants (hiVersion) --- entry, offset in data section, length type Index = [IndexEntry] -data IndexEntry = IndexEntry { ieEntry :: Entry - , ieOffset :: Int64 - , ieLength :: Int64 - } deriving (Show, Typeable, Generic) - -instance Binary IndexEntry - -data Entry = Object ShortText -- module name - | JsSource FilePath - deriving (Show, Typeable, Generic) - -instance Binary Entry - -data Meta = Meta { metaCppOptions :: [String] - } deriving (Show, Typeable, Generic) - -instance Binary Meta - --- sizes of the sections in bytes -data Sections = Sections { sectionIndex :: !Word64 - , sectionMeta :: !Word64 - , sectionData :: !Word64 - } deriving (Eq, Ord, Generic) - -instance Binary Sections where - put (Sections i m d) = putWord64le i >> putWord64le m >> putWord64le d - get = Sections <$> getWord64le <*> getWord64le <*> getWord64le - -sectionsLength :: Int -sectionsLength = 24 - -buildArchive :: Meta -> [(Entry, ByteString)] -> ByteString -buildArchive meta entries = - versionTag <> sections <> index <> meta' <> entries' - where - bl = fromIntegral . B.length - sections = runPut . put $ Sections (bl index) (bl meta') (bl entries') - meta' = runPut (put meta) - index = runPut . put $ scanl1 (\(IndexEntry _ o l) (IndexEntry e _ l') -> IndexEntry e (o+l) l') $ - map (\(e,b) -> IndexEntry e 0 (B.length b)) entries - entries' = mconcat (map snd entries) +data IndexEntry = IndexEntry + { ieEntry :: !Entry -- ^ Entry identifier + , ieOffset :: !(Bin ByteString) -- ^ Offset in the archive + } deriving (Show) + +instance Binary IndexEntry where + put_ bh (IndexEntry a b) = do + put_ bh a + put_ bh b + get bh = IndexEntry <$> get bh <*> get bh + +data Entry + = Object !ModuleName + | JsSource !FilePath + deriving (Show) + +instance Binary Entry where + put_ bh = \case + Object m -> putByte bh 0 >> put_ bh m + JsSource p -> putByte bh 1 >> put_ bh p + get bh = getByte bh >>= \case + 0 -> Object <$> get bh + _ -> JsSource <$> get bh + + +data Meta = Meta + { metaCppOptions :: [String] + } + +instance Binary Meta where + put_ bh (Meta a) = put_ bh a + get bh = Meta <$> get bh + +magic :: FixedLengthEncoding Word64 +magic = FixedLengthEncoding 0x435241534a434847 -- "GHCJSARC" + +writeArchive :: FilePath -> Meta -> [(Entry, ByteString)] -> IO () +writeArchive path meta entries = do + bh <- openBinMem (4*1024*1000) + put_ bh magic + put_ bh (show hiVersion) + + put_ bh meta + + -- forward put the index + forwardPut_ bh (put_ bh) $ do + idx <- forM entries $ \(e,bs) -> do + p <- tellBin bh + put_ bh bs + pure $ IndexEntry + { ieEntry = e + , ieOffset = p + } + pure idx + + writeBinMem bh path + +data Header = Header + { hdrMeta :: !Meta + , hdrIndex :: !Index + , hdrHandle :: !BinHandle + } + +getArchiveHeader :: BinHandle -> IO Header +getArchiveHeader bh = do + is_magic <- (== magic) <$> get bh + unless is_magic $ panic "getArchiveHeader: invalid magic header" + + is_correct_version <- ((== hiVersion) . read) <$> get bh + unless is_correct_version $ panic "getArchiveHeader: invalid header version" + + meta <- get bh + idx <- forwardGet bh (get bh) + pure $ Header + { hdrMeta = meta + , hdrIndex = idx + , hdrHandle = bh + } readMeta :: FilePath -> IO Meta -readMeta file = withBinaryFile file ReadMode $ \h -> do - sections <- hReadHeader ("readMeta " ++ file) h - hSeek h RelativeSeek (toInteger $ sectionIndex sections) - m <- B.hGet h (fromIntegral $ sectionMeta sections) - return $! runGet get m +readMeta file = do + bh <- readBinMem file + hdr <- getArchiveHeader bh + pure $! hdrMeta hdr readIndex :: FilePath -> IO Index -readIndex file = - withArchive "readIndex" file $ \_sections index _h -> return index - -readSource :: FilePath -> FilePath -> IO ByteString -readSource source file = withArchive "readSource" file $ - withEntry ("readSource " ++ file) - ("source file " ++ source) - selectSrc - (\h l -> B.hGet h $ fromIntegral l) +readIndex file = do + bh <- readBinMem file + hdr <- getArchiveHeader bh + pure $! hdrIndex hdr + +getArchiveEntries :: Header -> (Entry -> Bool) -> IO [ByteString] +getArchiveEntries hdr pred = mapMaybeM read_entry (hdrIndex hdr) where - selectSrc (JsSource src) = src == source - selectSrc _ = False - -readAllSources :: FilePath -> IO [(FilePath, ByteString)] -readAllSources file = withArchive "readAllSources" file $ \sections index h -> - forM [ (o, l, src) | IndexEntry (JsSource src) o l <- index ] $ \(o, l, src) -> do - hSeek h AbsoluteSeek (fromIntegral $ dataSectionStart sections + fromIntegral o) - (src,) <$> B.hGet h (fromIntegral l) - -readObject :: ModuleName -> FilePath -> IO ByteString -readObject m file = withArchive "readObject" file $ - withModuleObject ("readObject " ++ file) m (\h l -> B.hGet h $ fromIntegral l) - --- | seeks to the starting position of the object in the file -withObject :: ModuleName -> FilePath -> (Handle -> Int64 -> IO a) -> IO a -withObject m file f = withArchive "withObject" file $ - withModuleObject ("withObject " ++ file) m f - - -withAllObjects :: FilePath -> (ModuleName -> Handle -> Int64 -> IO a) -> IO [a] -withAllObjects file f = withArchive "withAllObjects" file $ \sections index h -> - forM [ (o, l, mn) | IndexEntry (Object mn) o l <- index ] $ \(o, l, mn) -> do - hSeek h AbsoluteSeek (fromIntegral $ dataSectionStart sections + fromIntegral o) - f (mkModuleName (T.unpack mn)) h l - ---------------------------------------------------------------------------------- - -withArchive :: String -> FilePath -> (Sections -> Index -> Handle -> IO a) -> IO a -withArchive name file f = withBinaryFile file ReadMode $ \h -> do - let name' = name ++ " " ++ file - putStrLn ("reading archive: " ++ name ++ " -> " ++ file) - sections <- hReadHeader name' h - index <- hReadIndex name' sections h - f sections index h - --- | seeks to start of entry data in file, then runs the action --- exactly one matching entry is expected -withEntry :: String -> String - -> (Entry -> Bool) -> (Handle -> Int64 -> IO a) - -> Sections -> Index -> Handle - -> IO a -withEntry name entryName p f sections index h = - case filter (p . ieEntry) index of - [] -> error (name ++ ": cannot find " ++ entryName) - [IndexEntry _ o l] -> do - hSeek h AbsoluteSeek (dataSectionStart sections + toInteger o) - f h (fromIntegral l) - _ -> error (name ++ ": multiple matches for " ++ entryName) - -withModuleObject :: String -> ModuleName -> (Handle -> Int64 -> IO a) - -> Sections -> Index -> Handle - -> IO a -withModuleObject name m f = - withEntry name ("object for module " ++ ms) selectEntry f + bh = hdrHandle hdr + read_entry (IndexEntry e offset) + | pred e = do + seekBin bh offset + Just <$> get bh + | otherwise = pure Nothing + +getArchiveEntry :: Header -> (Entry -> Bool) -> IO (Maybe ByteString) +getArchiveEntry hdr pred = go (hdrIndex hdr) where - ms = moduleNameString m - mt = T.pack ms - selectEntry (Object m') = mt == m' - selectEntry _ = False - --- | expects Handle to be positioned at the start of the header --- Handle is positioned at start of index after return -hReadHeader :: String -> Handle -> IO Sections -hReadHeader name h = do - ts <- B.hGet h (versionTagLength + sectionsLength) - when (B.take (fromIntegral versionTagLength) ts /= versionTag) - (error $ name ++ ": version tag mismatch") - return $! runGet get (B.drop (fromIntegral versionTagLength) ts) - --- | expects Handle to be positioned at the start of the index --- Handle is positioned at start of metadata section after return -hReadIndex :: String -> Sections -> Handle -> IO Index -hReadIndex _name s h = do - i <- B.hGet h (fromIntegral $ sectionIndex s) - return $! runGet get i - --- start of data section in file -dataSectionStart :: Sections -> Integer -dataSectionStart s = toInteger (versionTagLength + sectionsLength) - + toInteger (sectionIndex s + sectionMeta s) + bh = hdrHandle hdr + go = \case + (IndexEntry e offset:es) + | pred e -> seekBin bh offset >> (Just <$> get bh) + | otherwise -> go es + [] -> pure Nothing ===================================== compiler/GHC/StgToJS/Linker/Dynamic.hs ===================================== @@ -21,8 +21,12 @@ module GHC.StgToJS.Linker.Dynamic ( jsLinkBinary , jsLinkLib - ) where + ) +where +import GHC.Driver.Session + +import GHC.StgToJS.Types import GHC.StgToJS.Linker.Archive import GHC.StgToJS.Linker.Types import GHC.StgToJS.Linker.Utils @@ -32,7 +36,6 @@ import GHC.Linker.Types import GHC.Unit.Module import GHC.Unit.Module.ModIface -import GHC.Driver.Session import GHC.Types.Unique.DFM import GHC.Types.Basic @@ -44,15 +47,12 @@ import Prelude import Control.Monad -import qualified Data.ByteString.Lazy as B import qualified Data.ByteString as BS import Data.List ( nub ) -import qualified GHC.Data.ShortText as T import System.FilePath import GHC.Platform.Ways import GHC.Utils.Logger -import GHC.StgToJS.Types import GHC.Utils.TmpFs (TmpFs) --------------------------------------------------------------------------------- @@ -77,13 +77,13 @@ jsLinkLib settings jsFiles dflags _logger hpt jsFiles' = nub (lcJsLibSrcs settings ++ jsFiles) meta = Meta (opt_P dflags) jsEntries <- forM jsFiles' $ \file -> - (JsSource file,) . B.fromStrict <$> BS.readFile file + (JsSource file,) <$> BS.readFile file objEntries <- forM (eltsUDFM hpt) $ \hmi -> do - let mt = T.pack . moduleNameString . moduleName . mi_module . hm_iface $ hmi + let mod_name = moduleName . mi_module . hm_iface $ hmi files = maybe [] (\l -> [ o | DotO o <- linkableUnlinked l]) (hm_linkable hmi) -- fixme archive does not handle multiple files for a module yet - forM files (fmap ((Object mt,) . B.fromStrict) . BS.readFile) - B.writeFile outputFile (buildArchive meta (concat objEntries ++ jsEntries)) + forM files (fmap ((Object mod_name,)) . BS.readFile) + writeArchive outputFile meta (concat objEntries ++ jsEntries) -- we don't use shared js_so libraries ourselves, but Cabal expects that we -- generate one when building with --dynamic-too. Just write an empty file when (gopt Opt_BuildDynamicToo dflags || WayDyn `elem` ways dflags) $ do ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -66,7 +66,7 @@ import Data.IntSet (IntSet) import qualified Data.IntSet as IS import Data.IORef import Data.List ( partition, nub, foldl', intercalate, group, sort - , groupBy, isSuffixOf, find, intersperse + , groupBy, intersperse ) import Data.Map.Strict (Map) import qualified Data.Map.Strict as M @@ -77,15 +77,13 @@ import Data.Word import GHC.Generics (Generic) -import System.FilePath (splitPath, (<.>), (), dropExtension, isExtensionOf) -import System.Environment (lookupEnv) +import System.FilePath (splitPath, (<.>), (), dropExtension) import System.Directory ( createDirectoryIfMissing , doesFileExist , getCurrentDirectory , Permissions(..) , setPermissions , getPermissions - , listDirectory ) import GHC.Driver.Session (targetWays_, DynFlags(..)) @@ -93,6 +91,8 @@ import Language.Haskell.Syntax.Module.Name import GHC.Unit.Module (moduleStableString) import GHC.Utils.Logger (Logger, logVerbAtLeast) import GHC.Utils.TmpFs (TmpFs) +import GHC.Utils.Binary +import GHC.Utils.Ppr (Style(..), renderStyle, Mode(..)) import GHC.Linker.Static.Utils (exeFileName) @@ -102,14 +102,14 @@ newtype LinkerStats = LinkerStats -- | result of a link pass data LinkResult = LinkResult - { linkOut :: B.ByteString -- ^ compiled Haskell code - , linkOutStats :: LinkerStats -- ^ statistics about generated code - , linkOutMetaSize :: Int64 -- ^ size of packed metadata in generated code - , linkForeignRefs :: [ForeignJSRef] -- ^ foreign code references in compiled haskell code - , linkLibRTS :: [FilePath] -- ^ library code to load with the RTS - , linkLibA :: [FilePath] -- ^ library code to load after RTS - , linkLibAArch :: [FilePath] -- ^ library code to load from archives after RTS - , linkBase :: Base -- ^ base metadata to use if we want to link incrementally against this result + { linkOut :: FilePath -> IO () -- ^ compiled Haskell code + , linkOutStats :: LinkerStats -- ^ statistics about generated code + , linkOutMetaSize :: Int64 -- ^ size of packed metadata in generated code + , linkForeignRefs :: [ForeignJSRef] -- ^ foreign code references in compiled haskell code + , linkLibRTS :: [FilePath] -- ^ library code to load with the RTS + , linkLibA :: [FilePath] -- ^ library code to load after RTS + , linkLibAArch :: [FilePath] -- ^ library code to load from archives after RTS + , linkBase :: Base -- ^ base metadata to use if we want to link incrementally against this result } deriving (Generic) newtype ArchiveState = ArchiveState { loadedArchives :: IORef (Map FilePath Ar.Archive) } @@ -143,7 +143,7 @@ link env lc_cfg cfg logger tmpfs dflags unit_env out include pkgs objFiles jsFil jsExt | genBase = "base.js" | otherwise = "js" createDirectoryIfMissing False out - B.writeFile (out "out" <.> jsExt) (linkOut link_res) + linkOut link_res (out "out" <.> jsExt) -- dump foreign references file (.frefs) unless (lcOnlyOut lc_cfg) $ do @@ -167,12 +167,13 @@ link env lc_cfg cfg logger tmpfs dflags unit_env out include pkgs objFiles jsFil let all_lib_js = linkLibA link_res lla' <- streamShims <$> readShimFiles logger tmpfs dflags unit_env all_lib_js - llarch' <- mapM (readShimsArchive dflags) (linkLibAArch link_res) + llarch' <- mapM readShimsArchive (linkLibAArch link_res) let lib_js = BL.fromChunks $! llarch' ++ lla' BL.writeFile (out "lib" <.> jsExt) lib_js if genBase - then generateBase out (linkBase link_res) + then panic "support for base bundle not implemented" + -- generateBase out (linkBase link_res) else when ( not (lcOnlyOut lc_cfg) && not (lcNoRts lc_cfg) && not (usingBase lc_cfg) @@ -184,8 +185,8 @@ link env lc_cfg cfg logger tmpfs dflags unit_env out include pkgs objFiles jsFil writeRunner lc_cfg out writeExterns out -readShimsArchive :: DynFlags -> FilePath -> IO B.ByteString -readShimsArchive dflags ar_file = do +readShimsArchive :: FilePath -> IO B.ByteString +readShimsArchive ar_file = do (Ar.Archive entries) <- Ar.loadAr ar_file jsdata <- catMaybes <$> mapM readEntry entries return (B.intercalate "\n" jsdata) @@ -231,7 +232,7 @@ link' env lc_cfg cfg dflags logger unit_env target _include pkgs objFiles _jsFil base <- case lcUseBase lc_cfg of NoBase -> return emptyBase - BaseFile file -> loadBase file + BaseFile _file -> panic "support for base bundle not implemented" -- loadBase file BaseState b -> return b let (rdPkgs, rds) = rtsDeps pkgs @@ -269,9 +270,8 @@ link' env lc_cfg cfg dflags logger unit_env target _include pkgs objFiles _jsFil -- retrieve code for dependencies code <- collectDeps dep_map dep_units all_deps - let (outJs, metaSize, compactorState, stats) = - renderLinker lc_cfg cfg (baseCompactorState base) rds code - base' = Base compactorState (nub $ basePkgs base ++ pkgs'') + (outJs, metaSize, compactorState, stats) <- renderLinker lc_cfg cfg (baseCompactorState base) rds code + let base' = Base compactorState (nub $ basePkgs base ++ pkgs'') (all_deps `S.union` baseUnits base) return $ LinkResult @@ -299,7 +299,7 @@ link' env lc_cfg cfg dflags logger unit_env target _include pkgs objFiles _jsFil data ModuleCode = ModuleCode { mc_module :: !Module , mc_js_code :: !JStat - , mc_exports :: !FastString -- ^ rendered exports + , mc_exports :: !B.ByteString -- ^ rendered exports , mc_closures :: ![ClosureInfo] , mc_statics :: ![StaticInfo] , mc_frefs :: ![ForeignJSRef] @@ -311,36 +311,50 @@ renderLinker -> CompactorState -> Set ExportedFun -> [ModuleCode] -- ^ linked code per module - -> (B.ByteString, Int64, CompactorState, LinkerStats) -renderLinker settings cfg renamer_state rtsDeps code = - ( rendered_all - , meta_length - , renamer_state' - , stats - ) - where - -- extract ModuleCode fields required to make a LinkedUnit - code_to_linked_unit c = LinkedUnit - { lu_js_code = mc_js_code c - , lu_closures = mc_closures c - , lu_statics = mc_statics c - } - -- call the compactor - (renamer_state', compacted, meta) = compact settings cfg renamer_state - (map ((\(LexicalFastString f) -> f) . funSymbol) $ S.toList rtsDeps) - (map code_to_linked_unit code) + -> IO (FilePath -> IO (), Int64, CompactorState, LinkerStats) +renderLinker settings cfg renamer_state rtsDeps code = do + + -- extract ModuleCode fields required to make a LinkedUnit + let code_to_linked_unit c = LinkedUnit + { lu_js_code = mc_js_code c + , lu_closures = mc_closures c + , lu_statics = mc_statics c + } + + -- call the compactor + let (renamer_state', compacted, meta) = compact settings cfg renamer_state + (map ((\(LexicalFastString f) -> f) . funSymbol) $ S.toList rtsDeps) + (map code_to_linked_unit code) + let + render_all fp = do + BL.writeFile fp rendered_all + -- render result into JS code rendered_all = mconcat [mconcat rendered_mods, rendered_meta, rendered_exports] rendered_mods = fmap render_js compacted rendered_meta = render_js meta - render_js = BC.pack . (<>"\n") . show . pretty - rendered_exports = BC.concat . map bytesFS . filter (not . nullFS) $ map mc_exports code - meta_length = fromIntegral (BC.length rendered_meta) + doc_str = renderStyle (Style + { lineLength = 100 + , ribbonsPerLine = 1.5 + , mode = LeftMode + -- Faster to write but uglier code. + -- Use "PageMode False" to enable nicer code instead + }) + render_js x = BL.fromChunks [BC.pack (doc_str (pretty x)), BC.pack "\n"] + rendered_exports = BL.fromChunks (map mc_exports code) + meta_length = fromIntegral (BL.length rendered_meta) -- make LinkerStats entry for the given ModuleCode. -- For now, only associate generated code size in bytes to each module - mk_stat c b = (mc_module c, fromIntegral . BC.length $ b) + mk_stat c b = (mc_module c, fromIntegral . BL.length $ b) stats = LinkerStats $ M.fromList $ zipWith mk_stat code rendered_mods + pure + ( render_all + , meta_length + , renamer_state' + , stats + ) + -- | Render linker stats linkerStats :: Int64 -- ^ code size of packed metadata -> LinkerStats -- ^ code size per module @@ -567,30 +581,33 @@ extractDeps :: ArchiveState extractDeps ar_state units deps loc = case M.lookup mod units of Nothing -> return Nothing - Just modUnits -> do - let selector n _ = n `IS.member` modUnits || isGlobalUnit n - x <- case loc of - ObjectFile o -> collectCode =<< readObjectFileKeys selector o - ArchiveFile a -> (collectCode - <=< readObjectKeys (a ++ ':':moduleNameString (moduleName mod)) selector) - =<< readArObject ar_state mod a - InMemory n b -> collectCode =<< readObjectKeys n selector b - return x + Just mod_units -> Just <$> do + let selector n _ = fromIntegral n `IS.member` mod_units || isGlobalUnit (fromIntegral n) + case loc of + ObjectFile fp -> do + us <- readObjectUnits fp selector + pure (collectCode us) + ArchiveFile a -> do + obj <- readArObject ar_state mod a + us <- getObjectUnits obj selector + pure (collectCode us) + InMemory _n obj -> do + us <- getObjectUnits obj selector + pure (collectCode us) where mod = depsModule deps - newline = mkFastString "\n" + newline = BC.pack "\n" unlines' = intersperse newline . map oiRaw - collectCode l = let x = ModuleCode - { mc_module = mod - , mc_js_code = mconcat (map oiStat l) - , mc_exports = mconcat (unlines' l) - , mc_closures = concatMap oiClInfo l - , mc_statics = concatMap oiStatic l - , mc_frefs = concatMap oiFImports l - } - in return (Just x) - -readArObject :: ArchiveState -> Module -> FilePath -> IO BL.ByteString + collectCode l = ModuleCode + { mc_module = mod + , mc_js_code = mconcat (map oiStat l) + , mc_exports = mconcat (unlines' l) + , mc_closures = concatMap oiClInfo l + , mc_statics = concatMap oiStatic l + , mc_frefs = concatMap oiFImports l + } + +readArObject :: ArchiveState -> Module -> FilePath -> IO Object readArObject ar_state mod ar_file = do loaded_ars <- readIORef (loadedArchives ar_state) (Ar.Archive entries) <- case M.lookup ar_file loaded_ars of @@ -599,19 +616,27 @@ readArObject ar_state mod ar_file = do a <- Ar.loadAr ar_file modifyIORef (loadedArchives ar_state) (M.insert ar_file a) pure a - let tag = moduleNameTag $ moduleName mod - matchTag entry - | Right hdr <- getHeader (BL.fromStrict $ Ar.filedata entry) - = hdrModuleName hdr == tag - | otherwise - = False - - -- XXX this shouldn't be an exception probably - pure $! maybe (error $ "could not find object for module " - ++ moduleNameString (moduleName mod) - ++ " in " - ++ ar_file) - (BL.fromStrict . Ar.filedata) (find matchTag entries) + + -- look for the right object in archive + let go_entries = \case + -- XXX this shouldn't be an exception probably + [] -> panic $ "could not find object for module " + ++ moduleNameString (moduleName mod) + ++ " in " + ++ ar_file + + (e:es) -> do + let bs = Ar.filedata e + bh <- unsafeUnpackBinBuffer bs + getObjectHeader bh >>= \case + Left _ -> go_entries es -- not a valid object entry + Right mod_name + | mod_name /= moduleName mod + -> go_entries es -- not the module we're looking for + | otherwise + -> getObjectBody bh mod_name -- found it + + go_entries entries {- | Static dependencies are symbols that need to be linked regardless of whether the linked program refers to them. For example @@ -824,15 +849,15 @@ loadArchiveDeps' archives = do return (prepareLoadedDeps $ concat archDeps) where readEntry :: FilePath -> Ar.ArchiveEntry -> IO (Maybe (Deps, DepsLocation)) - readEntry ar_file ar_entry - | isObjFile ar_entry = - fmap (,ArchiveFile ar_file) <$> - (readDepsMaybe (ar_file ++ ':':Ar.filename ar_entry) (BL.fromStrict $ Ar.filedata ar_entry)) - | otherwise = return Nothing - - -isObjFile :: Ar.ArchiveEntry -> Bool -isObjFile = checkEntryHeader "GHCJSOBJ" + readEntry ar_file ar_entry = do + let bs = Ar.filedata ar_entry + bh <- unsafeUnpackBinBuffer bs + getObjectHeader bh >>= \case + Left _ -> pure Nothing -- not a valid object entry + Right mod_name -> do + obj <- getObjectBody bh mod_name + let !deps = objDeps obj + pure $ Just (deps, ArchiveFile ar_file) isJsFile :: Ar.ArchiveEntry -> Bool isJsFile = checkEntryHeader "//JavaScript" @@ -857,12 +882,15 @@ requiredUnits d = map (depsModule d,) (IS.toList $ depsRequired d) -- read dependencies from an object that might have already been into memory -- pulls in all Deps from an archive readDepsFile' :: LinkedObj -> IO (Deps, DepsLocation) -readDepsFile' (ObjLoaded name bs) = (,InMemory name bs) <$> - readDeps name bs -readDepsFile' (ObjFile file) = - (,ObjectFile file) <$> readDepsFile file - -generateBase :: FilePath -> Base -> IO () -generateBase outDir b = - BL.writeFile (outDir "out.base.symbs") (renderBase b) +readDepsFile' = \case + ObjLoaded name obj -> do + let !deps = objDeps obj + pure (deps,InMemory name obj) + ObjFile file -> do + deps <- readObjectDeps file + pure (deps,ObjectFile file) + +-- generateBase :: FilePath -> Base -> IO () +-- generateBase outDir b = +-- BL.writeFile (outDir "out.base.symbs") (renderBase b) ===================================== compiler/GHC/StgToJS/Linker/Types.hs ===================================== @@ -41,7 +41,6 @@ import GHC.StgToJS.Object import GHC.StgToJS.Types (ClosureInfo, StaticInfo) import GHC.Unit.Types -import GHC.Utils.Panic import GHC.Utils.Outputable hiding ((<>)) import GHC.Data.FastString import GHC.Driver.Env.Types (HscEnv) @@ -51,14 +50,9 @@ import GHC.Types.Unique.Map import Control.Monad import Data.Array -import qualified Data.Binary as DB -import qualified Data.Binary.Get as DB -import qualified Data.Binary.Put as DB import Data.ByteString (ByteString) -import qualified Data.ByteString.Lazy as BL import Data.Map.Strict (Map) import qualified Data.Map.Strict as M -import Data.List (sortOn) import Data.Set (Set) import qualified Data.Set as S import qualified Data.IntMap as I @@ -111,19 +105,19 @@ data StringTable = StringTable , stIdents :: !(UniqMap FastString (Either Int Int)) -- ^ identifiers in the table } -instance DB.Binary Ident where - put (TxtI s) = DB.put $ unpackFS s - get = TxtI . mkFastString <$> DB.get +-- instance DB.Binary Ident where +-- put (TxtI s) = DB.put $ unpackFS s +-- get = TxtI . mkFastString <$> DB.get -instance DB.Binary StringTable where - put (StringTable tids offs idents) = do - DB.put tids - DB.put (M.toList offs) - -- The lexical sorting allows us to use nonDetEltsUniqMap without introducing non-determinism - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap idents) - get = StringTable <$> DB.get - <*> fmap M.fromList DB.get - <*> fmap listToUniqMap DB.get +-- instance DB.Binary StringTable where +-- put (StringTable tids offs idents) = do +-- DB.put tids +-- DB.put (M.toList offs) +-- -- The lexical sorting allows us to use nonDetEltsUniqMap without introducing non-determinism +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap idents) +-- get = StringTable <$> DB.get +-- <*> fmap M.fromList DB.get +-- <*> fmap listToUniqMap DB.get emptyStringTable :: StringTable emptyStringTable = StringTable (listArray (0,-1) []) M.empty emptyUniqMap @@ -293,9 +287,9 @@ data Base = Base { baseCompactorState :: CompactorState , baseUnits :: Set (Module, Int) } -instance DB.Binary Base where - get = getBase "" - put = putBase +-- instance DB.Binary Base where +-- get = getBase "" +-- put = putBase showBase :: Base -> String showBase b = unlines @@ -309,96 +303,96 @@ showBase b = unlines emptyBase :: Base emptyBase = Base emptyCompactorState [] S.empty -putBase :: Base -> DB.Put -putBase (Base cs packages funs) = do - DB.putByteString "GHCJSBASE" - DB.putLazyByteString versionTag - putCs cs - putList DB.put packages - -- putList putPkg pkgs - putList DB.put mods - putList putFun (S.toList funs) - where - pi :: Int -> DB.Put - pi = DB.putWord32le . fromIntegral - uniq :: Ord a => [a] -> [a] - uniq = S.toList . S.fromList - -- pkgs = uniq (map fst $ S.toList funs) - -- pkgsM = M.fromList (zip pkgs [(0::Int)..]) - mods = uniq (map fst $ S.toList funs) - modsM = M.fromList (zip mods [(0::Int)..]) - putList f xs = pi (length xs) >> mapM_ f xs - -- serialise the compactor state - putCs (CompactorState [] _ _ _ _ _ _ _ _ _ _ _) = - panic "putBase: putCs exhausted renamer symbol names" - putCs (CompactorState (ns:_) nm es _ ss _ ls _ pes pss pls sts) = do - DB.put ns - -- We can use nonDetEltsUniqMap without introducing non-determinism by sorting lexically - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap nm) - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap es) - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap ss) - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap ls) - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pes) - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pss) - DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pls) - DB.put sts - -- putPkg mod = DB.put mod - -- fixme group things first - putFun (m,s) = --pi (pkgsM M.! p) >> - pi (modsM M.! m) >> DB.put s - -getBase :: FilePath -> DB.Get Base -getBase file = getBase' - where - gi :: DB.Get Int - gi = fromIntegral <$> DB.getWord32le - getList f = DB.getWord32le >>= \n -> replicateM (fromIntegral n) f - getFun ms = (,) <$> - -- ((ps!) <$> gi) <*> - ((ms!) <$> gi) <*> DB.get - la xs = listArray (0, length xs - 1) xs - -- getPkg = DB.get - getCs = do - n <- DB.get - nm <- listToUniqMap <$> DB.get - es <- listToUniqMap <$> DB.get - ss <- listToUniqMap <$> DB.get - ls <- listToUniqMap <$> DB.get - pes <- listToUniqMap <$> DB.get - pss <- listToUniqMap <$> DB.get - pls <- listToUniqMap <$> DB.get - CompactorState (dropWhile (/=n) renamedVars) - nm - es - (sizeUniqMap es) - ss - (sizeUniqMap ss) - ls - (sizeUniqMap ls) - pes - pss - pls <$> DB.get - getBase' = do - hdr <- DB.getByteString 9 - when (hdr /= "GHCJSBASE") - (panic $ "getBase: invalid base file: " <> file) - vt <- DB.getLazyByteString (fromIntegral versionTagLength) - when (vt /= versionTag) - (panic $ "getBase: incorrect version: " <> file) - cs <- makeCompactorParent <$> getCs - linkedPackages <- getList DB.get - -- pkgs <- la <$> getList getPkg - mods <- la <$> getList DB.get - funs <- getList (getFun mods) - return (Base cs linkedPackages $ S.fromList funs) - --- | lazily render the base metadata into a bytestring -renderBase :: Base -> BL.ByteString -renderBase = DB.runPut . putBase - --- | lazily load base metadata from a file, see @UseBase at . -loadBase :: FilePath -> IO Base -loadBase file = DB.runGet (getBase file) <$> BL.readFile file +-- putBase :: Base -> DB.Put +-- putBase (Base cs packages funs) = do +-- DB.putByteString "GHCJSBASE" +-- DB.putLazyByteString versionTag +-- putCs cs +-- putList DB.put packages +-- -- putList putPkg pkgs +-- putList DB.put mods +-- putList putFun (S.toList funs) +-- where +-- pi :: Int -> DB.Put +-- pi = DB.putWord32le . fromIntegral +-- uniq :: Ord a => [a] -> [a] +-- uniq = S.toList . S.fromList +-- -- pkgs = uniq (map fst $ S.toList funs) +-- -- pkgsM = M.fromList (zip pkgs [(0::Int)..]) +-- mods = uniq (map fst $ S.toList funs) +-- modsM = M.fromList (zip mods [(0::Int)..]) +-- putList f xs = pi (length xs) >> mapM_ f xs +-- -- serialise the compactor state +-- putCs (CompactorState [] _ _ _ _ _ _ _ _ _ _ _) = +-- panic "putBase: putCs exhausted renamer symbol names" +-- putCs (CompactorState (ns:_) nm es _ ss _ ls _ pes pss pls sts) = do +-- DB.put ns +-- -- We can use nonDetEltsUniqMap without introducing non-determinism by sorting lexically +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap nm) +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap es) +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap ss) +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap ls) +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pes) +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pss) +-- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pls) +-- DB.put sts +-- -- putPkg mod = DB.put mod +-- -- fixme group things first +-- putFun (m,s) = --pi (pkgsM M.! p) >> +-- pi (modsM M.! m) >> DB.put s + +-- getBase :: FilePath -> DB.Get Base +-- getBase file = getBase' +-- where +-- gi :: DB.Get Int +-- gi = fromIntegral <$> DB.getWord32le +-- getList f = DB.getWord32le >>= \n -> replicateM (fromIntegral n) f +-- getFun ms = (,) <$> +-- -- ((ps!) <$> gi) <*> +-- ((ms!) <$> gi) <*> DB.get +-- la xs = listArray (0, length xs - 1) xs +-- -- getPkg = DB.get +-- getCs = do +-- n <- DB.get +-- nm <- listToUniqMap <$> DB.get +-- es <- listToUniqMap <$> DB.get +-- ss <- listToUniqMap <$> DB.get +-- ls <- listToUniqMap <$> DB.get +-- pes <- listToUniqMap <$> DB.get +-- pss <- listToUniqMap <$> DB.get +-- pls <- listToUniqMap <$> DB.get +-- CompactorState (dropWhile (/=n) renamedVars) +-- nm +-- es +-- (sizeUniqMap es) +-- ss +-- (sizeUniqMap ss) +-- ls +-- (sizeUniqMap ls) +-- pes +-- pss +-- pls <$> DB.get +-- getBase' = do +-- hdr <- DB.getByteString 9 +-- when (hdr /= "GHCJSBASE") +-- (panic $ "getBase: invalid base file: " <> file) +-- vt <- DB.getLazyByteString (fromIntegral versionTagLength) +-- when (vt /= versionTag) +-- (panic $ "getBase: incorrect version: " <> file) +-- cs <- makeCompactorParent <$> getCs +-- linkedPackages <- getList DB.get +-- -- pkgs <- la <$> getList getPkg +-- mods <- la <$> getList DB.get +-- funs <- getList (getFun mods) +-- return (Base cs linkedPackages $ S.fromList funs) + +-- -- | lazily render the base metadata into a bytestring +-- renderBase :: Base -> BL.ByteString +-- renderBase = DB.runPut . putBase +-- +-- -- | lazily load base metadata from a file, see @UseBase at . +-- loadBase :: FilePath -> IO Base +-- loadBase file = DB.runGet (getBase file) <$> BL.readFile file -- | There are 3 ways the linker can use @Base at . We can not use it, and thus not -- do any incremental linking. We can load it from a file, where we assume that @@ -502,9 +496,9 @@ data LinkedUnit = LinkedUnit } -- | An object file that's either already in memory (with name) or on disk -data LinkedObj = ObjFile FilePath -- ^ load from this file - | ObjLoaded String BL.ByteString -- ^ already loaded: description and payload - deriving (Eq, Ord, Show) +data LinkedObj + = ObjFile FilePath -- ^ load from this file + | ObjLoaded String Object -- ^ already loaded: description and payload data GhcjsEnv = GhcjsEnv { compiledModules :: MVar (Map Module ByteString) -- ^ keep track of already compiled modules so we don't compile twice for dynamic-too ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -1,4 +1,3 @@ -{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} @@ -31,75 +30,49 @@ -- -- file layout: -- - magic "GHCJSOBJ" --- - length of symbol table --- - length of dependencies --- - length of index -- - compiler version tag --- - symbol table --- - dependency info --- - closureinfo index --- - closureinfo data (offsets described by index) +-- - module name +-- - offsets of string table +-- - dependencies +-- - offset of the index +-- - unit infos +-- - index +-- - string table -- ----------------------------------------------------------------------------- module GHC.StgToJS.Object - ( writeObject' - , readDepsFile - , readDepsFileEither - , hReadDeps - , hReadDepsEither - , readDeps, readDepsMaybe - , readObjectFile - , readObjectFileKeys + ( putObject + , getObjectHeader + , getObjectBody + , getObject , readObject - , readObjectKeys - , putLinkableUnit - , emptySymbolTable + , getObjectUnits + , readObjectUnits + , readObjectDeps , isGlobalUnit - , isExportsUnit -- XXX verify that this is used - -- XXX probably should instead do something that just inspects the header instead of exporting it - , Header(..), getHeader, moduleNameTag - , SymbolTable - , ObjUnit (..) + , Object(..) + , IndexEntry(..) , Deps (..), BlockDeps (..), DepsLocation (..) - , ExpFun (..), ExportedFun (..) - , versionTag, versionTagLength - , runPutS + , ExportedFun (..) ) where import GHC.Prelude -import Control.Exception (bracket) import Control.Monad import Data.Array -import Data.Monoid -import qualified Data.Binary as DB -import qualified Data.Binary.Get as DB -import qualified Data.Binary.Put as DB -import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as B -import Data.ByteString.Lazy (ByteString) -import qualified Data.ByteString.Lazy.Char8 as C8 (pack, unpack) -import qualified Data.ByteString.Short as SBS -import Data.Function (on) import Data.Int import Data.IntSet (IntSet) import qualified Data.IntSet as IS -import Data.IORef -import Data.List (sortBy, sortOn) +import Data.List (sortOn) import Data.Map (Map) import qualified Data.Map as M -import Data.Maybe (catMaybes) import Data.Word -import Data.Char (isSpace) +import Data.Char -import GHC.Generics -import GHC.Settings.Constants (hiVersion) - -import System.IO (openBinaryFile, withBinaryFile, Handle, - hClose, hSeek, SeekMode(..), IOMode(..) ) +import GHC.Settings.Constants (hiVersion) import GHC.JS.Syntax import GHC.StgToJS.Types @@ -110,16 +83,19 @@ import GHC.Data.FastString import GHC.Types.Unique.Map import GHC.Float (castDoubleToWord64, castWord64ToDouble) + import GHC.Utils.Binary hiding (SymbolTable) -import GHC.Utils.Misc import GHC.Utils.Outputable (ppr, Outputable, hcat, vcat, text) - -data Header = Header - { hdrModuleName :: !BS.ByteString - , hdrSymbsLen :: !Int64 - , hdrDepsLen :: !Int64 - , hdrIdxLen :: !Int64 - } deriving (Eq, Ord, Show) +import GHC.Utils.Panic +import GHC.Utils.Monad (mapMaybeM) + +data Object = Object + { objModuleName :: !ModuleName + , objHandle :: !BinHandle -- ^ BinHandle that can be used to read the ObjUnits + , objPayloadOffset :: !(Bin ObjUnit) -- ^ Offset of the payload (units) + , objDeps :: !Deps + , objIndex :: !Index + } type BlockId = Int type BlockIds = IntSet @@ -135,7 +111,7 @@ data Deps = Deps -- ^ exported Haskell functions -> block , depsBlocks :: !(Array BlockId BlockDeps) -- ^ info about each block - } deriving (Generic) + } instance Outputable Deps where ppr d = vcat @@ -144,29 +120,17 @@ instance Outputable Deps where ] -- | Where are the dependencies -data DepsLocation = ObjectFile FilePath -- ^ In an object file at path - | ArchiveFile FilePath -- ^ In a Ar file at path - | InMemory String ByteString -- ^ In memory - deriving (Eq, Show) - -instance Outputable DepsLocation where - ppr x = text (show x) +data DepsLocation + = ObjectFile FilePath -- ^ In an object file at path + | ArchiveFile FilePath -- ^ In a Ar file at path + | InMemory String Object -- ^ In memory data BlockDeps = BlockDeps { blockBlockDeps :: [Int] -- ^ dependencies on blocks in this object , blockFunDeps :: [ExportedFun] -- ^ dependencies on exported symbols in other objects -- , blockForeignExported :: [ExpFun] -- , blockForeignImported :: [ForeignRef] - } deriving (Generic) - -data ExpFun = ExpFun - { isIO :: !Bool - , args :: [JSFFIType] - , result :: !JSFFIType - } deriving (Eq, Ord, Show) - -trim :: String -> String -trim = let f = dropWhile isSpace . reverse in f . f + } {- | we use the convention that the first unit (0) is a module-global unit that's always included when something from the module @@ -176,24 +140,6 @@ trim = let f = dropWhile isSpace . reverse in f . f isGlobalUnit :: Int -> Bool isGlobalUnit n = n == 0 -isExportsUnit :: Int -> Bool -isExportsUnit n = n == 1 - -data JSFFIType - = Int8Type - | Int16Type - | Int32Type - | Int64Type - | Word8Type - | Word16Type - | Word32Type - | Word64Type - | DoubleType - | ByteArrayType - | PtrType - | RefType - deriving (Show, Ord, Eq, Enum) - data ExportedFun = ExportedFun { funModule :: !Module , funSymbol :: !LexicalFastString @@ -205,120 +151,129 @@ instance Outputable ExportedFun where , hcat [ text "symbol: ", ppr f ] ] --- we need to store the size separately, since getting a HashMap's size is O(n) -data SymbolTable - = SymbolTable !Int !(UniqMap FastString Int) - -emptySymbolTable :: SymbolTable -emptySymbolTable = SymbolTable 0 emptyUniqMap - -insertSymbol :: FastString -> SymbolTable -> (SymbolTable, Int) -insertSymbol s st@(SymbolTable n t) = - case lookupUniqMap t s of - Just k -> (st, k) - Nothing -> (SymbolTable (n+1) (addToUniqMap t s n), n) - -data ObjEnv = ObjEnv - { oeSymbols :: Dictionary - , _oeName :: String +-- | Write an ObjUnit, except for the top level symbols which are stored in the +-- index +putObjUnit :: BinHandle -> ObjUnit -> IO () +putObjUnit bh (ObjUnit _syms b c d e f g) = do + put_ bh b + put_ bh c + put_ bh d + put_ bh e + put_ bh f + put_ bh g + +-- | Read an ObjUnit and associate it to the given symbols (that must have been +-- read from the index) +getObjUnit :: [FastString] -> BinHandle -> IO ObjUnit +getObjUnit syms bh = do + b <- get bh + c <- get bh + d <- get bh + e <- get bh + f <- get bh + g <- get bh + pure (ObjUnit syms b c d e f g) + + +magic :: String +magic = "GHCJSOBJ" + +-- | Serialized unit indexes and their exported symbols +-- (the first unit is module-global) +type Index = [IndexEntry] +data IndexEntry = IndexEntry + { idxSymbols :: ![FastString] -- ^ Symbols exported by a unit + , idxOffset :: !(Bin ObjUnit) -- ^ Offset of the unit in the object file } -runGetS :: HasDebugCallStack => String -> Dictionary -> (BinHandle -> IO a) -> ByteString -> IO a -runGetS name st m bl = do - let bs = B.toStrict bl - bh0 <- unpackBinBuffer (BS.length bs) bs - let bh = setUserData bh0 (newReadState undefined (readTable (ObjEnv st name))) - m bh - --- temporary kludge to bridge BinHandle and ByteString -runPutS :: SymbolTable -> (BinHandle -> IO ()) -> IO (SymbolTable, ByteString) -runPutS st ps = do - bh0 <- openBinMem (1024 * 1024) - t_r <- newIORef st - let bh = setUserData bh0 (newWriteState undefined undefined (insertTable t_r)) - ps bh - (,) <$> readIORef t_r <*> (B.fromStrict <$> packBinBuffer bh) - -insertTable :: IORef SymbolTable -> BinHandle -> FastString -> IO () -insertTable t_r bh s = do - t <- readIORef t_r - let !(t', n) = insertSymbol s t - writeIORef t_r t' - put_ bh n - return () - -readTable :: ObjEnv -> BinHandle -> IO FastString -readTable e bh = do - n :: Int <- get bh - return $ (oeSymbols e) ! fromIntegral n - --- one toplevel block in the object file -data ObjUnit = ObjUnit - { oiSymbols :: [FastString] -- toplevel symbols (stored in index) - , oiClInfo :: [ClosureInfo] -- closure information of all closures in block - , oiStatic :: [StaticInfo] -- static closure data - , oiStat :: JStat -- the code - , oiRaw :: FastString -- raw JS code - , oiFExports :: [ExpFun] - , oiFImports :: [ForeignJSRef] - } +instance Binary IndexEntry where + put_ bh (IndexEntry a b) = put_ bh a >> put_ bh b + get bh = IndexEntry <$> get bh <*> get bh --- | Write a linkable unit -putLinkableUnit +putObject :: BinHandle - -> [ClosureInfo] - -> [StaticInfo] - -> JStat - -> FastString - -> [ExpFun] - -> [ForeignJSRef] + -> ModuleName -- ^ module + -> Deps -- ^ dependencies + -> [ObjUnit] -- ^ linkable units and their symbols -> IO () -putLinkableUnit bh ci si s sraw fe fi = do - put_ bh ci - put_ bh si - put_ bh s - put_ bh sraw - put_ bh fe - put_ bh fi - --- tag to store the module name in the object file -moduleNameTag :: ModuleName -> BS.ByteString -moduleNameTag (ModuleName fs) = case compare len moduleNameLength of - EQ -> tag - LT -> tag <> BS.replicate (moduleNameLength - len) 0 -- pad with 0s - GT -> BS.drop (len - moduleNameLength) tag -- take only the ending chars - where - !tag = SBS.fromShort (fs_sbs fs) - !len = n_chars fs - -writeObject' - :: ModuleName -- ^ module - -> SymbolTable -- ^ final symbol table - -> Deps -- ^ dependencies - -> [([FastString],ByteString)] -- ^ serialized units and their exported symbols, the first unit is module-global - -> IO ByteString -writeObject' mod_name st0 deps0 os = do - (sti, idx) <- putIndex st0 os - let symbs = putSymbolTable sti - deps1 <- putDepsSection deps0 - let bl = fromIntegral . B.length - let hdr = putHeader (Header (moduleNameTag mod_name) (bl symbs) (bl deps1) (bl idx)) - return $ hdr <> symbs <> deps1 <> idx <> mconcat (map snd os) - -putIndex :: SymbolTable -> [([FastString], ByteString)] -> IO (SymbolTable, ByteString) -putIndex st xs = runPutS st (\bh -> put_ bh $ zip symbols offsets) - where - (symbols, values) = unzip xs - offsets = scanl (+) 0 (map B.length values) - -getIndex :: HasDebugCallStack => String -> Dictionary -> ByteString -> IO [([FastString], Int64)] -getIndex name st bs = runGetS name st get bs - -putDeps :: SymbolTable -> Deps -> IO (SymbolTable, ByteString) -putDeps st deps = runPutS st (\bh -> put_ bh deps) - -getDeps :: HasDebugCallStack => String -> Dictionary -> ByteString -> IO Deps -getDeps name st bs = runGetS name st get bs +putObject bh mod_name deps os = do + forM_ magic (putByte bh . fromIntegral . ord) + put_ bh (show hiVersion) + + -- we store the module name as a String because we don't want to have to + -- decode the FastString table just to decode it when we're looking for an + -- object in an archive. + put_ bh (moduleNameString mod_name) + + (bh_fs, _bin_dict, put_dict) <- initBinDictionary bh + + forwardPut_ bh (const put_dict) $ do + put_ bh_fs deps + + -- forward put the index + forwardPut_ bh_fs (put_ bh_fs) $ do + idx <- forM os $ \o -> do + p <- tellBin bh_fs + -- write units without their symbols + putObjUnit bh_fs o + -- return symbols and offset to store in the index + pure (oiSymbols o,p) + pure idx + +-- | Parse object header +getObjectHeader :: BinHandle -> IO (Either String ModuleName) +getObjectHeader bh = do + let go_magic = \case + [] -> pure True + (e:es) -> getByte bh >>= \case + c | fromIntegral (ord e) == c -> go_magic es + | otherwise -> pure False + + is_magic <- go_magic magic + case is_magic of + False -> pure (Left "invalid magic header") + True -> do + is_correct_version <- ((== hiVersion) . read) <$> get bh + case is_correct_version of + False -> pure (Left "invalid header version") + True -> do + mod_name <- get bh + pure (Right (mkModuleName (mod_name))) + + +-- | Parse object body. Must be called after a sucessful getObjectHeader +getObjectBody :: BinHandle -> ModuleName -> IO Object +getObjectBody bh0 mod_name = do + -- Read the string table + dict <- forwardGet bh0 (getDictionary bh0) + let bh = setUserData bh0 $ defaultUserData { ud_get_fs = getDictFastString dict } + + deps <- get bh + idx <- forwardGet bh (get bh) + payload_pos <- tellBin bh + + pure $ Object + { objModuleName = mod_name + , objHandle = bh + , objPayloadOffset = payload_pos + , objDeps = deps + , objIndex = idx + } + +-- | Parse object +getObject :: BinHandle -> IO Object +getObject bh = do + getObjectHeader bh >>= \case + Left err -> panic ("getObject: " ++ err) + Right mod_name -> getObjectBody bh mod_name + +-- | Read object from file +-- +-- The object is still in memory after this (see objHandle). +readObject :: FilePath -> IO Object +readObject file = do + bh <- readBinMem file + getObject bh toI32 :: Int -> Int32 toI32 = fromIntegral @@ -326,18 +281,6 @@ toI32 = fromIntegral fromI32 :: Int32 -> Int fromI32 = fromIntegral -putDepsSection :: Deps -> IO ByteString -putDepsSection deps = do - (st, depsbs) <- putDeps emptySymbolTable deps - let stbs = putSymbolTable st - return $ DB.runPut (DB.putWord32le (fromIntegral $ B.length stbs)) <> stbs <> depsbs - -getDepsSection :: HasDebugCallStack => String -> ByteString -> IO Deps -getDepsSection name bs = - let symbsLen = fromIntegral $ DB.runGet DB.getWord32le bs - symbs = getSymbolTable (B.drop 4 bs) - in getDeps name symbs (B.drop (4+symbsLen) bs) - instance Binary Deps where put_ bh (Deps m r e b) = do put_ bh m @@ -362,177 +305,48 @@ instance Binary ExpFun where put_ bh (ExpFun isIO args res) = put_ bh isIO >> put_ bh args >> put_ bh res get bh = ExpFun <$> get bh <*> get bh <*> get bh --- | reads only the part necessary to get bh the dependencies --- so it's potentially more efficient than readDeps <$> B.readFile file -readDepsFile :: FilePath -> IO Deps -readDepsFile file = withBinaryFile file ReadMode (hReadDeps file) - -readDepsFileEither :: FilePath -> IO (Either String Deps) -readDepsFileEither file = withBinaryFile file ReadMode (hReadDepsEither file) - -hReadDeps :: String -> Handle -> IO Deps -hReadDeps name h = do - res <- hReadDepsEither name h - case res of - Left err -> error ("hReadDeps: not a valid GHCJS object: " ++ name ++ "\n " ++ err) - Right deps -> pure deps - -hReadDepsEither :: String -> Handle -> IO (Either String Deps) -hReadDepsEither name h = do - mhdr <- getHeader <$> B.hGet h headerLength - case mhdr of - Left err -> pure (Left err) - Right hdr -> do - hSeek h RelativeSeek (fromIntegral $ hdrSymbsLen hdr) - Right <$> (getDepsSection name =<< B.hGet h (fromIntegral $ hdrDepsLen hdr)) - -readDepsEither :: String -> ByteString -> IO (Either String Deps) -readDepsEither name bs = - case getHeader bs of - Left err -> return $ Left err - Right hdr -> - let depsStart = fromIntegral headerLength + fromIntegral (hdrSymbsLen hdr) - in Right <$> getDepsSection name (B.drop depsStart bs) - - --- | call with contents of the file -readDeps :: String -> B.ByteString -> IO Deps -readDeps name bs = do - mdeps <- readDepsEither name bs - case mdeps of - Left err -> error ("readDeps: not a valid GHCJS object: " ++ name ++ "\n " ++ err) - Right deps -> return deps - -readDepsMaybe :: String -> ByteString -> IO (Maybe Deps) -readDepsMaybe name bs = either (const Nothing) Just <$> readDepsEither name bs - --- | extract the linkable units from an object file -readObjectFile :: FilePath -> IO [ObjUnit] -readObjectFile = readObjectFileKeys (\_ _ -> True) - -readObjectFileKeys :: (Int -> [FastString] -> Bool) -> FilePath -> IO [ObjUnit] -readObjectFileKeys p file = bracket (openBinaryFile file ReadMode) hClose $ \h -> do - mhdr <- getHeader <$> B.hGet h headerLength - case mhdr of - Left err -> error ("readObjectFileKeys: not a valid GHCJS object: " ++ file ++ "\n " ++ err) - Right hdr -> do - bss <- B.hGet h (fromIntegral $ hdrSymbsLen hdr) - hSeek h RelativeSeek (fromIntegral $ hdrDepsLen hdr) - bsi <- B.fromStrict <$> BS.hGetContents h - readObjectKeys' file p (getSymbolTable bss) bsi (B.drop (fromIntegral $ hdrIdxLen hdr) bsi) - -readObject :: String -> ByteString -> IO [ObjUnit] -readObject name = readObjectKeys name (\_ _ -> True) - -readObjectKeys :: HasDebugCallStack => String -> (Int -> [FastString] -> Bool) -> ByteString -> IO [ObjUnit] -readObjectKeys name p bs = - case getHeader bs of - Left err -> error ("readObjectKeys: not a valid GHCJS object: " ++ name ++ "\n " ++ err) - Right hdr -> - let bssymbs = B.drop (fromIntegral headerLength) bs - bsidx = B.drop (fromIntegral $ hdrSymbsLen hdr + hdrDepsLen hdr) bssymbs - bsobjs = B.drop (fromIntegral $ hdrIdxLen hdr) bsidx - in readObjectKeys' name p (getSymbolTable bssymbs) bsidx bsobjs - -readObjectKeys' :: HasDebugCallStack - => String - -> (Int -> [FastString] -> Bool) - -> Dictionary - -> ByteString - -> ByteString - -> IO [ObjUnit] -readObjectKeys' name p st bsidx bsobjs = do - idx <- getIndex name st bsidx - catMaybes <$> zipWithM readObj [0..] idx - where - readObj n (x,off) - | p n x = do - (ci, si, s, sraw, fe, fi) <- runGetS name st getOU (B.drop off bsobjs) - return $ Just (ObjUnit x ci si s sraw fe fi) - | otherwise = return Nothing - getOU bh = (,,,,,) <$> get bh <*> get bh <*> get bh <*> get bh <*> get bh <*> get bh - -getSymbolTable :: HasDebugCallStack => ByteString -> Dictionary -getSymbolTable bs = listArray (0,n-1) xs +-- | Reads only the part necessary to get the dependencies +readObjectDeps :: FilePath -> IO Deps +readObjectDeps file = do + bh <- readBinMem file + obj <- getObject bh + pure $! objDeps obj + + +-- | Get units in the object file, using the given filtering function +getObjectUnits :: Object -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] +getObjectUnits obj pred = mapMaybeM read_entry (zip (objIndex obj) [0..]) where - (n,xs) = DB.runGet getter bs - getter :: DB.Get (Int, [FastString]) - getter = do - l <- DB.getWord32le - let l' = fromIntegral l - (l',) <$> replicateM l' DB.get - -putSymbolTable :: SymbolTable -> ByteString -putSymbolTable (SymbolTable _ hm) = st - where - st = DB.runPut $ do - DB.putWord32le (fromIntegral $ length xs) - mapM_ DB.put xs - xs :: [FastString] - xs = map fst . sortBy (compare `on` snd) . nonDetEltsUniqMap $ hm - -- We can use `nonDetEltsUniqMap` because the paired `Int`s introduce ordering. - -headerLength :: Int -headerLength = 32 + versionTagLength + moduleNameLength - --- human readable version string in object -versionTag :: ByteString -versionTag = B.take 32 . C8.pack $ show hiVersion ++ replicate versionTagLength ' ' - -versionTagLength :: Int -versionTagLength = 32 - --- last part of the module name, to disambiguate files -moduleNameLength :: Int -moduleNameLength = 128 - -getHeader :: HasDebugCallStack => ByteString -> Either String Header -getHeader bs - | B.length bs < fromIntegral headerLength = Left "not enough input, file truncated?" - | magic /= "GHCJSOBJ" = Left $ "magic number incorrect, not a JavaScript .o file?" - | tag /= versionTag = Left $ "incorrect version, expected " ++ show hiVersion ++ - " but got " ++ (trim . C8.unpack $ tag) - | otherwise = Right (Header mn sl dl il) - where - g = fromIntegral <$> DB.getWord64le - (magic, tag, mn, sl, dl, il) = DB.runGet ((,,,,,) <$> DB.getByteString 8 - <*> DB.getLazyByteString (fromIntegral versionTagLength) - <*> DB.getByteString (fromIntegral moduleNameLength) - <*> g - <*> g - <*> g - ) bs - -putHeader :: Header -> ByteString -putHeader (Header mn sl dl il) = DB.runPut $ do - DB.putByteString "GHCJSOBJ" - DB.putLazyByteString versionTag - DB.putByteString mn - mapM_ (DB.putWord64le . fromIntegral) [sl, dl, il] - -tag :: BinHandle -> Word8 -> IO () -tag = put_ - -getTag :: BinHandle -> IO Word8 -getTag = get + bh = objHandle obj + read_entry (e@(IndexEntry syms offset),i) + | pred i e = do + seekBin bh offset + Just <$> getObjUnit syms bh + | otherwise = pure Nothing + +-- | Read units in the object file, using the given filtering function +readObjectUnits :: FilePath -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] +readObjectUnits file pred = do + obj <- readObject file + getObjectUnits obj pred instance Binary JStat where - put_ bh (DeclStat i) = tag bh 1 >> put_ bh i - put_ bh (ReturnStat e) = tag bh 2 >> put_ bh e - put_ bh (IfStat e s1 s2) = tag bh 3 >> put_ bh e >> put_ bh s1 >> put_ bh s2 - put_ bh (WhileStat b e s) = tag bh 4 >> put_ bh b >> put_ bh e >> put_ bh s - put_ bh (ForInStat b i e s) = tag bh 5 >> put_ bh b >> put_ bh i >> put_ bh e >> put_ bh s - put_ bh (SwitchStat e ss s) = tag bh 6 >> put_ bh e >> put_ bh ss >> put_ bh s - put_ bh (TryStat s1 i s2 s3) = tag bh 7 >> put_ bh s1 >> put_ bh i >> put_ bh s2 >> put_ bh s3 - put_ bh (BlockStat xs) = tag bh 8 >> put_ bh xs - put_ bh (ApplStat e es) = tag bh 9 >> put_ bh e >> put_ bh es - put_ bh (UOpStat o e) = tag bh 10 >> put_ bh o >> put_ bh e - put_ bh (AssignStat e1 e2) = tag bh 11 >> put_ bh e1 >> put_ bh e2 + put_ bh (DeclStat i) = putByte bh 1 >> put_ bh i + put_ bh (ReturnStat e) = putByte bh 2 >> put_ bh e + put_ bh (IfStat e s1 s2) = putByte bh 3 >> put_ bh e >> put_ bh s1 >> put_ bh s2 + put_ bh (WhileStat b e s) = putByte bh 4 >> put_ bh b >> put_ bh e >> put_ bh s + put_ bh (ForInStat b i e s) = putByte bh 5 >> put_ bh b >> put_ bh i >> put_ bh e >> put_ bh s + put_ bh (SwitchStat e ss s) = putByte bh 6 >> put_ bh e >> put_ bh ss >> put_ bh s + put_ bh (TryStat s1 i s2 s3) = putByte bh 7 >> put_ bh s1 >> put_ bh i >> put_ bh s2 >> put_ bh s3 + put_ bh (BlockStat xs) = putByte bh 8 >> put_ bh xs + put_ bh (ApplStat e es) = putByte bh 9 >> put_ bh e >> put_ bh es + put_ bh (UOpStat o e) = putByte bh 10 >> put_ bh o >> put_ bh e + put_ bh (AssignStat e1 e2) = putByte bh 11 >> put_ bh e1 >> put_ bh e2 put_ _ (UnsatBlock {}) = error "put_ bh JStat: UnsatBlock" - put_ bh (LabelStat l s) = tag bh 12 >> put_ bh l >> put_ bh s - put_ bh (BreakStat ml) = tag bh 13 >> put_ bh ml - put_ bh (ContinueStat ml) = tag bh 14 >> put_ bh ml - get bh = getTag bh >>= \case + put_ bh (LabelStat l s) = putByte bh 12 >> put_ bh l >> put_ bh s + put_ bh (BreakStat ml) = putByte bh 13 >> put_ bh ml + put_ bh (ContinueStat ml) = putByte bh 14 >> put_ bh ml + get bh = getByte bh >>= \case 1 -> DeclStat <$> get bh 2 -> ReturnStat <$> get bh 3 -> IfStat <$> get bh <*> get bh <*> get bh @@ -550,15 +364,15 @@ instance Binary JStat where n -> error ("Binary get bh JStat: invalid tag: " ++ show n) instance Binary JExpr where - put_ bh (ValExpr v) = tag bh 1 >> put_ bh v - put_ bh (SelExpr e i) = tag bh 2 >> put_ bh e >> put_ bh i - put_ bh (IdxExpr e1 e2) = tag bh 3 >> put_ bh e1 >> put_ bh e2 - put_ bh (InfixExpr o e1 e2) = tag bh 4 >> put_ bh o >> put_ bh e1 >> put_ bh e2 - put_ bh (UOpExpr o e) = tag bh 5 >> put_ bh o >> put_ bh e - put_ bh (IfExpr e1 e2 e3) = tag bh 6 >> put_ bh e1 >> put_ bh e2 >> put_ bh e3 - put_ bh (ApplExpr e es) = tag bh 7 >> put_ bh e >> put_ bh es + put_ bh (ValExpr v) = putByte bh 1 >> put_ bh v + put_ bh (SelExpr e i) = putByte bh 2 >> put_ bh e >> put_ bh i + put_ bh (IdxExpr e1 e2) = putByte bh 3 >> put_ bh e1 >> put_ bh e2 + put_ bh (InfixExpr o e1 e2) = putByte bh 4 >> put_ bh o >> put_ bh e1 >> put_ bh e2 + put_ bh (UOpExpr o e) = putByte bh 5 >> put_ bh o >> put_ bh e + put_ bh (IfExpr e1 e2 e3) = putByte bh 6 >> put_ bh e1 >> put_ bh e2 >> put_ bh e3 + put_ bh (ApplExpr e es) = putByte bh 7 >> put_ bh e >> put_ bh es put_ _ (UnsatExpr {}) = error "put_ bh JExpr: UnsatExpr" - get bh = getTag bh >>= \case + get bh = getByte bh >>= \case 1 -> ValExpr <$> get bh 2 -> SelExpr <$> get bh <*> get bh 3 -> IdxExpr <$> get bh <*> get bh @@ -569,16 +383,16 @@ instance Binary JExpr where n -> error ("Binary get bh JExpr: invalid tag: " ++ show n) instance Binary JVal where - put_ bh (JVar i) = tag bh 1 >> put_ bh i - put_ bh (JList es) = tag bh 2 >> put_ bh es - put_ bh (JDouble d) = tag bh 3 >> put_ bh d - put_ bh (JInt i) = tag bh 4 >> put_ bh i - put_ bh (JStr xs) = tag bh 5 >> put_ bh xs - put_ bh (JRegEx xs) = tag bh 6 >> put_ bh xs - put_ bh (JHash m) = tag bh 7 >> put_ bh (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap m) - put_ bh (JFunc is s) = tag bh 8 >> put_ bh is >> put_ bh s + put_ bh (JVar i) = putByte bh 1 >> put_ bh i + put_ bh (JList es) = putByte bh 2 >> put_ bh es + put_ bh (JDouble d) = putByte bh 3 >> put_ bh d + put_ bh (JInt i) = putByte bh 4 >> put_ bh i + put_ bh (JStr xs) = putByte bh 5 >> put_ bh xs + put_ bh (JRegEx xs) = putByte bh 6 >> put_ bh xs + put_ bh (JHash m) = putByte bh 7 >> put_ bh (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap m) + put_ bh (JFunc is s) = putByte bh 8 >> put_ bh is >> put_ bh s put_ _ (UnsatVal {}) = error "put_ bh JVal: UnsatVal" - get bh = getTag bh >>= \case + get bh = getByte bh >>= \case 1 -> JVar <$> get bh 2 -> JList <$> get bh 3 -> JDouble <$> get bh @@ -596,12 +410,12 @@ instance Binary Ident where -- we need to preserve NaN and infinities, unfortunately the Binary instance for Double does not do this instance Binary SaneDouble where put_ bh (SaneDouble d) - | isNaN d = tag bh 1 - | isInfinite d && d > 0 = tag bh 2 - | isInfinite d && d < 0 = tag bh 3 - | isNegativeZero d = tag bh 4 - | otherwise = tag bh 5 >> put_ bh (castDoubleToWord64 d) - get bh = getTag bh >>= \case + | isNaN d = putByte bh 1 + | isInfinite d && d > 0 = putByte bh 2 + | isInfinite d && d < 0 = putByte bh 3 + | isNegativeZero d = putByte bh 4 + | otherwise = putByte bh 5 >> put_ bh (castDoubleToWord64 d) + get bh = getByte bh >>= \case 1 -> pure $ SaneDouble (0 / 0) 2 -> pure $ SaneDouble (1 / 0) 3 -> pure $ SaneDouble ((-1) / 0) @@ -623,9 +437,9 @@ instance Binary VarType where get bh = getEnum bh instance Binary CIRegs where - put_ bh CIRegsUnknown = tag bh 1 - put_ bh (CIRegs skip types) = tag bh 2 >> put_ bh skip >> put_ bh types - get bh = getTag bh >>= \case + put_ bh CIRegsUnknown = putByte bh 1 + put_ bh (CIRegs skip types) = putByte bh 2 >> put_ bh skip >> put_ bh types + get bh = getByte bh >>= \case 1 -> pure CIRegsUnknown 2 -> CIRegs <$> get bh <*> get bh n -> error ("Binary get bh CIRegs: invalid tag: " ++ show n) @@ -640,29 +454,29 @@ instance Binary JUOp where -- 16 bit sizes should be enough... instance Binary CILayout where - put_ bh CILayoutVariable = tag bh 1 - put_ bh (CILayoutUnknown size) = tag bh 2 >> put_ bh size - put_ bh (CILayoutFixed size types) = tag bh 3 >> put_ bh size >> put_ bh types - get bh = getTag bh >>= \case + put_ bh CILayoutVariable = putByte bh 1 + put_ bh (CILayoutUnknown size) = putByte bh 2 >> put_ bh size + put_ bh (CILayoutFixed size types) = putByte bh 3 >> put_ bh size >> put_ bh types + get bh = getByte bh >>= \case 1 -> pure CILayoutVariable 2 -> CILayoutUnknown <$> get bh 3 -> CILayoutFixed <$> get bh <*> get bh n -> error ("Binary get bh CILayout: invalid tag: " ++ show n) instance Binary CIStatic where - put_ bh (CIStaticRefs refs) = tag bh 1 >> put_ bh refs - get bh = getTag bh >>= \case + put_ bh (CIStaticRefs refs) = putByte bh 1 >> put_ bh refs + get bh = getByte bh >>= \case 1 -> CIStaticRefs <$> get bh n -> error ("Binary get bh CIStatic: invalid tag: " ++ show n) instance Binary CIType where - put_ bh (CIFun arity regs) = tag bh 1 >> put_ bh arity >> put_ bh regs - put_ bh CIThunk = tag bh 2 - put_ bh (CICon conTag) = tag bh 3 >> put_ bh conTag - put_ bh CIPap = tag bh 4 - put_ bh CIBlackhole = tag bh 5 - put_ bh CIStackFrame = tag bh 6 - get bh = getTag bh >>= \case + put_ bh (CIFun arity regs) = putByte bh 1 >> put_ bh arity >> put_ bh regs + put_ bh CIThunk = putByte bh 2 + put_ bh (CICon conTag) = putByte bh 3 >> put_ bh conTag + put_ bh CIPap = putByte bh 4 + put_ bh CIBlackhole = putByte bh 5 + put_ bh CIStackFrame = putByte bh 6 + get bh = getByte bh >>= \case 1 -> CIFun <$> get bh <*> get bh 2 -> pure CIThunk 3 -> CICon <$> get bh @@ -675,37 +489,6 @@ instance Binary ExportedFun where put_ bh (ExportedFun modu symb) = put_ bh modu >> put_ bh symb get bh = ExportedFun <$> get bh <*> get bh -instance DB.Binary Module where - put (Module unit mod_name) = DB.put unit >> DB.put mod_name - get = Module <$> DB.get <*> DB.get - -instance DB.Binary ModuleName where - put (ModuleName fs) = DB.put fs - get = ModuleName <$> DB.get - -instance DB.Binary Unit where - put = \case - RealUnit (Definite uid) -> DB.put (0 :: Int) >> DB.put uid - VirtUnit uid -> DB.put (1 :: Int) >> DB.put uid - HoleUnit -> DB.put (2 :: Int) - get = DB.get >>= \case - (0 :: Int) -> RealUnit . Definite <$> DB.get - 1 -> VirtUnit <$> DB.get - _ -> pure HoleUnit - -instance DB.Binary UnitId where - put (UnitId fs) = DB.put fs - get = UnitId <$> DB.get - -instance DB.Binary InstantiatedUnit where - put indef = do - DB.put (instUnitInstanceOf indef) - DB.put (instUnitInsts indef) - get = mkInstantiatedUnitSorted <$> DB.get <*> DB.get - -instance DB.Binary FastString where - put fs = DB.put (unpackFS fs) - get = mkFastString <$> DB.get putEnum :: Enum a => BinHandle -> a -> IO () putEnum bh x | n > 65535 = error ("putEnum: out of range: " ++ show n) @@ -720,12 +503,12 @@ instance Binary StaticInfo where get bh = StaticInfo <$> get bh <*> get bh <*> get bh instance Binary StaticVal where - put_ bh (StaticFun f args) = tag bh 1 >> put_ bh f >> put_ bh args - put_ bh (StaticThunk t) = tag bh 2 >> put_ bh t - put_ bh (StaticUnboxed u) = tag bh 3 >> put_ bh u - put_ bh (StaticData dc args) = tag bh 4 >> put_ bh dc >> put_ bh args - put_ bh (StaticList xs t) = tag bh 5 >> put_ bh xs >> put_ bh t - get bh = getTag bh >>= \case + put_ bh (StaticFun f args) = putByte bh 1 >> put_ bh f >> put_ bh args + put_ bh (StaticThunk t) = putByte bh 2 >> put_ bh t + put_ bh (StaticUnboxed u) = putByte bh 3 >> put_ bh u + put_ bh (StaticData dc args) = putByte bh 4 >> put_ bh dc >> put_ bh args + put_ bh (StaticList xs t) = putByte bh 5 >> put_ bh xs >> put_ bh t + get bh = getByte bh >>= \case 1 -> StaticFun <$> get bh <*> get bh 2 -> StaticThunk <$> get bh 3 -> StaticUnboxed <$> get bh @@ -734,12 +517,12 @@ instance Binary StaticVal where n -> error ("Binary get bh StaticVal: invalid tag " ++ show n) instance Binary StaticUnboxed where - put_ bh (StaticUnboxedBool b) = tag bh 1 >> put_ bh b - put_ bh (StaticUnboxedInt i) = tag bh 2 >> put_ bh i - put_ bh (StaticUnboxedDouble d) = tag bh 3 >> put_ bh d - put_ bh (StaticUnboxedString str) = tag bh 4 >> put_ bh str - put_ bh (StaticUnboxedStringOffset str) = tag bh 5 >> put_ bh str - get bh = getTag bh >>= \case + put_ bh (StaticUnboxedBool b) = putByte bh 1 >> put_ bh b + put_ bh (StaticUnboxedInt i) = putByte bh 2 >> put_ bh i + put_ bh (StaticUnboxedDouble d) = putByte bh 3 >> put_ bh d + put_ bh (StaticUnboxedString str) = putByte bh 4 >> put_ bh str + put_ bh (StaticUnboxedStringOffset str) = putByte bh 5 >> put_ bh str + get bh = getByte bh >>= \case 1 -> StaticUnboxedBool <$> get bh 2 -> StaticUnboxedInt <$> get bh 3 -> StaticUnboxedDouble <$> get bh @@ -748,24 +531,24 @@ instance Binary StaticUnboxed where n -> error ("Binary get bh StaticUnboxed: invalid tag " ++ show n) instance Binary StaticArg where - put_ bh (StaticObjArg i) = tag bh 1 >> put_ bh i - put_ bh (StaticLitArg p) = tag bh 2 >> put_ bh p - put_ bh (StaticConArg c args) = tag bh 3 >> put_ bh c >> put_ bh args - get bh = getTag bh >>= \case + put_ bh (StaticObjArg i) = putByte bh 1 >> put_ bh i + put_ bh (StaticLitArg p) = putByte bh 2 >> put_ bh p + put_ bh (StaticConArg c args) = putByte bh 3 >> put_ bh c >> put_ bh args + get bh = getByte bh >>= \case 1 -> StaticObjArg <$> get bh 2 -> StaticLitArg <$> get bh 3 -> StaticConArg <$> get bh <*> get bh n -> error ("Binary get bh StaticArg: invalid tag " ++ show n) instance Binary StaticLit where - put_ bh (BoolLit b) = tag bh 1 >> put_ bh b - put_ bh (IntLit i) = tag bh 2 >> put_ bh i - put_ bh NullLit = tag bh 3 - put_ bh (DoubleLit d) = tag bh 4 >> put_ bh d - put_ bh (StringLit t) = tag bh 5 >> put_ bh t - put_ bh (BinLit b) = tag bh 6 >> put_ bh b - put_ bh (LabelLit b t) = tag bh 7 >> put_ bh b >> put_ bh t - get bh = getTag bh >>= \case + put_ bh (BoolLit b) = putByte bh 1 >> put_ bh b + put_ bh (IntLit i) = putByte bh 2 >> put_ bh i + put_ bh NullLit = putByte bh 3 + put_ bh (DoubleLit d) = putByte bh 4 >> put_ bh d + put_ bh (StringLit t) = putByte bh 5 >> put_ bh t + put_ bh (BinLit b) = putByte bh 6 >> put_ bh b + put_ bh (LabelLit b t) = putByte bh 7 >> put_ bh b >> put_ bh t + get bh = getByte bh >>= \case 1 -> BoolLit <$> get bh 2 -> IntLit <$> get bh 3 -> pure NullLit ===================================== compiler/GHC/StgToJS/Types.hs ===================================== @@ -250,7 +250,7 @@ data ForeignJSRef = ForeignJSRef -- | data used to generate one ObjUnit in our object file data LinkableUnit = LinkableUnit - { luStat :: BS.ByteString -- ^ serialized JS AST + { luObjUnit :: ObjUnit -- ^ serializable unit info , luIdExports :: [Id] -- ^ exported names from haskell identifiers , luOtherExports :: [FastString] -- ^ other exports , luIdDeps :: [Id] -- ^ identifiers this unit depends on @@ -260,6 +260,39 @@ data LinkableUnit = LinkableUnit , luForeignRefs :: [ForeignJSRef] } +-- one toplevel block in the object file +data ObjUnit = ObjUnit + { oiSymbols :: ![FastString] -- toplevel symbols (stored in index) + , oiClInfo :: ![ClosureInfo] -- closure information of all closures in block + , oiStatic :: ![StaticInfo] -- static closure data + , oiStat :: !JStat -- the code + , oiRaw :: !BS.ByteString -- raw JS code + , oiFExports :: ![ExpFun] + , oiFImports :: ![ForeignJSRef] + } + +data ExpFun = ExpFun + { isIO :: !Bool + , args :: [JSFFIType] + , result :: !JSFFIType + } deriving (Eq, Ord, Show) + +data JSFFIType + = Int8Type + | Int16Type + | Int32Type + | Int64Type + | Word8Type + | Word16Type + | Word32Type + | Word64Type + | DoubleType + | ByteArrayType + | PtrType + | RefType + deriving (Show, Ord, Eq, Enum) + + -- | Typed expression data TypedExpr = TypedExpr { typex_typ :: !PrimRep ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Utils.Binary SymbolTable, Dictionary, BinData(..), dataHandle, handleData, - packBinBuffer, unpackBinBuffer, + packBinBuffer, unpackBinBuffer, unsafeUnpackBinBuffer, openBinMem, -- closeBin, @@ -50,6 +50,7 @@ module GHC.Utils.Binary readBinMem, putAt, getAt, + forwardPut, forwardPut_, forwardGet, -- * For writing instances putByte, @@ -72,8 +73,11 @@ module GHC.Utils.Binary -- * User data UserData(..), getUserData, setUserData, - newReadState, newWriteState, + newReadState, newWriteState, defaultUserData, + + -- * String table ("dictionary") putDictionary, getDictionary, putFS, + BinDictionary, initBinDictionary, getDictFastString, putDictFastString, ) where import GHC.Prelude @@ -87,10 +91,11 @@ import GHC.Types.Unique.FM import GHC.Data.FastMutInt import GHC.Utils.Fingerprint import GHC.Types.SrcLoc +import GHC.Types.Unique import qualified GHC.Data.Strict as Strict import Control.DeepSeq -import Foreign hiding (shiftL, shiftR) +import Foreign hiding (shiftL, shiftR, void) import Data.Array import Data.Array.IO import Data.Array.Unsafe @@ -105,7 +110,7 @@ import Data.Set ( Set ) import qualified Data.Set as Set import Data.Time import Data.List (unfoldr) -import Control.Monad ( when, (<$!>), unless, forM_ ) +import Control.Monad ( when, (<$!>), unless, forM_, void ) import System.IO as IO import System.IO.Unsafe ( unsafeInterleaveIO ) import System.IO.Error ( mkIOError, eofErrorType ) @@ -152,7 +157,7 @@ dataHandle (BinData size bin) = do ixr <- newFastMutInt 0 szr <- newFastMutInt size binr <- newIORef bin - return (BinMem noUserData ixr szr binr) + return (BinMem defaultUserData ixr szr binr) handleData :: BinHandle -> IO BinData handleData (BinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef binr @@ -163,7 +168,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)) @@ -202,6 +207,13 @@ unpackBinBuffer n from = do seekBin bh (BinPtr 0) return bh +unsafeUnpackBinBuffer :: ByteString -> IO BinHandle +unsafeUnpackBinBuffer (BS.BS arr len) = do + arr_r <- newIORef arr + ix_r <- newFastMutInt 0 + sz_r <- newFastMutInt len + return (BinMem defaultUserData ix_r sz_r arr_r) + --------------------------------------------------------------- -- Bin --------------------------------------------------------------- @@ -237,13 +249,13 @@ getAt bh p = do seekBin bh p; get bh openBinMem :: Int -> IO BinHandle openBinMem size - | size <= 0 = error "Data.Binary.openBinMem: size must be >= 0" + | size <= 0 = error "GHC.Utils.Binary.openBinMem: size must be >= 0" | otherwise = do arr <- mallocForeignPtrBytes size arr_r <- newIORef arr ix_r <- newFastMutInt 0 sz_r <- newFastMutInt size - return (BinMem noUserData ix_r sz_r arr_r) + return (BinMem defaultUserData ix_r sz_r arr_r) tellBin :: BinHandle -> IO (Bin a) tellBin (BinMem _ r _ _) = do ix <- readFastMutInt r; return (BinPtr ix) @@ -255,6 +267,14 @@ seekBin h@(BinMem _ ix_r sz_r _) (BinPtr !p) = do then do expandBin h p; writeFastMutInt ix_r p else writeFastMutInt ix_r p +-- | SeekBin but without calling expandBin +seekBinNoExpand :: BinHandle -> Bin a -> IO () +seekBinNoExpand (BinMem _ ix_r sz_r _) (BinPtr !p) = do + sz <- readFastMutInt sz_r + if (p >= sz) + then panic "seekBinNoExpand: seek out of range" + else writeFastMutInt ix_r p + writeBinMem :: BinHandle -> FilePath -> IO () writeBinMem (BinMem _ ix_r _ arr_r) fn = do h <- openBinaryFile fn WriteMode @@ -277,7 +297,7 @@ readBinMem filename = do arr_r <- newIORef arr ix_r <- newFastMutInt 0 sz_r <- newFastMutInt filesize - return (BinMem noUserData ix_r sz_r arr_r) + return (BinMem defaultUserData ix_r sz_r arr_r) -- expand the size of the array to include a specified offset expandBin :: BinHandle -> Int -> IO () @@ -572,7 +592,9 @@ getSLEB128 bh = do -- | Encode the argument in it's full length. This is different from many default -- binary instances which make no guarantee about the actual encoding and -- might do things use variable length encoding. -newtype FixedLengthEncoding a = FixedLengthEncoding { unFixedLength :: a } +newtype FixedLengthEncoding a + = FixedLengthEncoding { unFixedLength :: a } + deriving (Eq,Ord,Show) instance Binary (FixedLengthEncoding Word8) where put_ h (FixedLengthEncoding x) = putByte h x @@ -934,6 +956,45 @@ instance Binary (Bin a) where get bh = do i <- getWord32 bh; return (BinPtr (fromIntegral (i :: Word32))) +-- ----------------------------------------------------------------------------- +-- Forward reading/writing + +-- | "forwardPut put_A put_B" outputs A after B but allows A to be read before B +-- by using a forward reference +forwardPut :: BinHandle -> (b -> IO a) -> IO b -> IO (a,b) +forwardPut bh put_A put_B = do + -- write placeholder pointer to A + pre_a <- tellBin bh + put_ bh pre_a + + -- write B + r_b <- put_B + + -- update A's pointer + a <- tellBin bh + putAt bh pre_a a + seekBinNoExpand bh a + + -- write A + r_a <- put_A r_b + pure (r_a,r_b) + +forwardPut_ :: BinHandle -> (b -> IO a) -> IO b -> IO () +forwardPut_ bh put_A put_B = void $ forwardPut bh put_A put_B + +-- | Read a value stored using a forward reference +forwardGet :: BinHandle -> IO a -> IO a +forwardGet bh get_A = do + -- read forward reference + p <- get bh -- a BinPtr + -- store current position + p_a <- tellBin bh + -- go read the forward value, then seek back + seekBinNoExpand bh p + r <- get_A + seekBinNoExpand bh p_a + pure r + -- ----------------------------------------------------------------------------- -- Lazy reading/writing @@ -1041,8 +1102,14 @@ newWriteState put_nonbinding_name put_binding_name put_fs ud_put_fs = put_fs } -noUserData :: a -noUserData = undef "UserData" +defaultUserData :: UserData +defaultUserData = UserData + { ud_get_name = undef "get_name" + , ud_get_fs = undef "get_fs" + , ud_put_nonbinding_name = undef "put_nonbinding_name" + , ud_put_binding_name = undef "put_binding_name" + , ud_put_fs = undef "put_fs" + } undef :: String -> a undef s = panic ("Binary.UserData: no " ++ s) @@ -1070,6 +1137,56 @@ getDictionary bh = do writeArray mut_arr i fs unsafeFreeze mut_arr +getDictFastString :: Dictionary -> BinHandle -> IO FastString +getDictFastString dict bh = do + j <- get bh + return $! (dict ! fromIntegral (j :: Word32)) + + +initBinDictionary :: BinHandle -> IO (BinHandle, BinDictionary, IO Int) +initBinDictionary bh = do + dict_next_ref <- newFastMutInt 0 + dict_map_ref <- newIORef emptyUFM + let bin_dict = BinDictionary + { bin_dict_next = dict_next_ref + , bin_dict_map = dict_map_ref + } + let put_dict = do + fs_count <- readFastMutInt dict_next_ref + dict_map <- readIORef dict_map_ref + putDictionary bh fs_count dict_map + pure fs_count + + -- BinHandle with FastString writing support + let ud = getUserData bh + let ud_fs = ud { ud_put_fs = putDictFastString bin_dict } + let bh_fs = setUserData bh ud_fs + + return (bh_fs,bin_dict,put_dict) + +putDictFastString :: BinDictionary -> BinHandle -> FastString -> IO () +putDictFastString dict bh fs = allocateFastString dict fs >>= put_ bh + +allocateFastString :: BinDictionary -> FastString -> IO Word32 +allocateFastString BinDictionary { bin_dict_next = j_r, + bin_dict_map = out_r} f = do + out <- readIORef out_r + let !uniq = getUnique f + case lookupUFM_Directly out uniq of + Just (j, _) -> return (fromIntegral j :: Word32) + Nothing -> do + j <- readFastMutInt j_r + writeFastMutInt j_r (j + 1) + writeIORef out_r $! addToUFM_Directly out uniq (j, f) + return (fromIntegral j :: Word32) + +data BinDictionary = BinDictionary { + bin_dict_next :: !FastMutInt, -- The next index to use + bin_dict_map :: !(IORef (UniqFM FastString (Int,FastString))) + -- indexed by FastString + } + + --------------------------------------------------------- -- The Symbol Table --------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a606f87203a1c249437b1f182df091743e6c3194...24773ce87a251951727a62a2d49343a7c9954af6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a606f87203a1c249437b1f182df091743e6c3194...24773ce87a251951727a62a2d49343a7c9954af6 You're receiving 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 Sep 6 17:26:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Sep 2022 13:26:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix :add docs in user guide Message-ID: <631782c4f9bc_869eb5145021515@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c54732e1 by Jan Hrček at 2022-09-06T13:26:10-04:00 Fix :add docs in user guide - - - - - 1d59e3f8 by Cheng Shao at 2022-09-06T13:26:11-04:00 ci: remove unused build_make/test_make in ci script - - - - - 2 changed files: - .gitlab/ci.sh - docs/users_guide/ghci.rst Changes: ===================================== .gitlab/ci.sh ===================================== @@ -50,11 +50,6 @@ Common Modes: shell Run an interactive shell with a configured build environment. save_cache Preserve the cabal cache -Make build system: - - build_make Build GHC via the make build system - test_make Test GHC via the make build system - Hadrian build system build_hadrian Build GHC via the Hadrian build system test_hadrian Test GHC via the Hadrian build system @@ -436,23 +431,6 @@ function configure() { end_section "configuring" } -function build_make() { - check_release_build - prepare_build_mk - if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then - fail "BIN_DIST_PREP_TAR_COMP is not set" - fi - if [[ -n "${VERBOSE:-}" ]]; then - MAKE_ARGS="${MAKE_ARGS:-} V=1" - else - MAKE_ARGS="${MAKE_ARGS:-} V=0" - fi - - run "$MAKE" -j"$cores" "$MAKE_ARGS" - run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 - ls -lh "$BIN_DIST_PREP_TAR_COMP" -} - function fetch_perf_notes() { info "Fetching perf notes..." "$TOP/.gitlab/test-metrics.sh" pull @@ -508,23 +486,6 @@ function check_release_build() { fi } -function test_make() { - if [ -n "${CROSS_TARGET:-}" ]; then - info "Can't test cross-compiled build." - return - fi - - check_msys2_deps inplace/bin/ghc-stage2 --version - check_release_build - - run "$MAKE" test_bindist TEST_PREP=YES TEST_PROF=${RELEASE_JOB:-} - (unset $(compgen -v | grep CI_*); - run "$MAKE" V=0 VERBOSE=1 test \ - THREADS="$cores" \ - JUNIT_FILE=../../junit.xml \ - EXTRA_RUNTEST_OPTS="${RUNTEST_ARGS:-}") -} - function build_hadrian() { if [ -z "${BIN_DIST_NAME:-}" ]; then fail "BIN_DIST_NAME not set" @@ -842,13 +803,6 @@ case $1 in usage) usage ;; setup) setup && cleanup_submodules ;; configure) time_it "configure" configure ;; - build_make) time_it "build" build_make ;; - test_make) - fetch_perf_notes - res=0 - time_it "test" test_make || res=$? - push_perf_notes - exit $res ;; build_hadrian) time_it "build" build_hadrian ;; # N.B. Always push notes, even if the build fails. This is okay to do as the # testsuite driver doesn't record notes for tests that fail due to ===================================== docs/users_guide/ghci.rst ===================================== @@ -2183,7 +2183,7 @@ commonly used commands. Abandons the current evaluation (only available when stopped at a breakpoint). -.. ghci-cmd:: :add;[*] ⟨module⟩ +.. ghci-cmd:: :add; [*]⟨module⟩ Add ⟨module⟩(s) to the current target set, and perform a reload. Normally pre-compiled code for the module will be loaded if View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/841eaf3608769f2a4caa48c4f7bc82d1ceb24ce6...1d59e3f88a5418146061c11f261ca373b459f206 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/841eaf3608769f2a4caa48c4f7bc82d1ceb24ce6...1d59e3f88a5418146061c11f261ca373b459f206 You're receiving 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 Sep 6 17:52:57 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 06 Sep 2022 13:52:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/cleanup-outputable Message-ID: <631788f9c9a88_869eb514a0222691@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/cleanup-outputable at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/cleanup-outputable You're receiving 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 Sep 6 19:36:38 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Sep 2022 15:36:38 -0400 Subject: [Git][ghc/ghc][master] Update instances.rst, clarifying InstanceSigs Message-ID: <6317a1462a87e_869eb5148c2405ec@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - 1 changed file: - docs/users_guide/exts/instances.rst Changes: ===================================== docs/users_guide/exts/instances.rst ===================================== @@ -591,16 +591,15 @@ Instance signatures: type signatures in instance declarations Allow type signatures for members in instance definitions. -In Haskell, you can't write a type signature in an instance declaration, -but it is sometimes convenient to do so, and the language extension -:extension:`InstanceSigs` allows you to do so. For example: :: +The :extension:`InstanceSigs` extension allows users to give type signatures +to the class methods in a class instance declaration. For example: :: data T a = MkT a a instance Eq a => Eq (T a) where - (==) :: T a -> T a -> Bool -- The signature + (==) :: T a -> T a -> Bool -- The instance signature (==) (MkT x1 x2) (MkTy y1 y2) = x1==y1 && x2==y2 -Some details +Some details: - The type signature in the instance declaration must be more polymorphic than (or the same as) the one in the class declaration, @@ -613,11 +612,37 @@ Some details Here the signature in the instance declaration is more polymorphic than that required by the instantiated class method. + Note that, to check that the instance signature is more polymorphic, + GHC performs a sub-type check, which can solve constraints using available + top-level instances. + This means that the following instance signature is accepted: :: + + instance Eq (T Int) where + (==) :: Eq Int => T Int -> T Int -> Bool + (==) (MkT x1 _) (MkT y1 _) = x1 == y1 + + The ``Eq Int`` constraint in the instance signature will be solved + by the top-level ``Eq Int`` instance, from which it follows that the + instance signature is indeed as general as the instantiated class + method type ``T Int -> T Int -> Bool``. + - The code for the method in the instance declaration is typechecked against the type signature supplied in the instance declaration, as you would expect. So if the instance signature is more polymorphic than required, the code must be too. +- The instance signature is purely local to the class instance + declaration. It only affects the typechecking of the method in + the instance; it does not affect anything outside the class + instance. In this way, it is similar to an inline type signature: + + instance Eq a => Eq (T a) where + (==) = (\ x y -> True) :: forall b. b -> b -> Bool + + In particular, adding constraints such as `HasCallStack` to the + instance signature will not have an effect; they need to be added + to the class instead. + - One stylistic reason for wanting to write a type signature is simple documentation. Another is that you may want to bring scoped type variables into scope. For example: :: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f37b621fdeff6922c6ad9533a02ccc26c50f9b2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f37b621fdeff6922c6ad9533a02ccc26c50f9b2e You're receiving 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 Sep 6 19:37:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Sep 2022 15:37:13 -0400 Subject: [Git][ghc/ghc][master] Fix :add docs in user guide Message-ID: <6317a1694c940_869eb5148c244145@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 1 changed file: - docs/users_guide/ghci.rst Changes: ===================================== docs/users_guide/ghci.rst ===================================== @@ -2183,7 +2183,7 @@ commonly used commands. Abandons the current evaluation (only available when stopped at a breakpoint). -.. ghci-cmd:: :add;[*] ⟨module⟩ +.. ghci-cmd:: :add; [*]⟨module⟩ Add ⟨module⟩(s) to the current target set, and perform a reload. Normally pre-compiled code for the module will be loaded if View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d4f908f7dff34c650fd3cf26dbba1d5b66c13dbc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d4f908f7dff34c650fd3cf26dbba1d5b66c13dbc You're receiving 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 Sep 6 19:37:48 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Sep 2022 15:37:48 -0400 Subject: [Git][ghc/ghc][master] ci: remove unused build_make/test_make in ci script Message-ID: <6317a18c6b628_869eb514a024771b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -50,11 +50,6 @@ Common Modes: shell Run an interactive shell with a configured build environment. save_cache Preserve the cabal cache -Make build system: - - build_make Build GHC via the make build system - test_make Test GHC via the make build system - Hadrian build system build_hadrian Build GHC via the Hadrian build system test_hadrian Test GHC via the Hadrian build system @@ -436,23 +431,6 @@ function configure() { end_section "configuring" } -function build_make() { - check_release_build - prepare_build_mk - if [[ -z "$BIN_DIST_PREP_TAR_COMP" ]]; then - fail "BIN_DIST_PREP_TAR_COMP is not set" - fi - if [[ -n "${VERBOSE:-}" ]]; then - MAKE_ARGS="${MAKE_ARGS:-} V=1" - else - MAKE_ARGS="${MAKE_ARGS:-} V=0" - fi - - run "$MAKE" -j"$cores" "$MAKE_ARGS" - run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1 - ls -lh "$BIN_DIST_PREP_TAR_COMP" -} - function fetch_perf_notes() { info "Fetching perf notes..." "$TOP/.gitlab/test-metrics.sh" pull @@ -508,23 +486,6 @@ function check_release_build() { fi } -function test_make() { - if [ -n "${CROSS_TARGET:-}" ]; then - info "Can't test cross-compiled build." - return - fi - - check_msys2_deps inplace/bin/ghc-stage2 --version - check_release_build - - run "$MAKE" test_bindist TEST_PREP=YES TEST_PROF=${RELEASE_JOB:-} - (unset $(compgen -v | grep CI_*); - run "$MAKE" V=0 VERBOSE=1 test \ - THREADS="$cores" \ - JUNIT_FILE=../../junit.xml \ - EXTRA_RUNTEST_OPTS="${RUNTEST_ARGS:-}") -} - function build_hadrian() { if [ -z "${BIN_DIST_NAME:-}" ]; then fail "BIN_DIST_NAME not set" @@ -842,13 +803,6 @@ case $1 in usage) usage ;; setup) setup && cleanup_submodules ;; configure) time_it "configure" configure ;; - build_make) time_it "build" build_make ;; - test_make) - fetch_perf_notes - res=0 - time_it "test" test_make || res=$? - push_perf_notes - exit $res ;; build_hadrian) time_it "build" build_hadrian ;; # N.B. Always push notes, even if the build fails. This is okay to do as the # testsuite driver doesn't record notes for tests that fail due to View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/808bb7934e1e3007bf7115bdf75263bba937c85b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/808bb7934e1e3007bf7115bdf75263bba937c85b You're receiving 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 Sep 6 19:39:52 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 06 Sep 2022 15:39:52 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Primops: Add {Index,Write,Read}ByteArrayAs ops Message-ID: <6317a20850fe7_869eb5146424798@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 95723ce8 by doyougnu at 2022-09-06T15:38:45-04: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 - - - - - 3 changed files: - compiler/GHC/JS/Make.hs - compiler/GHC/StgToJS/Prim.hs - rts/js/mem.js Changes: ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -498,7 +498,7 @@ infixl 8 .^ -- | Assign a variable to an expression -- --- > foo |= expr ==> foo = expr; +-- > foo |= expr ==> var foo = expr; (|=) :: JExpr -> JExpr -> JStat (|=) = AssignStat ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1035,50 +1035,124 @@ genPrim prof ty op = case op of ShrinkSmallMutableArrayOp_Char -> unhandledPrimop op GetSizeofSmallMutableArrayOp -> unhandledPrimop op - IndexByteArrayOp_Word8AsChar -> unhandledPrimop op - IndexByteArrayOp_Word8AsWideChar -> unhandledPrimop op - IndexByteArrayOp_Word8AsAddr -> unhandledPrimop op - IndexByteArrayOp_Word8AsFloat -> unhandledPrimop op - IndexByteArrayOp_Word8AsDouble -> unhandledPrimop op - IndexByteArrayOp_Word8AsStablePtr -> unhandledPrimop op - IndexByteArrayOp_Word8AsInt16 -> unhandledPrimop op - IndexByteArrayOp_Word8AsInt32 -> unhandledPrimop op - IndexByteArrayOp_Word8AsInt64 -> unhandledPrimop op - IndexByteArrayOp_Word8AsInt -> unhandledPrimop op - IndexByteArrayOp_Word8AsWord16 -> unhandledPrimop op - IndexByteArrayOp_Word8AsWord32 -> unhandledPrimop op - IndexByteArrayOp_Word8AsWord64 -> unhandledPrimop op - IndexByteArrayOp_Word8AsWord -> unhandledPrimop op - - ReadByteArrayOp_Word8AsChar -> unhandledPrimop op - ReadByteArrayOp_Word8AsWideChar -> unhandledPrimop op - ReadByteArrayOp_Word8AsAddr -> unhandledPrimop op - ReadByteArrayOp_Word8AsFloat -> unhandledPrimop op - ReadByteArrayOp_Word8AsDouble -> unhandledPrimop op - ReadByteArrayOp_Word8AsStablePtr -> unhandledPrimop op - ReadByteArrayOp_Word8AsInt16 -> unhandledPrimop op - ReadByteArrayOp_Word8AsInt32 -> unhandledPrimop op - ReadByteArrayOp_Word8AsInt64 -> unhandledPrimop op - ReadByteArrayOp_Word8AsInt -> unhandledPrimop op - ReadByteArrayOp_Word8AsWord16 -> unhandledPrimop op - ReadByteArrayOp_Word8AsWord32 -> unhandledPrimop op - ReadByteArrayOp_Word8AsWord64 -> unhandledPrimop op - ReadByteArrayOp_Word8AsWord -> unhandledPrimop op - - WriteByteArrayOp_Word8AsChar -> unhandledPrimop op - WriteByteArrayOp_Word8AsWideChar -> unhandledPrimop op - WriteByteArrayOp_Word8AsAddr -> unhandledPrimop op - WriteByteArrayOp_Word8AsFloat -> unhandledPrimop op - WriteByteArrayOp_Word8AsDouble -> unhandledPrimop op - WriteByteArrayOp_Word8AsStablePtr -> unhandledPrimop op - WriteByteArrayOp_Word8AsInt16 -> unhandledPrimop op - WriteByteArrayOp_Word8AsInt32 -> unhandledPrimop op - WriteByteArrayOp_Word8AsInt64 -> unhandledPrimop op - WriteByteArrayOp_Word8AsInt -> unhandledPrimop op - WriteByteArrayOp_Word8AsWord16 -> unhandledPrimop op - WriteByteArrayOp_Word8AsWord32 -> unhandledPrimop op - WriteByteArrayOp_Word8AsWord64 -> unhandledPrimop op - WriteByteArrayOp_Word8AsWord -> unhandledPrimop op + IndexByteArrayOp_Word8AsChar -> \[r] [a,i] -> PrimInline $ r |= dv_u8 a i + IndexByteArrayOp_Word8AsWideChar -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i + IndexByteArrayOp_Word8AsAddr -> \[r1,r2] [a,i] -> + PrimInline $ jVar \t -> mconcat + [-- grab the "array" property + t |= a .^ "arr" + -- make sure we have a non-empty array + , ifBlockS (t .&&. t .! i) + -- we do, r1 is the ArrayBuffer, r2 is the payload offset + [ r1 |= t + , r2 |= dv_u32 t i + ] + -- we don't + [ r1 |= null_ + , r2 |= zero_ + ] + ] + IndexByteArrayOp_Word8AsFloat -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i + IndexByteArrayOp_Word8AsDouble -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i + IndexByteArrayOp_Word8AsStablePtr -> \[r1,r2] [a,i] -> + PrimInline $ mconcat + [ r1 |= var "h$stablePtrBuf" + , r2 |= dv_i32 a i + ] + IndexByteArrayOp_Word8AsInt16 -> \[r] [a,i] -> PrimInline $ r |= dv_i16 a i + IndexByteArrayOp_Word8AsInt32 -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i + IndexByteArrayOp_Word8AsInt64 -> \[h,l] [a,i] -> + PrimInline $ mconcat + [ h |= dv_u32 a (Add i (Int 4)) + , l |= dv_u32 a i + ] + IndexByteArrayOp_Word8AsInt -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i + IndexByteArrayOp_Word8AsWord16 -> \[r] [a,i] -> PrimInline $ r |= dv_u16 a i + IndexByteArrayOp_Word8AsWord32 -> \[r] [a,i] -> PrimInline $ r |= dv_u32 a i + IndexByteArrayOp_Word8AsWord64 -> \[h,l] [a,i] -> + PrimInline $ mconcat + [ h |= dv_u32 a (Add i (Int 4)) + , l |= dv_u32 a i + ] + IndexByteArrayOp_Word8AsWord -> \[r] [a,i] -> PrimInline $ r |= dv_u32 a i + + ReadByteArrayOp_Word8AsChar -> \[r] [a,i] -> PrimInline $ r |= dv_u8 a i + ReadByteArrayOp_Word8AsWideChar -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i + ReadByteArrayOp_Word8AsAddr -> \[r1,r2] [a,i] -> + PrimInline $ jVar \t -> mconcat + [-- grab the "array" property + t |= a .^ "arr" + -- make sure we have a non-empty array + , ifBlockS (t .&&. t .! i) + -- we do, r1 is the ArrayBuffer, r2 is the payload offset + [ r1 |= t + , r2 |= dv_u32 t i + ] + -- we don't + [ r1 |= null_ + , r2 |= zero_ + ] + ] + ReadByteArrayOp_Word8AsFloat -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i + ReadByteArrayOp_Word8AsDouble -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i + ReadByteArrayOp_Word8AsStablePtr -> \[r1,r2] [a,i] -> + PrimInline $ mconcat + [ r1 |= var "h$stablePtrBuf" + , r2 |= dv_i32 a i + ] + ReadByteArrayOp_Word8AsInt16 -> \[r] [a,i] -> PrimInline $ r |= dv_i16 a i + ReadByteArrayOp_Word8AsInt32 -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i + ReadByteArrayOp_Word8AsInt64 -> \[h,l] [a,i] -> + PrimInline $ mconcat + [ h |= dv_i32 a (Add i (Int 4)) + , l |= dv_u32 a i + ] + ReadByteArrayOp_Word8AsInt -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i + ReadByteArrayOp_Word8AsWord16 -> \[r] [a,i] -> PrimInline $ r |= dv_u16 a i + ReadByteArrayOp_Word8AsWord32 -> \[r] [a,i] -> PrimInline $ r |= dv_u32 a i + ReadByteArrayOp_Word8AsWord64 -> \[h,l] [a,i] -> + PrimInline $ mconcat + [ h |= dv_u32 a (Add i (Int 4)) + , l |= dv_u32 a i + ] + ReadByteArrayOp_Word8AsWord -> \[r] [a,i] -> PrimInline $ r |= dv_u32 a i + + WriteByteArrayOp_Word8AsChar -> \[] [a,i,e] -> PrimInline $ dv_s_u8 a i e + WriteByteArrayOp_Word8AsWideChar -> \[] [a,i,e] -> PrimInline $ dv_s_i32 a i e + WriteByteArrayOp_Word8AsAddr -> \[] [a,i,e1,e2] -> + PrimInline $ mconcat + [ ifS (Not (a .^ "arr")) + -- if we don't have the "arr" property then make it + (a .^ "arr" |= ValExpr (JList [])) + -- else noop + mempty + , dv_s_i32 (a .^ "arr") i (ValExpr (JList [e1, e2])) + ] + WriteByteArrayOp_Word8AsFloat -> \[] [a,i,e] -> PrimInline $ dv_s_f32 a i e + WriteByteArrayOp_Word8AsDouble -> \[] [a,i,e] -> PrimInline $ dv_s_f32 a i e + WriteByteArrayOp_Word8AsStablePtr -> \[] [a,i,_e1,e2] -> PrimInline $ dv_s_i32 a i e2 + WriteByteArrayOp_Word8AsInt16 -> \[] [a,i,e] -> PrimInline $ dv_s_i16 a i e + WriteByteArrayOp_Word8AsInt32 -> \[] [a,i,e] -> PrimInline $ dv_s_i32 a i e + WriteByteArrayOp_Word8AsInt64 -> \[] [a,i,h,l] -> + -- JS Numbers are little-endian and 32-bit, so write the lower 4 bytes at i + -- then write the higher 4 bytes to i+4 + PrimInline $ mconcat [ dv_s_i32 a (Add i (Int 4)) h + , dv_s_i32 a i l + ] + -- it is probably strange to be using dv_s_i32, and dv_s_i16 when dv_s_u16 and + -- dv_s_u32 exist. Unfortunately this is a infelicity of the JS Backend. u32_ + -- and friends are only valid for reading. For writing, we use i32 and friends + -- because u32_ uses the i32_ views internally and then coerces the Int32 to a + -- Word32. We must go through this ceremony because JS doesn't really have the + -- concept of a Word32, so we have to cast to Int32 and write using i32_. + WriteByteArrayOp_Word8AsInt -> \[] [a,i,e] -> PrimInline $ dv_s_i32 a i e + WriteByteArrayOp_Word8AsWord16 -> \[] [a,i,e] -> PrimInline $ dv_s_i16 a i e + WriteByteArrayOp_Word8AsWord32 -> \[] [a,i,e] -> PrimInline $ dv_s_i32 a i e + WriteByteArrayOp_Word8AsWord64 -> \[] [a,i,h,l] -> + PrimInline $ mconcat [ dv_s_i32 a (Add i (Int 4)) (i32 h) + , dv_s_i32 a i (i32 l) + ] + WriteByteArrayOp_Word8AsWord -> \[] [a,i,e] -> PrimInline $ dv_s_u32 a i (i32 e) CasByteArrayOp_Int8 -> unhandledPrimop op CasByteArrayOp_Int16 -> unhandledPrimop op @@ -1195,8 +1269,17 @@ f6_ a i = IdxExpr (a .^ "f6") i f3_ a i = IdxExpr (a .^ "f3") i u1_ a i = IdxExpr (a .^ "u1") i -dv_s_i8, dv_s_i16, dv_s_u16, dv_s_i32, dv_s_u32, dv_s_f32, dv_s_f64 :: JExpr -> JExpr -> JExpr -> JStat +-- | Data View helper functions. In the JS backend we keep a field @dv@ for each +-- ByteArray. The @dv@ field is a JS @DataView@ that is a low level interface +-- for reading/writing number types into a JS @ArrayBuffer at . See +-- 'h$newByteArray' in 'ghc/rts/js/mem.js' for details. These helper functions +-- wrap useful @DataView@ methods for us in PrimOps. The argument list consists +-- of the index @i@, the new value to set (in the case of a setter) @v@, and a +-- Boolean flag indicating whether the type in question is stored in +-- little-endian (True) or big-endian (False) format. +dv_s_i8, dv_s_u8, dv_s_i16, dv_s_u16, dv_s_i32, dv_s_u32, dv_s_f32, dv_s_f64 :: JExpr -> JExpr -> JExpr -> JStat dv_s_i8 a i v = ApplStat (a .^ "dv" .^ "setInt8" ) [i, v, true_] +dv_s_u8 a i v = ApplStat (a .^ "dv" .^ "setUInt8" ) [i, v, true_] dv_s_u16 a i v = ApplStat (a .^ "dv" .^ "setUint16" ) [i, v, true_] dv_s_i16 a i v = ApplStat (a .^ "dv" .^ "setInt16" ) [i, v, true_] dv_s_i32 a i v = ApplStat (a .^ "dv" .^ "setInt32" ) [i, v, true_] @@ -1204,7 +1287,8 @@ dv_s_u32 a i v = ApplStat (a .^ "dv" .^ "setUint32" ) [i, v, true_] dv_s_f32 a i v = ApplStat (a .^ "dv" .^ "setFloat32") [i, v, true_] dv_s_f64 a i v = ApplStat (a .^ "dv" .^ "setFloat64") [i, v, true_] -dv_i8, dv_i16, dv_u16, dv_i32, dv_u32, dv_f32, dv_f64 :: JExpr -> JExpr -> JExpr +dv_i8, dv_u8, dv_i16, dv_u16, dv_i32, dv_u32, dv_f32, dv_f64 :: JExpr -> JExpr -> JExpr +dv_u8 a i = ApplExpr (a .^ "dv" .^ "getUInt8" ) [i, true_] dv_i8 a i = ApplExpr (a .^ "dv" .^ "getInt8" ) [i, true_] dv_i16 a i = ApplExpr (a .^ "dv" .^ "getInt16" ) [i, true_] dv_u16 a i = ApplExpr (a .^ "dv" .^ "getUint16" ) [i, true_] @@ -1242,11 +1326,17 @@ newByteArray tgt len = tgt |= app "h$newByteArray" [len] --- e|0 (32 bit signed integer truncation) +-- e|0 (32 bit signed integer truncation) required because of JS numbers. e|0 +-- converts e to an Int32. Note that e|0 _is still a Double_ because JavaScript. +-- So (x|0) * (y|0) can still return values outside of the Int32 range. You have +-- been warned! i32 :: JExpr -> JExpr i32 e = BOr e zero_ -- e>>>0 (32 bit unsigned integer truncation) +-- required because of JS numbers. e>>>0 converts e to a Word32 +-- so (-2147483648) >>> 0 = 2147483648 +-- and ((-2147483648) >>>0) | 0 = -2147483648 u32 :: JExpr -> JExpr u32 e = e .>>>. zero_ ===================================== rts/js/mem.js ===================================== @@ -940,6 +940,7 @@ function h$roundUpToMultipleOf(n,m) { return rem === 0 ? n : n - rem + m; } +// len in bytes function h$newByteArray(len) { var len0 = Math.max(h$roundUpToMultipleOf(len, 8), 8); var buf = new ArrayBuffer(len0); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/95723ce8449f508e029667760c725495edac90a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/95723ce8449f508e029667760c725495edac90a4 You're receiving 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 Sep 6 20:44:53 2022 From: gitlab at gitlab.haskell.org (Dominik Peteler (@mmhat)) Date: Tue, 06 Sep 2022 16:44:53 -0400 Subject: [Git][ghc/ghc][wip/21611-move-corem] 63 commits: Various Hadrian bootstrapping fixes Message-ID: <6317b145cc081_869eb5142825434b@gitlab.mail> Dominik Peteler pushed to branch wip/21611-move-corem at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - e91112a1 by Dominik Peteler at 2022-09-06T22:43:59+02:00 Move CoreM to GHC.Plugins.Monad Removes the uses of CoreM in the Specialise, SpecConstr and CallerCC pass. Since CoreM is now only used by Core2core plugins within the Core pipeline the monad got moved to an own module. Additionally CoreToDo and related types got moved to an own module GHC.Core.Opt.Pipeline.Types. Moved the remaining code from GHC.Core.Opt.Monad to GHC.Core.Opt.Utils. GHC.Core.Opt.{SpecConstr,CallerCC} got proper configs / the usual treatment. Split out GHC.Core.Opt.CallerCC.Filter to avoid hs-boot. Removed explicit PrintUnqualified argument from `endPassIO` Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep Fixes #21611. - - - - - 4395ab05 by Dominik Peteler at 2022-09-06T22:44:07+02:00 Removed CoreM uses from GHC.Core.Lint - - - - - 5420618a by Dominik Peteler at 2022-09-06T22:44:09+02:00 Purified GHC.Core.LateCC.addLateCostCentres * GHC.Driver.Config.Core.Lint: * Removed: endPass * Renamed: endPassHscEnvIO -> endPass * Moved GHC.Core.Opt.Pipeline.initLintAnnotationsConfig to GHC.Driver.Config.Core.Lint - - - - - 85c75ba1 by Dominik Peteler at 2022-09-06T22:44:11+02:00 Run the CoreToDo interpreter in an own monad `SimplCountM` This monad is just `StateT SimplCount IO` wrapped in a newtype. This way we get rid of some `Core.Opt.Pipeline` boilerplate. It lives in GHC.Core.Opt.Counting and `Tick` and `SimplCount` got moved there as well. Also: * GHC.Core.Opt.Pipeline.runCorePasses: Take logger service as an argument - - - - - 319ffb38 by Dominik Peteler at 2022-09-06T22:44:13+02:00 Removed references to driver from Specialise pass - - - - - 7ddac9ba by Dominik Peteler at 2022-09-06T22:44:14+02:00 Split `Core.EndPass` from `Core.Lint` This better sepates concerns (linting is domain layer, end pass diagnostics is application later), and `Core.Lint` is a huge module to boot. - - - - - ccbb96d4 by Dominik Peteler at 2022-09-06T22:44:15+02:00 Get rid of `CoreDesugar`, `CoreDesugarOpt`, `CoreTidy`, `CorePrep` Those are not Core -> Core passes and so they don't belong in that sum type. Also cleaned up a bit: * Removed 'GHC.Driver.Config.Core.Lint.lintCoreBindings' It was dead code. * Removed 'GHC.Driver.Config.Core.Lint.lintPassResult' It run the actual linting and therefore it didn't belong to the GHC.Driver.Config namespace. As it was used only once the definition got inlined. * GHC.Core.Lint: Renamed lintPassResult' to lintPassResult. Also renamed lintCoreBindings' to lintCoreBindings. * GHC.Driver.Config.Core.Lint: Stick to the defaults when initializing the config records. * GHC.Driver.Config.Core.EndPass: Inlined `endPass` * GHC.Driver.Config.Core.EndPass: Removed `endPassLintFlags` as it was never used - - - - - d0299510 by Dominik Peteler at 2022-09-06T22:44:15+02:00 Simplified initSimplifyOpts - - - - - e503faf3 by Dominik Peteler at 2022-09-06T22:44:17+02:00 Adjusted tests - - - - - 278e2d33 by Dominik Peteler at 2022-09-06T22:44:18+02:00 Removed RuleBase from getCoreToDo - - - - - 84a46d19 by Dominik Peteler at 2022-09-06T22:44:19+02:00 Purified initSpecialiseOpts Also pass the rule bases and the visible orphan modules as arguments to the Specialise pass. - - - - - e9570f9c by Dominik Peteler at 2022-09-06T22:44:20+02:00 Simplified CoreToDo interpreter a bit - - - - - 9a35c91a by Dominik Peteler at 2022-09-06T22:44:21+02:00 Config records of some Core passes are now provided by CoreToDo * CoreAddCallerCcs * CoreAddLateCcs * CoreDoFloatInwards * CoreLiberateCase * CoreDoSpecConstr - - - - - 35b143a0 by Dominik Peteler at 2022-09-06T22:44:22+02:00 Move Core pipeline to the driver * Moved `getCoreToDo` to an own module GHC.Driver.Config.Core.Opt * Moved the remaining part of GHC.Core.Opt.Pipeline to a new module GHC.Driver.Core.Opt * Renamed GHC.Core.Opt.Pipeline.Types to GHC.Core.Opt.Config - - - - - e8d58107 by Dominik Peteler at 2022-09-06T22:44:23+02:00 Fixed tests - - - - - 121e3aef by Dominik Peteler at 2022-09-06T22:44:23+02:00 Fixed note - - - - - b36c6b66 by John Ericson at 2022-09-06T22:44:24+02:00 Add some haddocks - - - - - eaf007f8 by John Ericson at 2022-09-06T22:44:25+02:00 Move `core2core` to `GHC.Driver.Main` This "pushes up" the planning vs execution split, by not combining the two until a further downstream module. That helps encourage this separation we are very much fans of. Also deduplicate some logic with `liftCoreMToSimplCountM`, which abstracts over a number of details to eliminate a `CoreM` to a `SimpleCountM`. It might be a bit too opinionated at the moment, in which case we will think about how to shuffle some things around. In addition, deduplicate `simplMask`, which is indeed sketchy thing to export, but we can deal with that later. - - - - - fd8b3dea by John Ericson at 2022-09-06T22:44:26+02:00 Factor out `readRuleEnv` into its own module nad give haddocks Might end up up recombining this but its good separation of concerns for now. - - - - - 6384eb4f by John Ericson at 2022-09-06T22:44:27+02:00 Quick and dirty chop up modules once again I decided my earlier recommendation to mmhat was not quite write. It was the one I implemented too. So through this together real quick and dirty. We can make it nicer afterwords Things that are not yet nice: - `CoreOptEnv` is a grab bag of junk. Of course, it is merely reifying how was were accessing `HscEnv` before --- also rather junky! So maybe it cannot totally be improved. But it would be good to go over bits and ask / make issues (like #21926) that would help us clean up later. - Logging tricks for annotations linting is broken from the planning vs execution separation. We'll need to "delay that part of planning too. Can hack it up with more higher order function tricks, might be also a good oppertunity to rethink what should go in which config. - Some of the per-pass config records require info that isn't available at planning time. I hacked up up with functions in `CoreToDo` but we could do better. Conversely, per #21926, perhaps we *should* include the module name in the config after all, since we know it from downsweep before upsweep begins. - `GHC.Driver.Core.Rules` could just go inside `GHC.Driver.Core.Opt`. - - - - - eda8e833 by John Ericson at 2022-09-06T22:44:28+02:00 Split `GHC.Core.Opt.Utils` Half of it was domain layer (float out switches) but the other half was infrastructure / driver (annotations). - - - - - c6dc49c2 by Dominik Peteler at 2022-09-06T22:44:29+02:00 Fixed tests - - - - - e5e6d0ae by Dominik Peteler at 2022-09-06T22:44:30+02:00 Better configuration of Core lint debug options - - - - - c828aca8 by Dominik Peteler at 2022-09-06T22:44:31+02:00 Configuration record for rule check pass - - - - - c874ef82 by Dominik Peteler at 2022-09-06T22:44:32+02:00 Renamed dmdAnal to demandAnalysis and moved it to GHC.Core.Opt.DmdAnal - - - - - 7a0c82c0 by Dominik Peteler at 2022-09-06T22:44:33+02:00 Fix tests - - - - - c68f3edb by Dominik Peteler at 2022-09-06T22:44:34+02:00 Added environment for worker/wrapper pass - - - - - 34cab7ac by Dominik Peteler at 2022-09-06T22:44:35+02:00 Refactored configuration of Specialise pass again Also removed GHC.Core.Opt.Specialise.Config again. We may introduce separate *.Config modules for the passes once we had a look at the module graph and decide whether the addition of these modules is justified. - - - - - 1ac1f7ec by Dominik Peteler at 2022-09-06T22:44:36+02:00 Removed GHC.Driver.Core.Rules - - - - - 43e46675 by Dominik Peteler at 2022-09-06T22:44:37+02:00 Removed CoreDoNothing and CoreDoPasses Rewrote the getCoreToDo function using a Writer monad. This makes these data constructors superfluous. - - - - - 7e2e4341 by Dominik Peteler at 2022-09-06T22:44:38+02:00 Renamed endPassIO to endPass - - - - - f070c2af by Dominik Peteler at 2022-09-06T22:44:38+02:00 Renamed hscSimplify/hscSimplify' to optimizeCoreIO/optimizeCoreHsc - - - - - e4664fb3 by Dominik Peteler at 2022-09-06T22:44:39+02:00 Run simplifyPgm in SimplCountM - - - - - bea12fe4 by Dominik Peteler at 2022-09-06T22:44:40+02:00 Added note on the architecture of the Core optimizer - - - - - e4e813df by Dominik Peteler at 2022-09-06T22:44:41+02:00 Merged GHC.Driver.Config.Core.Opt.* modules in GHC.Driver.Config.Core.Opt - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - + compiler/GHC/Core/EndPass.hs - compiler/GHC/Core/LateCC.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Lint/Interactive.hs - + compiler/GHC/Core/Opt.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CallerCC.hs - − compiler/GHC/Core/Opt/CallerCC.hs-boot - + compiler/GHC/Core/Opt/CallerCC/Filter.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs → compiler/GHC/Core/Opt/Config.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatOut.hs - + compiler/GHC/Core/Opt/FloatOutSwitches.hs - − compiler/GHC/Core/Opt/Pipeline.hs - + compiler/GHC/Core/Opt/RuleCheck.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78c3cf49346ab211b9c20db978c73d4ddf9b7b4f...e4e813df1d9762c92927381159b9cd9cff19bcb3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78c3cf49346ab211b9c20db978c73d4ddf9b7b4f...e4e813df1d9762c92927381159b9cd9cff19bcb3 You're receiving 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 Sep 6 22:54:39 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 06 Sep 2022 18:54:39 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Move platform.js to base (it must be linked first) Message-ID: <6317cfafc4b2e_869eb5152c2590d7@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: ec203f53 by Sylvain Henry at 2022-09-07T00:57:26+02:00 Move platform.js to base (it must be linked first) - - - - - 4662e9bc by Sylvain Henry at 2022-09-07T00:57:26+02:00 Remove old shim directory - - - - - 15 changed files: - − js/arith.js.pp - − js/compact.js.pp - − js/debug.js.pp - − js/enum.js.pp - − js/environment.js.pp - − js/errno.js.pp - − js/gc.js.pp - − js/goog.js - − js/hscore.js.pp - − js/md5.js - − js/mem.js.pp - − js/node-exports.js - − js/object.js.pp - − js/platform.js.pp - − js/profiling.js.pp The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/95723ce8449f508e029667760c725495edac90a4...4662e9bcf4b9db35ecfd4971c2313090713996f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/95723ce8449f508e029667760c725495edac90a4...4662e9bcf4b9db35ecfd4971c2313090713996f7 You're receiving 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 Sep 7 08:10:36 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 07 Sep 2022 04:10:36 -0400 Subject: [Git][ghc/ghc][wip/T21623] 63 commits: Update instances.rst, clarifying InstanceSigs Message-ID: <631851fca620_869eb5148c2946d0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 99e3d521 by Simon Peyton Jones at 2022-09-07T09:08:07+01:00 Start work Not ready for review - - - - - df8dd468 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 More progress - - - - - f2ada482 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - 619fa65a by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Stage1 compiles - - - - - 52165349 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 More wibbles - - - - - 3e499c96 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 More wibbles - - - - - 51381115 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 More -- almost working - - - - - e4f39962 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Comments - - - - - ed3ff6f1 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - c96eb0b0 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - de919199 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble inlineId - - - - - 93298918 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - eaab1774 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Infinite loop somewhere - - - - - 313c4a17 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 More wibbles. Maybe can build stage2 - - - - - 4ae76734 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Make FuNCo a thing by itself - - - - - bcd8497b by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble - - - - - a4d1be8f by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble - - - - - a06bc64e by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - 8d9cdb69 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Fix OptCoercion - - - - - 9e095f29 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble - - - - - d4a26be9 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble to optCoercion - - - - - 013d1d27 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Replace SORT with TYPE and CONSTRAINT - - - - - c9a5769e by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble - - - - - b8021b69 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Delete unused import - - - - - fc7381cd by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Delete TypeOrConstraint from ghc-prim:GHC.Types - - - - - d48d6ce3 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Move from NthCo to SelCo - - - - - 2a61da9b by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - 75aaedcd by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles in RepType - - - - - fa67a183 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble - - - - - 602de325 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Add mkWpEta - - - - - 1c69de3e by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Really add mkWpEta - - - - - b9f63d8b by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibble Typeable binds etc - - - - - 810abc60 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Improve error messages - - - - - 781d04d4 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 More wibbles, mainly to error messages - - - - - 5bc03a50 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles - - - - - a2fd3731 by Simon Peyton Jones at 2022-09-07T09:08:08+01:00 Wibbles to errors - - - - - 3a1cd022 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibbles But especially: treat Constraint as Typeable - - - - - b79fd7a0 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 More wibbles - - - - - a1aeb56c by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends - - - - - da10c25f by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Unused variable - - - - - 652682a8 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibbles - - - - - c2ca818c by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibble - - - - - 5b3b2379 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Accept error message changes - - - - - 3478c102 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. - - - - - 3970b90c by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Introduce GHC.Core.TyCo.Compare Lots of import changes! - - - - - b4115c58 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Update haddock submodule (I hope) - - - - - 89f9db0e by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibbles (notably: actually add GHC.Core.TyCo.Compare) - - - - - 3c2229cf by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibbles - - - - - 9bad1ffc by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibble output of T16575 - - - - - b70c4da5 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibbles - - - - - 1ca63089 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 More wibbles - - - - - c53bf8e7 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Remove infinite loop in T1946 See Note [ForAllTy and type equality] - - - - - 8cbac138 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Deal with rejigConRes Needs a Note to be written by Richard - - - - - c71b749e by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag - - - - - 6cd3c8f2 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Update haddock submodule - - - - - 9f1ef41f by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Rename TyCoBinder to ForAllTyBinder - - - - - 6b9420b8 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibbles - - - - - 0c47a8a6 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Update haddock - - - - - bcbac282 by Simon Peyton Jones at 2022-09-07T09:08:09+01:00 Wibble - - - - - 7daff5a9 by Simon Peyton Jones at 2022-09-07T09:11:07+01:00 Update unix submodule I think I accidentally got it out of sync with HEAD; this puts it back. - - - - - 21 changed files: - .gitlab/ci.sh - 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/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.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/Multiplicity.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/33295998c12f4aa50da2ac17545eaa1837ef451a...7daff5a9df7e0bd4ba7b77e49b24004505171357 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/33295998c12f4aa50da2ac17545eaa1837ef451a...7daff5a9df7e0bd4ba7b77e49b24004505171357 You're receiving 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 Sep 7 13:15:37 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 07 Sep 2022 09:15:37 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Primop: WriteByteArrayOp_Word8AsChar use setInt8 Message-ID: <631899793b2fb_869eb5146434247c@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: a39992ae by doyougnu at 2022-09-07T09:14:49-04:00 Primop: WriteByteArrayOp_Word8AsChar use setInt8 - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1117,7 +1117,7 @@ genPrim prof ty op = case op of ] ReadByteArrayOp_Word8AsWord -> \[r] [a,i] -> PrimInline $ r |= dv_u32 a i - WriteByteArrayOp_Word8AsChar -> \[] [a,i,e] -> PrimInline $ dv_s_u8 a i e + WriteByteArrayOp_Word8AsChar -> \[] [a,i,e] -> PrimInline $ dv_s_i8 a i e WriteByteArrayOp_Word8AsWideChar -> \[] [a,i,e] -> PrimInline $ dv_s_i32 a i e WriteByteArrayOp_Word8AsAddr -> \[] [a,i,e1,e2] -> PrimInline $ mconcat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a39992ae2c425a5c0ece62f1bcc4ead7b54db4ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a39992ae2c425a5c0ece62f1bcc4ead7b54db4ea You're receiving 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 Sep 7 13:32:02 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 07 Sep 2022 09:32:02 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Primops: remove dv_s_u8 Message-ID: <63189d52e1578_869eb5143c3426db@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 83a8317a by doyougnu at 2022-09-07T09:30:29-04:00 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. - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1277,9 +1277,8 @@ u1_ a i = IdxExpr (a .^ "u1") i -- of the index @i@, the new value to set (in the case of a setter) @v@, and a -- Boolean flag indicating whether the type in question is stored in -- little-endian (True) or big-endian (False) format. -dv_s_i8, dv_s_u8, dv_s_i16, dv_s_u16, dv_s_i32, dv_s_u32, dv_s_f32, dv_s_f64 :: JExpr -> JExpr -> JExpr -> JStat +dv_s_i8, dv_s_i16, dv_s_u16, dv_s_i32, dv_s_u32, dv_s_f32, dv_s_f64 :: JExpr -> JExpr -> JExpr -> JStat dv_s_i8 a i v = ApplStat (a .^ "dv" .^ "setInt8" ) [i, v, true_] -dv_s_u8 a i v = ApplStat (a .^ "dv" .^ "setUInt8" ) [i, v, true_] dv_s_u16 a i v = ApplStat (a .^ "dv" .^ "setUint16" ) [i, v, true_] dv_s_i16 a i v = ApplStat (a .^ "dv" .^ "setInt16" ) [i, v, true_] dv_s_i32 a i v = ApplStat (a .^ "dv" .^ "setInt32" ) [i, v, true_] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83a8317af6db422b15b5bd9d763b909b5333e684 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83a8317af6db422b15b5bd9d763b909b5333e684 You're receiving 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 Sep 7 16:50:42 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 07 Sep 2022 12:50:42 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Primops: set dv_u8 to correct method call Message-ID: <6318cbe23ff42_869eb515f435923c@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: dcd89960 by doyougnu at 2022-09-07T12:49:25-04:00 Primops: set dv_u8 to correct method call should be getUint8, not getUInt8, of course the naming convention changes ever so slightly for Words. - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1287,7 +1287,7 @@ dv_s_f32 a i v = ApplStat (a .^ "dv" .^ "setFloat32") [i, v, true_] dv_s_f64 a i v = ApplStat (a .^ "dv" .^ "setFloat64") [i, v, true_] dv_i8, dv_u8, dv_i16, dv_u16, dv_i32, dv_u32, dv_f32, dv_f64 :: JExpr -> JExpr -> JExpr -dv_u8 a i = ApplExpr (a .^ "dv" .^ "getUInt8" ) [i, true_] +dv_u8 a i = ApplExpr (a .^ "dv" .^ "getUint8" ) [i, true_] dv_i8 a i = ApplExpr (a .^ "dv" .^ "getInt8" ) [i, true_] dv_i16 a i = ApplExpr (a .^ "dv" .^ "getInt16" ) [i, true_] dv_u16 a i = ApplExpr (a .^ "dv" .^ "getUint16" ) [i, true_] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dcd899606f29756be62d87f6a3a0a61602f28b78 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dcd899606f29756be62d87f6a3a0a61602f28b78 You're receiving 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 Sep 7 17:42:46 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 07 Sep 2022 13:42:46 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Fix :add docs in user guide Message-ID: <6318d8166d32c_869eb5152c3680eb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 220acfab by Eric Lindblad at 2022-09-07T13:42:33-04:00 typo - - - - - 6073934d by Eric Lindblad at 2022-09-07T13:42:33-04:00 typos - - - - - d2b99df6 by Eric Lindblad at 2022-09-07T13:42:33-04:00 whitespace - - - - - 7bcd79c5 by Cheng Shao at 2022-09-07T13:42:35-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - 737f63eb by Krzysztof Gogolewski at 2022-09-07T13:42:36-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 3aae3823 by Krzysztof Gogolewski at 2022-09-07T13:42:36-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Gen/Pat.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d59e3f88a5418146061c11f261ca373b459f206...3aae3823e81c50a6ddf096210c4c25120124a879 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d59e3f88a5418146061c11f261ca373b459f206...3aae3823e81c50a6ddf096210c4c25120124a879 You're receiving 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 Sep 7 20:43:00 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 07 Sep 2022 16:43:00 -0400 Subject: [Git][ghc/ghc][master] 3 commits: typo Message-ID: <63190254a014b_869eb5148c3855c9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 7 changed files: - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/StgToByteCode.hs - libraries/base/GHC/Event/Windows.hsc Changes: ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -300,7 +300,7 @@ instance Outputable BCInstr where ppr CASEFAIL = text "CASEFAIL" ppr (JMP lab) = text "JMP" <+> ppr lab ppr (CCALL off marshall_addr flags) = text "CCALL " <+> ppr off - <+> text "marshall code at" + <+> text "marshal code at" <+> text (show marshall_addr) <+> (case flags of 0x1 -> text "(interruptible)" ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -307,7 +307,7 @@ only it knows how to build the dictionaries d1 and d2! For example Here, the specialised version of g is an application of g's rhs to the Ord dictionary for (Tree Int), which only the type checker can conjure up. There might not even *be* one, if (Tree Int) is not an instance of -Ord! (All the other specialision has suitable dictionaries to hand +Ord! (All the other specialisation has suitable dictionaries to hand from actual calls.) Problem. The type checker doesn't have to hand a convenient , because @@ -1335,7 +1335,7 @@ specBind top_lvl env (NonRec fn rhs) do_body fn3 = zapIdDemandInfo fn2 -- We zap the demand info because the binding may float, - -- which would invaidate the demand info (see #17810 for example). + -- which would invalidate the demand info (see #17810 for example). -- Destroying demand info is not terrible; specialisation is -- always followed soon by demand analysis. ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -153,7 +153,7 @@ Note [Overall plumbing for rules] In a single simplifier run new rules can be added into the EPS so it matters to keep an up-to-date view of which rules have been loaded. For examples of - where this went wrong and caused cryptic performance regressions seee + where this went wrong and caused cryptic performance regressions see T19790 and !6735. @@ -971,7 +971,7 @@ match renv subst e1 (Var v2) mco -- Note [Expanding variables] -- Note the match on MRefl! We fail if there is a cast in the target -- (e1 e2) ~ (d1 d2) |> co -- See Note [Cancel reflexive casts]: in the Cast equations for 'match' --- we agressively ensure that if MCo is reflective, it really is MRefl. +-- we aggressively ensure that if MCo is reflective, it really is MRefl. match renv subst (App f1 a1) (App f2 a2) MRefl = do { subst' <- match renv subst f1 f2 MRefl ; match renv subst' a1 a2 MRefl } @@ -1150,7 +1150,7 @@ when we eta-reduce (\a b. blah a b) to 'blah', we'll get and we really want to spot that the co/sym-co cancels out. Hence * We keep an invariant that the MCoercion is always MRefl - if the MCoercion is reflextve + if the MCoercion is reflexive * We maintain this invariant via the call to checkReflexiveMCo in the Cast case of 'match'. -} ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -129,7 +129,7 @@ The goal of this pass is to prepare for code generation. annotate according to scoping rules when floating. 11. Collect cost centres (including cost centres in unfoldings) if we're in - profiling mode. We have to do this here beucase we won't have unfoldings + profiling mode. We have to do this here because we won't have unfoldings after this pass (see `trimUnfolding` and Note [Drop unfoldings and rules]. 12. Eliminate case clutter in favour of unsafe coercions. @@ -179,7 +179,7 @@ CorePrep does these two transformations: Tiresome, but not difficult. These transformations get rid of "case clutter", leaving only casts. -We are doing no further significant tranformations, so the reasons +We are doing no further significant transformations, so the reasons for the case forms have disappeared. And it is extremely helpful for the ANF-ery, CoreToStg, and backends, if trivial expressions really do look trivial. #19700 was an example. @@ -2028,7 +2028,7 @@ enterRecGroupRHSs env grp {- Note [CpeTyCoEnv] ~~~~~~~~~~~~~~~~~~~~ The cpe_tyco_env :: Maybe CpeTyCoEnv field carries a substitution -for type and coercion varibles +for type and coercion variables * We need the coercion substitution to support the elimination of unsafeEqualityProof (see Note [Unsafe coercions]) ===================================== compiler/GHC/Stg/Lint.hs ===================================== @@ -68,8 +68,8 @@ is much coarser. In particular, STG programs must be /well-kinded/. More precisely, if f :: ty1 -> ty2, then in the application (f e) where e :: ty1', we must have kind(ty1) = kind(ty1'). -So the STG type system does not distinguish beteen Int and Bool, -but it /does/ distinguish beteen Int and Int#, because they have +So the STG type system does not distinguish between Int and Bool, +but it /does/ distinguish between Int and Int#, because they have different kinds. Actually, since all terms have kind (TYPE rep), we might say that the STG language is well-runtime-rep'd. @@ -356,7 +356,7 @@ lintStgAppReps fun args = do | and $ zipWith (primRepCompatible platform) actual_rep expected_rep = match_args actual_reps_left expected_reps_left - | otherwise = addErrL $ hang (text "Function type reps and function argument reps missmatched") 2 $ + | otherwise = addErrL $ hang (text "Function type reps and function argument reps mismatched") 2 $ (text "In application " <> ppr fun <+> ppr args $$ text "argument rep:" <> ppr actual_rep $$ text "expected rep:" <> ppr expected_rep $$ ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -1330,7 +1330,7 @@ generateCCall d0 s p (CCallSpec target cconv safety) result_ty args_r_to_l Addr# address_of_C_fn (must be an unboxed type) - The interpreter then calls the marshall code mentioned + The interpreter then calls the marshal code mentioned in the CCALL insn, passing it (& ), that is, the addr of the topmost word in the stack. When this returns, the placeholder will have been ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -1039,7 +1039,7 @@ step maxDelay mgr at Manager{..} = do -- before adding something to the work queue. -- -- Thread safety: This function atomically replaces outstanding events with --- a pointer to nullReq. This means it's safe (but potentially wastefull) to +-- a pointer to nullReq. This means it's safe (but potentially wasteful) to -- have two concurrent or parallel invocations on the same array. processCompletion :: Manager -> Int -> Maybe Seconds -> IO (Bool, Maybe Seconds) processCompletion Manager{..} n delay = do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/808bb7934e1e3007bf7115bdf75263bba937c85b...a581186f38a4feb850614b03f452191eaceee14d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/808bb7934e1e3007bf7115bdf75263bba937c85b...a581186f38a4feb850614b03f452191eaceee14d You're receiving 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 Sep 7 20:43:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 07 Sep 2022 16:43:39 -0400 Subject: [Git][ghc/ghc][master] CmmToAsm: remove unused ModLocation from NatM_State Message-ID: <6319027ba55de_869eb514503891b7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - 3 changed files: - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Monad.hs - testsuite/tests/regalloc/regalloc_unit_tests.hs Changes: ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -331,7 +331,7 @@ cmmNativeGenStream logger config modLoc ncgImpl h us cmm_stream ngs dbgMap = debugToMap ndbgs -- Generate native code - (ngs',us') <- cmmNativeGens logger config modLoc ncgImpl h + (ngs',us') <- cmmNativeGens logger config ncgImpl h dbgMap us cmms ngs 0 -- Link native code information into debug blocks @@ -355,7 +355,6 @@ cmmNativeGens :: forall statics instr jumpDest. (OutputableP Platform statics, Outputable jumpDest, Instruction instr) => Logger -> NCGConfig - -> ModLocation -> NcgImpl statics instr jumpDest -> BufHandle -> LabelMap DebugBlock @@ -365,7 +364,7 @@ cmmNativeGens :: forall statics instr jumpDest. -> Int -> IO (NativeGenAcc statics instr, UniqSupply) -cmmNativeGens logger config modLoc ncgImpl h dbgMap = go +cmmNativeGens logger config ncgImpl h dbgMap = go where go :: UniqSupply -> [RawCmmDecl] -> NativeGenAcc statics instr -> Int @@ -378,7 +377,7 @@ cmmNativeGens logger config modLoc ncgImpl h dbgMap = go let fileIds = ngs_dwarfFiles ngs (us', fileIds', native, imports, colorStats, linearStats, unwinds) <- {-# SCC "cmmNativeGen" #-} - cmmNativeGen logger modLoc ncgImpl us fileIds dbgMap + cmmNativeGen logger ncgImpl us fileIds dbgMap cmm count -- Generate .file directives for every new file that has been @@ -432,7 +431,6 @@ emitNativeCode logger config h sdoc = do cmmNativeGen :: forall statics instr jumpDest. (Instruction instr, OutputableP Platform statics, Outputable jumpDest) => Logger - -> ModLocation -> NcgImpl statics instr jumpDest -> UniqSupply -> DwarfFiles @@ -448,7 +446,7 @@ cmmNativeGen , LabelMap [UnwindPoint] -- unwinding information for blocks ) -cmmNativeGen logger modLoc ncgImpl us fileIds dbgMap cmm count +cmmNativeGen logger ncgImpl us fileIds dbgMap cmm count = do let config = ncgConfig ncgImpl let platform = ncgPlatform config @@ -478,7 +476,7 @@ cmmNativeGen logger modLoc ncgImpl us fileIds dbgMap cmm count -- generate native code from cmm let ((native, lastMinuteImports, fileIds', nativeCfgWeights), usGen) = {-# SCC "genMachCode" #-} - initUs us $ genMachCode config modLoc + initUs us $ genMachCode config (cmmTopCodeGen ncgImpl) fileIds dbgMap opt_cmm cmmCfg @@ -902,7 +900,6 @@ apply_mapping ncgImpl ufm (CmmProc info lbl live (ListGraph blocks)) genMachCode :: NCGConfig - -> ModLocation -> (RawCmmDecl -> NatM [NatCmmDecl statics instr]) -> DwarfFiles -> LabelMap DebugBlock @@ -915,10 +912,10 @@ genMachCode , CFG ) -genMachCode config modLoc cmmTopCodeGen fileIds dbgMap cmm_top cmm_cfg +genMachCode config cmmTopCodeGen fileIds dbgMap cmm_top cmm_cfg = do { initial_us <- getUniqueSupplyM ; let initial_st = mkNatM_State initial_us 0 config - modLoc fileIds dbgMap cmm_cfg + fileIds dbgMap cmm_cfg (new_tops, final_st) = initNat initial_st (cmmTopCodeGen cmm_top) final_delta = natm_delta final_st final_imports = natm_imports final_st ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -32,7 +32,6 @@ module GHC.CmmToAsm.Monad ( getPicBaseMaybeNat, getPicBaseNat, getCfgWeights, - getModLoc, getFileId, getDebugBlock, @@ -111,7 +110,6 @@ data NatM_State natm_imports :: [(CLabel)], natm_pic :: Maybe Reg, natm_config :: NCGConfig, - natm_modloc :: ModLocation, natm_fileid :: DwarfFiles, natm_debug_map :: LabelMap DebugBlock, natm_cfg :: CFG @@ -128,17 +126,16 @@ newtype NatM result = NatM (NatM_State -> (result, NatM_State)) unNat :: NatM a -> NatM_State -> (a, NatM_State) unNat (NatM a) = a -mkNatM_State :: UniqSupply -> Int -> NCGConfig -> ModLocation -> +mkNatM_State :: UniqSupply -> Int -> NCGConfig -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State mkNatM_State us delta config - = \loc dwf dbg cfg -> + = \dwf dbg cfg -> NatM_State { natm_us = us , natm_delta = delta , natm_imports = [] , natm_pic = Nothing , natm_config = config - , natm_modloc = loc , natm_fileid = dwf , natm_debug_map = dbg , natm_cfg = cfg @@ -309,10 +306,6 @@ getPicBaseNat rep reg <- getNewRegNat rep NatM (\state -> (reg, state { natm_pic = Just reg })) -getModLoc :: NatM ModLocation -getModLoc - = NatM $ \ st -> (natm_modloc st, st) - -- | Get native code generator configuration getConfig :: NatM NCGConfig getConfig = NatM $ \st -> (natm_config st, st) ===================================== testsuite/tests/regalloc/regalloc_unit_tests.hs ===================================== @@ -152,7 +152,7 @@ compileCmmForRegAllocStats logger home_unit dflags cmmFile ncgImplF us = do -- compile and discard the generated code, returning regalloc stats mapM (\ (count, thisCmm) -> - cmmNativeGen logger thisModLoc ncgImpl + cmmNativeGen logger ncgImpl usb dwarfFileIds dbgMap thisCmm count >>= (\(_, _, _, _, colorStats, linearStats, _) -> -- scrub unneeded output from cmmNativeGen @@ -167,7 +167,6 @@ compileCmmForRegAllocStats logger home_unit dflags cmmFile ncgImplF us = do thisMod = mkModule (stringToUnit . show . uniqFromSupply $ usc) (mkModuleName . show . uniqFromSupply $ usd) - thisModLoc = mkHiOnlyModLocation (initFinderOpts dflags) "hi" "dyn_hi" "" cmmFile -- | The register allocator should be able to see that each variable only View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04a738cb23e82b32caf38b7965f5042e6af6ee88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04a738cb23e82b32caf38b7965f5042e6af6ee88 You're receiving 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 Sep 7 20:44:17 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 07 Sep 2022 16:44:17 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Minor SDoc cleanup Message-ID: <631902a197073_869eb5143c3927d9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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". - - - - - 23 changed files: - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Layout.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Utils/Outputable.hs Changes: ===================================== compiler/GHC/Cmm/Dominators.hs ===================================== @@ -38,9 +38,7 @@ import GHC.Cmm.Dataflow.Graph import GHC.Cmm.Dataflow.Label import GHC.Cmm -import GHC.Utils.Outputable( Outputable(..), text, int, hcat, (<+>) - , showSDocUnsafe - ) +import GHC.Utils.Outputable( Outputable(..), text, int, hcat, (<+>)) import GHC.Utils.Misc import GHC.Utils.Panic @@ -188,7 +186,7 @@ gwdRPNumber g l = findLabelIn l (gwd_rpnumbering g) findLabelIn :: HasDebugCallStack => Label -> LabelMap a -> a findLabelIn lbl = mapFindWithDefault failed lbl where failed = - panic $ "label " ++ showSDocUnsafe (ppr lbl) ++ " not found in result of analysis" + pprPanic "label not found in result of analysis" (ppr lbl) -- | Use `gwdDominatorsOf` on the result of the dominator analysis to get -- a mapping from the `Label` of each reachable block to the dominator ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -449,7 +449,7 @@ cmmproc :: { CmmParse () } platform <- getPlatform; ctx <- getContext; formals <- sequence (fromMaybe [] $3); - withName (renderWithContext ctx (pprCLabel platform CStyle entry_ret_label)) + withName (showSDocOneLine ctx (pprCLabel platform CStyle entry_ret_label)) $4; return (entry_ret_label, info, stk_formals, formals) } let do_layout = isJust $3 ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -696,7 +696,7 @@ maybeDumpCfg logger (Just cfg) msg proc_name checkLayout :: [NatCmmDecl statics instr] -> [NatCmmDecl statics instr] -> [NatCmmDecl statics instr] checkLayout procsUnsequenced procsSequenced = - assertPpr (setNull diff) (ppr "Block sequencing dropped blocks:" <> ppr diff) + assertPpr (setNull diff) (text "Block sequencing dropped blocks:" <> ppr diff) procsSequenced where blocks1 = foldl' (setUnion) setEmpty $ @@ -785,7 +785,7 @@ makeImportsDoc config imports | otherwise = Outputable.empty - doPpr lbl = (lbl, renderWithContext + doPpr lbl = (lbl, showSDocOneLine (ncgAsmContext config) (pprAsmLabel platform lbl)) ===================================== compiler/GHC/CmmToAsm/CFG.hs ===================================== @@ -660,7 +660,7 @@ getCfg platform weights graph = (CmmCall { cml_cont = Nothing }) -> [] other -> panic "Foo" $ - assertPpr False (ppr "Unknown successor cause:" <> + assertPpr False (text "Unknown successor cause:" <> (pdoc platform branch <+> text "=>" <> pdoc platform (G.successors other))) $ map (\x -> ((bid,x),mkEdgeInfo 0)) $ G.successors other where ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2015,10 +2015,10 @@ genCondBranch' _ bid id false bool = do -- Use ASSERT so we don't break releases if -- LTT/LE creep in somehow. LTT -> - assertPpr False (ppr "Should have been turned into >") + assertPpr False (text "Should have been turned into >") and_ordered LE -> - assertPpr False (ppr "Should have been turned into >=") + assertPpr False (text "Should have been turned into >=") and_ordered _ -> and_ordered @@ -3088,9 +3088,9 @@ condFltReg is32Bit cond x y = condFltReg_sse2 GU -> plain_test dst GEU -> plain_test dst -- Use ASSERT so we don't break releases if these creep in. - LTT -> assertPpr False (ppr "Should have been turned into >") $ + LTT -> assertPpr False (text "Should have been turned into >") $ and_ordered dst - LE -> assertPpr False (ppr "Should have been turned into >=") $ + LE -> assertPpr False (text "Should have been turned into >=") $ and_ordered dst _ -> and_ordered dst) ===================================== compiler/GHC/CmmToLlvm/Base.hs ===================================== @@ -447,7 +447,7 @@ strCLabel_llvm lbl = do ctx <- llvmCgContext <$> getConfig platform <- getPlatform let sdoc = pprCLabel platform CStyle lbl - str = Outp.renderWithContext ctx sdoc + str = Outp.showSDocOneLine ctx sdoc return (fsLit str) -- ---------------------------------------------------------------------------- ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -1203,10 +1203,10 @@ genStore_slow addr val alignment meta = do other -> pprPanic "genStore: ptr not right type!" - (pdoc platform addr <+> text ( - "Size of Ptr: " ++ show (llvmPtrBits platform) ++ - ", Size of var: " ++ show (llvmWidthInBits platform other) ++ - ", Var: " ++ renderWithContext (llvmCgContext cfg) (ppVar cfg vaddr))) + (pdoc platform addr $$ + text "Size of Ptr:" <+> ppr (llvmPtrBits platform) $$ + text "Size of var:" <+> ppr (llvmWidthInBits platform other) $$ + text "Var:" <+> ppVar cfg vaddr) mkStore :: LlvmVar -> LlvmVar -> AlignmentSpec -> LlvmStatement mkStore vval vptr alignment = @@ -1255,7 +1255,7 @@ genExpectLit expLit expTy var = do lit = LMLitVar $ LMIntLit expLit expTy llvmExpectName - | isInt expTy = fsLit $ "llvm.expect." ++ renderWithContext (llvmCgContext cfg) (ppr expTy) + | isInt expTy = fsLit $ "llvm.expect." ++ showSDocOneLine (llvmCgContext cfg) (ppr expTy) | otherwise = panic "genExpectedLit: Type not an int!" (llvmExpect, stmts, top) <- @@ -1874,10 +1874,10 @@ genLoad_slow atomic e ty align meta = do doExprW (cmmToLlvmType ty) (MExpr meta $ mkLoad atomic ptr align) other -> pprPanic "exprToVar: CmmLoad expression is not right type!" - (pdoc platform e <+> text ( - "Size of Ptr: " ++ show (llvmPtrBits platform) ++ - ", Size of var: " ++ show (llvmWidthInBits platform other) ++ - ", Var: " ++ renderWithContext (llvmCgContext cfg) (ppVar cfg iptr))) + (pdoc platform e $$ + text "Size of Ptr:" <+> ppr (llvmPtrBits platform) $$ + text "Size of var:" <+> ppr (llvmWidthInBits platform other) $$ + text "Var:" <+> (ppVar cfg iptr)) {- Note [Alignment of vector-typed values] ===================================== compiler/GHC/CmmToLlvm/Ppr.hs ===================================== @@ -56,7 +56,7 @@ pprLlvmCmmDecl (CmmProc mb_info entry_lbl live (ListGraph blks)) funDec <- llvmFunSig live lbl link cfg <- getConfig platform <- getPlatform - let buildArg = fsLit . renderWithContext (llvmCgContext cfg). ppPlainName cfg + let buildArg = fsLit . showSDocOneLine (llvmCgContext cfg). ppPlainName cfg funArgs = map buildArg (llvmFunArgs platform live) funSect = llvmFunSection cfg (decName funDec) ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1213,7 +1213,7 @@ tryUnfolding logger opts !case_depth id lone_variable , text "ANSWER =" <+> if yes_or_no then text "YES" else text "NO"] ctx = log_default_dump_context (logFlags logger) - str = "Considering inlining: " ++ renderWithContext ctx (ppr id) + str = "Considering inlining: " ++ showSDocOneLine ctx (ppr id) n_val_args = length arg_infos -- some_benefit is used when the RHS is small enough ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -589,7 +589,7 @@ compileForeign hsc_env lang stub_c = do -- This should never happen as viaCPipeline should only return `Nothing` when the stop phase is `StopC`. -- and the same should never happen for asPipeline -- Future refactoring to not check StopC for this case - Nothing -> pprPanic "compileForeign" (ppr stub_c) + Nothing -> pprPanic "compileForeign" (text stub_c) Just fp -> return fp compileEmptyStub :: DynFlags -> HscEnv -> FilePath -> ModLocation -> ModuleName -> IO () ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -860,9 +860,11 @@ getOutputFilename logger tmpfs stop_phase output basename dflags next_phase mayb | otherwise = newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule suffix where - getOutputFile_ dflags = case outputFile_ dflags of - Nothing -> pprPanic "SpecificFile: No filename" (ppr $ (dynamicNow dflags, outputFile_ dflags, dynOutputFile_ dflags)) - Just fn -> fn + getOutputFile_ dflags = + case outputFile_ dflags of + Nothing -> pprPanic "SpecificFile: No filename" (ppr (dynamicNow dflags) $$ + text (fromMaybe "-" (dynOutputFile_ dflags))) + Just fn -> fn hcsuf = hcSuf dflags odir = objectDir dflags ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -848,7 +848,7 @@ pprTcSpecPrags (SpecPrags ps) = vcat (map (ppr . unLoc) ps) instance Outputable TcSpecPrag where ppr (SpecPrag var _ inl) - = ppr (extractSpecPragName $ inl_src inl) <+> pprSpec var (text "") inl + = text (extractSpecPragName $ inl_src inl) <+> pprSpec var (text "") inl pprMinimalSig :: (OutputableBndr name) => LBooleanFormula (GenLocated l name) -> SDoc ===================================== compiler/GHC/HsToCore/Foreign/C.hs ===================================== @@ -333,7 +333,7 @@ dsFCall fn_id co fcall mDeclHeader = do toCName :: Id -> String -toCName i = renderWithContext defaultSDocContext (pprCode (ppr (idName i))) +toCName i = showSDocOneLine defaultSDocContext (pprCode (ppr (idName i))) toCType :: Type -> (Maybe Header, SDoc) toCType = f False ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -118,7 +118,7 @@ readBinIfaceHeader profile _name_cache checkHiWay traceBinIFace hi_path = do check_tag <- get bh let tag = profileBuildTag profile - wantedGot "Way" tag check_tag ppr + wantedGot "Way" tag check_tag text when (checkHiWay == CheckHiWay) $ errorOnMismatch "mismatched interface file profile tag" tag check_tag @@ -381,7 +381,7 @@ getSymtabName _name_cache _dict symtab bh = do in return $! case lookupKnownKeyName u of Nothing -> pprPanic "getSymtabName:unknown known-key unique" - (ppr i $$ ppr (unpkUnique u)) + (ppr i $$ ppr u) Just n -> n _ -> pprPanic "getSymtabName:unknown name tag" (ppr i) ===================================== compiler/GHC/Iface/Ext/Binary.hs ===================================== @@ -331,7 +331,7 @@ fromHieName nc hie_name = do KnownKeyName u -> case lookupKnownKeyName u of Nothing -> pprPanic "fromHieName:unknown known-key unique" - (ppr (unpkUnique u)) + (ppr u) Just n -> pure n -- ** Reading and writing `HieName`'s ===================================== compiler/GHC/Iface/Ext/Types.hs ===================================== @@ -774,7 +774,7 @@ hieNameOcc (KnownKeyName u) = case lookupKnownKeyName u of Just n -> nameOccName n Nothing -> pprPanic "hieNameOcc:unknown known-key unique" - (ppr (unpkUnique u)) + (ppr u) toHieName :: Name -> HieName toHieName name ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -653,14 +653,14 @@ checkDependencies hsc_env summary iface text "package " <> quotes (ppr old) <> text "no longer in dependencies" return $ needsRecompileBecause $ UnitDepRemoved old - check_packages (new:news) olds + check_packages ((new_name, new_unit):news) olds | Just (old, olds') <- uncons olds - , snd new == old = check_packages (dropWhile ((== (snd new)) . snd) news) olds' + , new_unit == old = check_packages (dropWhile ((== new_unit) . snd) news) olds' | otherwise = do trace_hi_diffs logger $ - text "imported package " <> quotes (ppr new) <> - text " not among previous dependencies" - return $ needsRecompileBecause $ ModulePackageChanged $ fst new + text "imported package" <+> text new_name <+> ppr new_unit <+> + text "not among previous dependencies" + return $ needsRecompileBecause $ ModulePackageChanged new_name needInterface :: Module -> (ModIface -> IO RecompileRequired) ===================================== compiler/GHC/Linker/Types.hs ===================================== @@ -244,7 +244,7 @@ data LibrarySpec | Framework String -- Only used for darwin, but does no harm instance Outputable LibrarySpec where - ppr (Objects objs) = text "Objects" <+> ppr objs + ppr (Objects objs) = text "Objects" <+> ppr (map text objs) ppr (Archive a) = text "Archive" <+> text a ppr (DLL s) = text "DLL" <+> text s ppr (DLLPath f) = text "DLLPath" <+> text f ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -783,5 +783,5 @@ closureDescription -- Not called for StgRhsCon which have global info tables built in -- CgConTbls.hs with a description generated from the data constructor closureDescription mod_name name - = renderWithContext defaultSDocContext + = showSDocOneLine defaultSDocContext (char '<' <> pprFullName mod_name name <> char '>') ===================================== compiler/GHC/StgToCmm/Layout.hs ===================================== @@ -208,7 +208,7 @@ slowCall fun stg_args r <- direct_call "slow_call" NativeNodeCall (mkRtsApFastLabel rts_fun) arity ((P,Just fun):argsreps) emitComment $ mkFastString ("slow_call for " ++ - renderWithContext ctx (pdoc platform fun) ++ + showSDocOneLine ctx (pdoc platform fun) ++ " with pat " ++ unpackFS rts_fun) return r ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -1926,7 +1926,7 @@ genFamInsts spec@(DS { ds_tvs = tyvars, ds_mechanism = mechanism -- canDeriveAnyClass should ensure that this code can't be reached -- unless -XDeriveAnyClass is enabled. assertPpr (xopt LangExt.DeriveAnyClass dflags) - (ppr "genFamInsts: bad derived class" <+> ppr clas) $ + (text "genFamInsts: bad derived class" <+> ppr clas) $ mapM (tcATDefault loc mini_subst emptyNameSet) (classATItems clas) pure $ concat tyfam_insts ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -20,7 +20,6 @@ module GHC.Tc.Gen.Pat , tcCheckPat, tcCheckPat_O, tcInferPat , tcPats , addDataConStupidTheta - , polyPatSig ) where @@ -36,7 +35,6 @@ import GHC.Tc.Utils.Zonk import GHC.Tc.Gen.Sig( TcPragEnv, lookupPragEnv, addInlinePrags ) import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Instantiate -import GHC.Types.Error import GHC.Types.FieldLabel import GHC.Types.Id import GHC.Types.Var @@ -1503,8 +1501,3 @@ checkGADT conlike ex_tvs arg_tys = \case where has_existentials :: Bool has_existentials = any (`elemVarSet` tyCoVarsOfTypes arg_tys) ex_tvs - -polyPatSig :: TcType -> SDoc -polyPatSig sig_ty - = hang (text "Illegal polymorphic type signature in pattern:") - 2 (ppr sig_ty) ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -895,8 +895,8 @@ keyword = coloured Col.colBold class Outputable a where ppr :: a -> SDoc -instance Outputable Char where - ppr c = text [c] +-- There's no Outputable for Char; it's too easy to use Outputable +-- on String and have ppr "hello" rendered as "h,e,l,l,o". instance Outputable Bool where ppr True = text "True" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04a738cb23e82b32caf38b7965f5042e6af6ee88...7918265d53db963bfd3dd529b1063fb844549733 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04a738cb23e82b32caf38b7965f5042e6af6ee88...7918265d53db963bfd3dd529b1063fb844549733 You're receiving 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 Sep 8 11:51:16 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 08 Sep 2022 07:51:16 -0400 Subject: [Git][ghc/ghc][wip/T21623] 68 commits: typo Message-ID: <6319d734581e9_869eb5146445768@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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". - - - - - 820e9f35 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Start work Not ready for review - - - - - d27d2730 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 More progress - - - - - ef482591 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Wibbles - - - - - 7ec21ebe by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Stage1 compiles - - - - - 1c2036ba by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 More wibbles - - - - - a387b1c0 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 More wibbles - - - - - bfeb66b3 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 More -- almost working - - - - - 8ce6b7f2 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Comments - - - - - 4e2871ec by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Wibbles - - - - - 2f43cd0c by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Wibbles - - - - - 0422889e by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Wibble inlineId - - - - - 5a65b2f8 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Wibbles - - - - - 331da3f5 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Infinite loop somewhere - - - - - 08c5a4b2 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 More wibbles. Maybe can build stage2 - - - - - 9b4b1659 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Make FuNCo a thing by itself - - - - - 74da2568 by Simon Peyton Jones at 2022-09-08T12:50:57+01:00 Wibble - - - - - db7f8494 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble - - - - - 9091a657 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles - - - - - 6fae0170 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Fix OptCoercion - - - - - dabcbf8f by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble - - - - - ad16b29a by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble to optCoercion - - - - - c9117d91 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Replace SORT with TYPE and CONSTRAINT - - - - - 5072a337 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble - - - - - 30fe98cd by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Delete unused import - - - - - b9a40534 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Delete TypeOrConstraint from ghc-prim:GHC.Types - - - - - ff6b94a0 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Move from NthCo to SelCo - - - - - 9fd072e2 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles - - - - - 977c740f by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles in RepType - - - - - 61356b0a by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble - - - - - d6eef876 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Add mkWpEta - - - - - c8b56fa7 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Really add mkWpEta - - - - - d8baedd6 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble Typeable binds etc - - - - - 100d6013 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Improve error messages - - - - - 7b275f3a by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 More wibbles, mainly to error messages - - - - - a21a64fb by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles - - - - - bca0393b by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles to errors - - - - - ee5bdc14 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles But especially: treat Constraint as Typeable - - - - - 099d792a by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 More wibbles - - - - - a11b90d0 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends - - - - - bb136c62 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Unused variable - - - - - 7030b678 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles - - - - - 6cc8dcaf by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble - - - - - 8a83bf7a by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Accept error message changes - - - - - df687696 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. - - - - - 85a75d8c by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Introduce GHC.Core.TyCo.Compare Lots of import changes! - - - - - e29176d5 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Update haddock submodule (I hope) - - - - - 6c591201 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles (notably: actually add GHC.Core.TyCo.Compare) - - - - - 3344603f by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles - - - - - 273a1424 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibble output of T16575 - - - - - ae0addc8 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Wibbles - - - - - 627088c8 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 More wibbles - - - - - fe77a552 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Remove infinite loop in T1946 See Note [ForAllTy and type equality] - - - - - f0a645e9 by Simon Peyton Jones at 2022-09-08T12:50:58+01:00 Deal with rejigConRes Needs a Note to be written by Richard - - - - - 0b7519c8 by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag - - - - - 2d4e80cb by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Update haddock submodule - - - - - 31ec72df by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Rename TyCoBinder to ForAllTyBinder - - - - - fde82701 by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Wibbles - - - - - fb9b79dc by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Update haddock - - - - - c6fcfb97 by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Wibble - - - - - 0b546b48 by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Update unix submodule I think I accidentally got it out of sync with HEAD; this puts it back. - - - - - 4dfc55df by Simon Peyton Jones at 2022-09-08T12:50:59+01:00 Rename TyCoBinder to PiTyBinder - - - - - 52536468 by Simon Peyton Jones at 2022-09-08T12:52:36+01:00 Update Haddock submodule - - - - - 28 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/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Map/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7daff5a9df7e0bd4ba7b77e49b24004505171357...5253646887ffb1c158458802589bae8d34c3b495 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7daff5a9df7e0bd4ba7b77e49b24004505171357...5253646887ffb1c158458802589bae8d34c3b495 You're receiving 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 Sep 8 19:19:15 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Sep 2022 15:19:15 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: typo Message-ID: <631a4033a3826_869eb514285108a0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - b131308e by Cheng Shao at 2022-09-08T15:18:58-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. - - - - - 30 changed files: - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Prelude.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/StgToCmm/Layout.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3aae3823e81c50a6ddf096210c4c25120124a879...b131308ec561514941b31ec311f3d73dfc5a4148 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3aae3823e81c50a6ddf096210c4c25120124a879...b131308ec561514941b31ec311f3d73dfc5a4148 You're receiving 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 Sep 8 21:31:33 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 08 Sep 2022 17:31:33 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22152 Message-ID: <631a5f3529eb2_869eb514dc522619@gitlab.mail> Sylvain Henry pushed new branch wip/T22152 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22152 You're receiving 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 Sep 8 21:49:27 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Sep 2022 17:49:27 -0400 Subject: [Git][ghc/ghc][master] 5 commits: Export liftA2 from Prelude Message-ID: <631a6367eaa0c_869eb5152c5348a8@gitlab.mail> Marge Bot pushed to branch master 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. - - - - - 15 changed files: - compiler/GHC/Hs/Doc.hs - compiler/GHC/Prelude.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Misc.hs - compiler/GHC/Utils/Monad.hs - libraries/Cabal - libraries/base/Data/Complex.hs - libraries/base/Data/List/NonEmpty.hs - libraries/base/Data/Semigroup.hs - libraries/base/Prelude.hs - libraries/base/changelog.md - libraries/containers - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -38,7 +38,6 @@ import GHC.Types.Avail import GHC.Types.Name.Set import GHC.Driver.Flags -import Control.Applicative (liftA2) import Data.Data import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap ===================================== compiler/GHC/Prelude.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Prelude (module X + ,Applicative (..) ,module Bits ,shiftL, shiftR ) where @@ -47,7 +48,8 @@ NoImplicitPrelude. There are two motivations for this: extensions. -} -import Prelude as X hiding ((<>)) +import Prelude as X hiding ((<>), Applicative(..)) +import Control.Applicative (Applicative(..)) import Data.Foldable as X (foldl') #if MIN_VERSION_base(4,16,0) ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -125,7 +125,6 @@ import GHC.Data.FastString import qualified GHC.Data.Strict as Strict import Control.DeepSeq -import Control.Applicative (liftA2) import Data.Data import Data.List (sortBy, intercalate) import Data.Function (on) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -141,7 +141,6 @@ import Data.List.NonEmpty ( NonEmpty(..) ) import GHC.Exts import GHC.Stack (HasCallStack) -import Control.Applicative ( liftA2 ) import Control.Monad ( liftM, guard ) import Control.Monad.IO.Class ( MonadIO, liftIO ) import System.IO.Error as IO ( isDoesNotExistError ) ===================================== compiler/GHC/Utils/Monad.hs ===================================== @@ -29,7 +29,6 @@ module GHC.Utils.Monad import GHC.Prelude -import Control.Applicative import Control.Monad import Control.Monad.Fix import Control.Monad.IO.Class ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 5d18b763356dca719f5286a52328cb41b9fa4192 +Subproject commit dac10555299fa0d750838529a67598821264e5e3 ===================================== libraries/base/Data/Complex.hs ===================================== @@ -35,6 +35,7 @@ module Data.Complex ) where +import Prelude hiding (Applicative(..)) import GHC.Base (Applicative (..)) import GHC.Generics (Generic, Generic1) import GHC.Float (Floating(..)) ===================================== libraries/base/Data/List/NonEmpty.hs ===================================== @@ -102,7 +102,7 @@ import Prelude hiding (break, cycle, drop, dropWhile, last, length, map, repeat, reverse, scanl, scanl1, scanr, scanr1, span, splitAt, tail, take, takeWhile, - unzip, zip, zipWith, (!!)) + unzip, zip, zipWith, (!!), Applicative(..)) import qualified Prelude import Control.Applicative (Applicative (..), Alternative (many)) ===================================== libraries/base/Data/Semigroup.hs ===================================== @@ -98,7 +98,7 @@ module Data.Semigroup ( , ArgMax ) where -import Prelude hiding (foldr1) +import Prelude hiding (foldr1, Applicative(..)) import GHC.Base (Semigroup(..)) ===================================== libraries/base/Prelude.hs ===================================== @@ -73,7 +73,7 @@ module Prelude ( -- ** Monads and functors Functor(fmap, (<$)), (<$>), - Applicative(pure, (<*>), (*>), (<*)), + Applicative(pure, (<*>), (*>), (<*), liftA2), Monad((>>=), (>>), return), MonadFail(fail), mapM_, sequence_, (=<<), ===================================== libraries/base/changelog.md ===================================== @@ -25,6 +25,10 @@ * Change default `Ord` implementation of `(>=)`, `(>)`, and `(<)` to use `(<=)` instead of `compare` per [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/24). + * Export `liftA2` from `Prelude`. This means that the entirety of `Applicative` + is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) + for the related discussion, + as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) ## 4.17.0.0 *August 2022* ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 50175b72dc781f82a419bddafba1bdd758fbee4b +Subproject commit 5e338df84454b56d649360a57d2c186785aff2b4 ===================================== libraries/template-haskell/Language/Haskell/TH/Lib.hs ===================================== @@ -178,10 +178,10 @@ import Language.Haskell.TH.Lib.Internal hiding import qualified Language.Haskell.TH.Lib.Internal as Internal import Language.Haskell.TH.Syntax -import Control.Applicative ( liftA2 ) +import Control.Applicative (Applicative(..)) import Foreign.ForeignPtr import Data.Word -import Prelude +import Prelude hiding (Applicative(..)) -- All definitions below represent the "old" API, since their definitions are -- different in Language.Haskell.TH.Lib.Internal. Please think carefully before ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs ===================================== @@ -20,12 +20,12 @@ module Language.Haskell.TH.Lib.Internal where import Language.Haskell.TH.Syntax hiding (Role, InjectivityAnn) import qualified Language.Haskell.TH.Syntax as TH -import Control.Applicative(liftA, liftA2) +import Control.Applicative(liftA, Applicative(..)) import qualified Data.Kind as Kind (Type) import Data.Word( Word8 ) import Data.List.NonEmpty ( NonEmpty(..) ) import GHC.Exts (TYPE) -import Prelude +import Prelude hiding (Applicative(..)) ---------------------------------------------------------- -- * Type synonyms ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -39,7 +39,7 @@ import GHC.IO.Unsafe ( unsafeDupableInterleaveIO ) import Control.Monad (liftM) import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.Fix (MonadFix (..)) -import Control.Applicative (liftA2) +import Control.Applicative (Applicative(..)) import Control.Exception (BlockedIndefinitelyOnMVar (..), catch, throwIO) import Control.Exception.Base (FixIOException (..)) import Control.Concurrent.MVar (newEmptyMVar, readMVar, putMVar) @@ -60,7 +60,7 @@ import GHC.Lexeme ( startsVarSym, startsVarId ) import GHC.ForeignSrcLang.Type import Language.Haskell.TH.LanguageExtensions import Numeric.Natural -import Prelude +import Prelude hiding (Applicative(..)) import Foreign.ForeignPtr import Foreign.C.String import Foreign.C.Types View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7918265d53db963bfd3dd529b1063fb844549733...a4b34808720e93b434b4fcf18db114bc1f0599aa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7918265d53db963bfd3dd529b1063fb844549733...a4b34808720e93b434b4fcf18db114bc1f0599aa You're receiving 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 Sep 8 21:50:06 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Sep 2022 17:50:06 -0400 Subject: [Git][ghc/ghc][master] CmmToC: enable 64-bit CallishMachOp on 32-bit targets Message-ID: <631a638e7a508_869eb5143c5384dd@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - compiler/GHC/CmmToC.hs Changes: ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -967,39 +967,37 @@ pprCallishMachOp_for_C mop -- Not adding it for now (MO_Prefetch_Data _ ) -> unsupported - MO_I64_ToI -> dontReach64 - MO_I64_FromI -> dontReach64 - MO_W64_ToW -> dontReach64 - MO_W64_FromW -> dontReach64 - MO_x64_Neg -> dontReach64 - MO_x64_Add -> dontReach64 - MO_x64_Sub -> dontReach64 - MO_x64_Mul -> dontReach64 - MO_I64_Quot -> dontReach64 - MO_I64_Rem -> dontReach64 - MO_W64_Quot -> dontReach64 - MO_W64_Rem -> dontReach64 - MO_x64_And -> dontReach64 - MO_x64_Or -> dontReach64 - MO_x64_Xor -> dontReach64 - MO_x64_Not -> dontReach64 - MO_x64_Shl -> dontReach64 - MO_I64_Shr -> dontReach64 - MO_W64_Shr -> dontReach64 - MO_x64_Eq -> dontReach64 - MO_x64_Ne -> dontReach64 - MO_I64_Ge -> dontReach64 - MO_I64_Gt -> dontReach64 - MO_I64_Le -> dontReach64 - MO_I64_Lt -> dontReach64 - MO_W64_Ge -> dontReach64 - MO_W64_Gt -> dontReach64 - MO_W64_Le -> dontReach64 - MO_W64_Lt -> dontReach64 + MO_I64_ToI -> text "hs_int64ToInt" + MO_I64_FromI -> text "hs_intToInt64" + MO_W64_ToW -> text "hs_word64ToWord" + MO_W64_FromW -> text "hs_wordToWord64" + MO_x64_Neg -> text "hs_neg64" + MO_x64_Add -> text "hs_add64" + MO_x64_Sub -> text "hs_sub64" + MO_x64_Mul -> text "hs_mul64" + MO_I64_Quot -> text "hs_quotInt64" + MO_I64_Rem -> text "hs_remInt64" + MO_W64_Quot -> text "hs_quotWord64" + MO_W64_Rem -> text "hs_remWord64" + MO_x64_And -> text "hs_and64" + MO_x64_Or -> text "hs_or64" + MO_x64_Xor -> text "hs_xor64" + MO_x64_Not -> text "hs_not64" + MO_x64_Shl -> text "hs_uncheckedShiftL64" + MO_I64_Shr -> text "hs_uncheckedIShiftRA64" + MO_W64_Shr -> text "hs_uncheckedShiftRL64" + MO_x64_Eq -> text "hs_eq64" + MO_x64_Ne -> text "hs_ne64" + MO_I64_Ge -> text "hs_geInt64" + MO_I64_Gt -> text "hs_gtInt64" + MO_I64_Le -> text "hs_leInt64" + MO_I64_Lt -> text "hs_ltInt64" + MO_W64_Ge -> text "hs_geWord64" + MO_W64_Gt -> text "hs_gtWord64" + MO_W64_Le -> text "hs_leWord64" + MO_W64_Lt -> text "hs_ltWord64" where unsupported = panic ("pprCallishMachOp_for_C: " ++ show mop ++ " not supported!") - dontReach64 = panic ("pprCallishMachOp_for_C: " ++ show mop - ++ " should be not be encountered because the regular primop for this 64-bit operation is used instead.") -- --------------------------------------------------------------------- -- Useful #defines View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c4ea90c6b493eee6df1798c63a6031cc18ae6da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c4ea90c6b493eee6df1798c63a6031cc18ae6da You're receiving 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 Sep 9 14:49:57 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Sep 2022 10:49:57 -0400 Subject: [Git][ghc/ghc][wip/T21286] 20 commits: DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <631b5295dc335_869eb514dc6387f6@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 190f0d35 by Simon Peyton Jones at 2022-09-09T15:49:24+01: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 modules * 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: Metrics: compile_time/bytes allocated -------------------------------------------------------- LargeRecord(normal) -50.2% GOOD MultiLayerModulesTH_OneShot(normal) +2.0% T10547(normal) +1.3% T12545(normal) -3.9% T13056(optasm) -8.4% GOOD T14052(ghci) +1.9% T15164(normal) -3.5% GOOD T16577(normal) -2.6% GOOD T18223(normal) -33.4% GOOD T3064(normal) +1.5% T8095(normal) +1.3% T9630(normal) 32.9% GOOD WWRec(normal) -9.8% GOOD hie002(normal) +1.8% geo. mean -1.5% I diligently investigated all these big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlesslly specialising wrappers LargeRecord, T9630 I agonised a bit about some small regressions in nofib: # bytes allocated +===============================++===============+===========+ | real/lift || -1.55% | 0.0% | | real/maillist || +1.66% | 0.0% | | real/smallpt || +0.51% | 0.0% | | shootout/reverse-complement || +4.93% | 0.0% | | spectral/dom-lt || +1.80% | 0.0% | ToDo: re-do these figures Metric Decrease: LargeRecord T13056 T15164 T16577 T18223 T9630 WWRec - - - - - 6a1448c6 by Simon Peyton Jones at 2022-09-09T15:51:21+01: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. - - - - - cbadbc1a by Simon Peyton Jones at 2022-09-09T15:51:21+01: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. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.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/cc429374475d3dc9523a263ffda6018c2bdf92ca...cbadbc1a6815da0f2eddfb7c4291f7026a93ad3a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc429374475d3dc9523a263ffda6018c2bdf92ca...cbadbc1a6815da0f2eddfb7c4291f7026a93ad3a You're receiving 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 Sep 9 16:24:17 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Sep 2022 12:24:17 -0400 Subject: [Git][ghc/ghc][wip/T21470] 19 commits: DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <631b68b1f1d36_869eb5147865111f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - aac311af by Simon Peyton Jones at 2022-09-09T17:25:14+01: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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - ff2734fa by Simon Peyton Jones at 2022-09-09T17:25:14+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/HsToCore/Foreign/C.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ecab78ab29c619b91a31704f6b2f435fc9595ea...ff2734fa3eae10dc33ec77af632642a5ca9f6f3c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ecab78ab29c619b91a31704f6b2f435fc9595ea...ff2734fa3eae10dc33ec77af632642a5ca9f6f3c You're receiving 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 Sep 9 16:38:26 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Sep 2022 12:38:26 -0400 Subject: [Git][ghc/ghc][wip/T21470] 2 commits: Make the specialiser handle polymorphic specialisation Message-ID: <631b6c0264cd5_869eb515f465369f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: 7cc71521 by Simon Peyton Jones at 2022-09-09T17:39:48+01: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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - 651265b4 by Simon Peyton Jones at 2022-09-09T17:39:48+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 12 changed files: - 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/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Type.hs - testsuite/tests/linters/notes.stdout - testsuite/tests/numeric/should_compile/T19641.stderr - testsuite/tests/simplCore/should_compile/T8331.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -19,7 +19,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs + zapLambdaBndrs, scrutBinderSwap_maybe ) where import GHC.Prelude @@ -27,11 +27,12 @@ import GHC.Prelude import GHC.Core import GHC.Core.FVs import GHC.Core.Utils ( exprIsTrivial, isDefaultAlt, isExpandableApp, - stripTicksTopE, mkTicks ) + mkCastMCo, mkTicks ) import GHC.Core.Opt.Arity ( joinRhsArity, isOneShotBndr ) import GHC.Core.Coercion +import GHC.Core.Predicate ( isDictId ) import GHC.Core.Type -import GHC.Core.TyCo.FVs( tyCoVarsOfMCo ) +import GHC.Core.TyCo.FVs ( tyCoVarsOfMCo ) import GHC.Data.Maybe( isJust, orElse ) import GHC.Data.Graph.Directed ( SCC(..), Node(..) @@ -2462,8 +2463,8 @@ data OccEnv -- See Note [The binder-swap substitution] -- If x :-> (y, co) is in the env, - -- then please replace x by (y |> sym mco) - -- Invariant of course: idType x = exprType (y |> sym mco) + -- then please replace x by (y |> mco) + -- Invariant of course: idType x = exprType (y |> mco) , occ_bs_env :: !(VarEnv (OutId, MCoercion)) , occ_bs_rng :: !VarSet -- Vars free in the range of occ_bs_env -- Domain is Global and Local Ids @@ -2669,7 +2670,7 @@ The binder-swap is implemented by the occ_bs_env field of OccEnv. There are two main pieces: * Given case x |> co of b { alts } - we add [x :-> (b, co)] to the occ_bs_env environment; this is + we add [x :-> (b, sym co)] to the occ_bs_env environment; this is done by addBndrSwap. * Then, at an occurrence of a variable, we look up in the occ_bs_env @@ -2737,30 +2738,8 @@ Some tricky corners: (BS5) We have to apply the occ_bs_env substitution uniformly, including to (local) rules and unfoldings. -Historical note ---------------- -We used to do the binder-swap transformation by introducing -a proxy let-binding, thus; - - case x of b { pi -> ri } - ==> - case x of b { pi -> let x = b in ri } - -But that had two problems: - -1. If 'x' is an imported GlobalId, we'd end up with a GlobalId - on the LHS of a let-binding which isn't allowed. We worked - around this for a while by "localising" x, but it turned - out to be very painful #16296, - -2. In CorePrep we use the occurrence analyser to do dead-code - elimination (see Note [Dead code in CorePrep]). But that - occasionally led to an unlifted let-binding - case x of b { DEFAULT -> let x::Int# = b in ... } - which disobeys one of CorePrep's output invariants (no unlifted - let-bindings) -- see #5433. - -Doing a substitution (via occ_bs_env) is much better. +(BS6) We must be very careful with dictionaries. + See Note [Care with binder-swap on dictionaries] Note [Case of cast] ~~~~~~~~~~~~~~~~~~~ @@ -2770,6 +2749,54 @@ We'd like to eliminate the inner case. That is the motivation for equation (2) in Note [Binder swap]. When we get to the inner case, we inline x, cancel the casts, and away we go. +Note [Care with binder-swap on dictionaries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This Note explains why we need isDictId in scrutBinderSwap_maybe. +Consider this tricky example (#21229, #21470): + + class Sing (b :: Bool) where sing :: Bool + instance Sing 'True where sing = True + instance Sing 'False where sing = False + + f :: forall a. Sing a => blah + + h = \ @(a :: Bool) ($dSing :: Sing a) + let the_co = Main.N:Sing[0] :: Sing a ~R# Bool + case ($dSing |> the_co) of wild + True -> f @'True (True |> sym the_co) + False -> f @a dSing + +Now do a binder-swap on the case-expression: + + h = \ @(a :: Bool) ($dSing :: Sing a) + let the_co = Main.N:Sing[0] :: Sing a ~R# Bool + case ($dSing |> the_co) of wild + True -> f @'True (True |> sym the_co) + False -> f @a (wild |> sym the_co) + +And now substitute `False` for `wild` (since wild=False in the False branch): + + h = \ @(a :: Bool) ($dSing :: Sing a) + let the_co = Main.N:Sing[0] :: Sing a ~R# Bool + case ($dSing |> the_co) of wild + True -> f @'True (True |> sym the_co) + False -> f @a (False |> sym the_co) + +And now we have a problem. The specialiser will specialise (f @a d)a (for all +vtypes a and dictionaries d!!) with the dictionary (False |> sym the_co), using +Note [Specialising polymorphic dictionaries] in GHC.Core.Opt.Specialise. + +The real problem is the binder-swap. It swaps a dictionary variable $dSing +(of kind Constraint) for a term variable wild (of kind Type). And that is +dangerous: a dictionary is a /singleton/ type whereas a general term variable is +not. In this particular example, Bool is most certainly not a singleton type! + +Conclusion: + for a /dictionary variable/ do not perform + the clever cast version of the binder-swap + +Hence the subtle isDictId in scrutBinderSwap_maybe. + Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From the original @@ -2784,8 +2811,83 @@ binding x = cb. See #5028. NB: the OccInfo on /occurrences/ really doesn't matter much; the simplifier doesn't use it. So this is only to satisfy the perhaps-over-picky Lint. +-} + +addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv +-- See Note [The binder-swap substitution] +addBndrSwap scrut case_bndr + env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) + | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + , scrut_var /= case_bndr + -- Consider: case x of x { ... } + -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop + = env { occ_bs_env = extendVarEnv swap_env scrut_var (case_bndr', mco) + , occ_bs_rng = rng_vars `extendVarSet` case_bndr' + `unionVarSet` tyCoVarsOfMCo mco } + + | otherwise + = env + where + case_bndr' = zapIdOccInfo case_bndr + -- See Note [Zap case binders in proxy bindings] + +scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) +-- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- v = e |> mco +-- See Note [Case of cast] +-- See Note [Care with binder-swap on dictionaries] +-- +-- We use this same function in SpecConstr, and Simplify.Iteration, +-- when something binder-swap-like is happening +scrutBinderSwap_maybe (Var v) = Just (v, MRefl) +scrutBinderSwap_maybe (Cast (Var v) co) + | not (isDictId v) = Just (v, MCo (mkSymCo co)) + -- Cast: see Note [Case of cast] + -- isDictId: see Note [Care with binder-swap on dictionaries] +scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks +scrutBinderSwap_maybe _ = Nothing + +lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) +-- See Note [The binder-swap substitution] +-- Returns an expression of the same type as Id +lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr + = case lookupVarEnv bs_env bndr of { + Nothing -> (Var bndr, bndr) ; + Just (bndr1, mco) -> + + -- Why do we iterate here? + -- See (BS2) in Note [The binder-swap substitution] + case lookupBndrSwap env bndr1 of + (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } + + +{- Historical note [Proxy let-bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We used to do the binder-swap transformation by introducing +a proxy let-binding, thus; + + case x of b { pi -> ri } + ==> + case x of b { pi -> let x = b in ri } + +But that had two problems: + +1. If 'x' is an imported GlobalId, we'd end up with a GlobalId + on the LHS of a let-binding which isn't allowed. We worked + around this for a while by "localising" x, but it turned + out to be very painful #16296, + +2. In CorePrep we use the occurrence analyser to do dead-code + elimination (see Note [Dead code in CorePrep]). But that + occasionally led to an unlifted let-binding + case x of b { DEFAULT -> let x::Int# = b in ... } + which disobeys one of CorePrep's output invariants (no unlifted + let-bindings) -- see #5433. + +Doing a substitution (via occ_bs_env) is much better. + Historical Note [no-case-of-case] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We *used* to suppress the binder-swap in case expressions when -fno-case-of-case is on. Old remarks: "This happens in the first simplifier pass, @@ -2844,53 +2946,8 @@ binder-swap in OccAnal: It's fixed by doing the binder-swap in OccAnal because we can do the binder-swap unconditionally and still get occurrence analysis information right. --} -addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv --- See Note [The binder-swap substitution] -addBndrSwap scrut case_bndr - env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- get_scrut_var (stripTicksTopE (const True) scrut) - , scrut_var /= case_bndr - -- Consider: case x of x { ... } - -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop - = env { occ_bs_env = extendVarEnv swap_env scrut_var (case_bndr', mco) - , occ_bs_rng = rng_vars `extendVarSet` case_bndr' - `unionVarSet` tyCoVarsOfMCo mco } - - | otherwise - = env - where - get_scrut_var :: OutExpr -> Maybe (OutVar, MCoercion) - get_scrut_var (Var v) = Just (v, MRefl) - get_scrut_var (Cast (Var v) co) = Just (v, MCo co) -- See Note [Case of cast] - get_scrut_var _ = Nothing - - case_bndr' = zapIdOccInfo case_bndr - -- See Note [Zap case binders in proxy bindings] -lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) --- See Note [The binder-swap substitution] --- Returns an expression of the same type as Id -lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr - = case lookupVarEnv bs_env bndr of { - Nothing -> (Var bndr, bndr) ; - Just (bndr1, mco) -> - - -- Why do we iterate here? - -- See (BS2) in Note [The binder-swap substitution] - case lookupBndrSwap env bndr1 of - (fun, fun_id) -> (add_cast fun mco, fun_id) } - - where - add_cast fun MRefl = fun - add_cast fun (MCo co) = Cast fun (mkSymCo co) - -- We must switch that 'co' to 'sym co'; - -- see the comment with occ_bs_env - -- No need to test for isReflCo, because 'co' came from - -- a (Cast e co) and hence is unlikely to be Refl - -{- ************************************************************************ * * \subsection[OccurAnal-types]{OccEnv} ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -51,17 +51,6 @@ The simplifier tries to get rid of occurrences of x, in favour of wild, in the hope that there will only be one remaining occurrence of x, namely the scrutinee of the case, and we can inline it. - - This can only work if @wild@ is an unrestricted binder. Indeed, even with the - extended typing rule (in the linter) for case expressions, if - case x of wild % 1 { p -> e} - is well-typed, then - case x of wild % 1 { p -> e[wild\x] } - is only well-typed if @e[wild\x] = e@ (that is, if @wild@ is not used in @e@ - at all). In which case, it is, of course, pointless to do the substitution - anyway. So for a linear binder (and really anything which isn't unrestricted), - doing this substitution would either produce ill-typed terms or be the - identity. -} module GHC.Core.Opt.SetLevels ( @@ -1602,7 +1591,9 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - | Many <- varMult case_bndr + -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- get a bit more floating. But we didn't in the past and it's + -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var , le_env = add_id id_env (case_bndr, scrut_var) } extendCaseBndrEnv env _ _ = env ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -71,7 +71,8 @@ import GHC.Core.Make ( mkWildValBinder, mkCoreLet ) import GHC.Builtin.Types import GHC.Core.TyCo.Rep ( TyCoBinder(..) ) import qualified GHC.Core.Type as Type -import GHC.Core.Type hiding ( substTy, substTyVar, substTyVarBndr, extendTvSubst, extendCvSubst ) +import GHC.Core.Type hiding ( substTy, substTyVar, substTyVarBndr, substCo + , extendTvSubst, extendCvSubst ) import qualified GHC.Core.Coercion as Coercion import GHC.Core.Coercion hiding ( substCo, substCoVar, substCoVarBndr ) import GHC.Platform ( Platform ) ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -22,7 +22,7 @@ import GHC.Core.Opt.Simplify.Monad import GHC.Core.Type hiding ( substTy, substTyVar, extendTvSubst, extendCvSubst ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -3240,19 +3240,21 @@ zapIdOccInfoAndSetEvald str v = -- see Note [Case alternative occ info] addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplM SimplEnv -addAltUnfoldings env scrut case_bndr con_app +addAltUnfoldings env mb_scrut case_bndr con_app = do { let con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Many <- idMult case_bndr = case scrut of - Just (Var v) -> addBinderUnfolding env1 v con_app_unf - Just (Cast (Var v) co) -> addBinderUnfolding env1 v $ - mk_simple_unf (Cast con_app (mkSymCo co)) - _ -> env1 + env2 | Just scrut <- mb_scrut + , Just (v,mco) <- scrutBinderSwap_maybe scrut + = addBinderUnfolding env1 v $ + if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf + then con_app_unf -- twice in the common case + else mk_simple_unf (mkCastMCo con_app mco) + | otherwise = env1 - ; traceSmpl "addAltUnf" (vcat [ppr case_bndr <+> ppr scrut, ppr con_app]) + ; traceSmpl "addAltUnf" (vcat [ppr case_bndr <+> ppr mb_scrut, ppr con_app]) ; return env2 } where -- Force the opts, so that the whole SimplEnv isn't retained @@ -3315,9 +3317,6 @@ it's also good for case-elimination -- suppose that 'f' was inlined and did multi-level case analysis, then we'd solve it in one simplifier sweep instead of two. -Exactly the same issue arises in GHC.Core.Opt.SpecConstr; -see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr - HOWEVER, given case x of y { Just a -> r1; Nothing -> r2 } we do not want to add the unfolding x -> y to 'x', which might seem cool, @@ -3328,8 +3327,11 @@ piece of information. So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. -Since this transformation is tantamount to a binder swap, the same caveat as in -Note [Suppressing binder-swaps on linear case] in OccurAnal apply. +Since this transformation is tantamount to a binder swap, we use +GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. + +Exactly the same issue arises in GHC.Core.Opt.SpecConstr; +see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr ************************************************************************ ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Core.Unfold import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils +import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1066,8 +1067,8 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Var v <- stripTicksTopE (const True) scrut - = extendValEnv env v cval + env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval | otherwise = env1 @@ -1157,6 +1158,10 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. +It's very like the binder-swap story, so we use scrutBinderSwap_maybe +to identify suitable scrutinees -- but only if there is no cast +(isReflMCo) because that's all that the ValueEnv allows. + Note [Avoiding exponential blowup] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The sc_count field of the ScEnv says how many times we are prepared to ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -15,9 +15,7 @@ import GHC.Driver.Config import GHC.Driver.Config.Diagnostic import GHC.Driver.Config.Core.Rules ( initRuleOpts ) -import GHC.Tc.Utils.TcType hiding( substTy ) - -import GHC.Core.Type hiding( substTy, extendTvSubstList, zapSubst ) +import GHC.Core.Type hiding( substTy, substCo, extendTvSubstList, zapSubst ) import GHC.Core.Multiplicity import GHC.Core.Predicate import GHC.Core.Coercion( Coercion ) @@ -25,12 +23,15 @@ import GHC.Core.Opt.Monad import qualified GHC.Core.Subst as Core import GHC.Core.Unfold.Make import GHC.Core +import GHC.Core.Make ( mkLitRubbish ) +import GHC.Core.Unify ( tcMatchTy ) import GHC.Core.Rules import GHC.Core.Utils ( exprIsTrivial , mkCast, exprType , stripTicksTop ) import GHC.Core.FVs -import GHC.Core.TyCo.Rep (TyCoBinder (..)) +import GHC.Core.TyCo.Rep ( TyCoBinder (..) ) +import GHC.Core.TyCo.FVs ( tyCoVarsOfTypeList ) import GHC.Core.Opt.Arity( collectBindersPushingCo ) import GHC.Builtin.Types ( unboxedUnitTy ) @@ -529,6 +530,50 @@ like f :: Eq [(a,b)] => ... +Note [Specialisation and overlapping instances] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Here is at tricky case (see a comment in MR !8916): + + module A where + + class C a where + meth :: a -> String + + instance {-# OVERLAPPABLE #-} C (Maybe a) where + meth _ = "Maybe" + + {-# SPECIALISE f :: Maybe a -> Bool -> String #-} + f :: C a => a -> Bool -> String + f a True = f a False + f a _ = meth a + + module B where + import A + + instance C (Maybe Int) where + meth _ = "Int" + + main = putStrLn $ f (Just 42 :: Maybe Int) True + +Running main without optimisations yields "Int", the correct answer. +Activating optimisations yields "Maybe" due to a rewrite rule in module +A generated by the SPECIALISE pragma: + + RULE "USPEC f" forall a (d :: C a). f @a d = $sf + +In B we get the call (f @(Maybe Int) (d :: C (Maybe Int))), and +that rewrites to $sf, but that isn't really right. + +Overlapping instances mean that `C (Maybe Int)` is not a singleton +type: there two distinct dictionaries that have this type. And that +spells trouble for specialistion, which really asssumes singleton +types. + +For now, we just accept this problem, but it may bite us one day. +One solution would be to decline to expose any specialisation rules +to an importing module -- but that seems a bit drastic. + + ************************************************************************ * * \subsubsection{The new specialiser} @@ -770,6 +815,10 @@ spec_import top_env callers rb dict_binds cis@(CIS fn _) canSpecImport :: DynFlags -> Id -> Maybe CoreExpr -- See Note [Specialise imported INLINABLE things] canSpecImport dflags fn + | isDataConWrapId fn + = Nothing -- Don't specialise data-con wrappers, even if they + -- have dict args; there is no benefit. + | CoreUnfolding { uf_src = src, uf_tmpl = rhs } <- unf , isStableSource src = Just rhs -- By default, specialise only imported things that have a stable @@ -1493,12 +1542,12 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs | otherwise -- No calls or RHS doesn't fit our preconceptions = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me) - "Missed specialisation opportunity" (ppr fn $$ _trace_doc) $ + "Missed specialisation opportunity for" (ppr fn $$ trace_doc) $ -- Note [Specialisation shape] -- pprTrace "specCalls: none" (ppr fn <+> ppr calls_for_me) $ return ([], [], emptyUDs) where - _trace_doc = sep [ ppr rhs_bndrs, ppr (idInlineActivation fn) ] + trace_doc = sep [ ppr rhs_bndrs, ppr (idInlineActivation fn) ] fn_type = idType fn fn_arity = idArity fn @@ -1562,8 +1611,16 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs else do { -- Run the specialiser on the specialised RHS -- The "1" suffix is before we maybe add the void arg - ; (spec_rhs1, rhs_uds) <- specLam rhs_env2 (spec_bndrs1 ++ leftover_bndrs) rhs_body - ; let spec_fn_ty1 = exprType spec_rhs1 + ; (rhs_body', rhs_uds) <- specExpr rhs_env2 rhs_body + -- Add the { d1' = dx1; d2' = dx2 } usage stuff + -- to the rhs_uds; see Note [Specialising Calls] + ; let rhs_uds_w_dx = foldr consDictBind rhs_uds dx_binds + spec_rhs_bndrs = spec_bndrs1 ++ leftover_bndrs + (spec_uds, dumped_dbs) = dumpUDs spec_rhs_bndrs rhs_uds_w_dx + spec_rhs1 = mkLams spec_rhs_bndrs $ + wrapDictBindsE dumped_dbs rhs_body' + + spec_fn_ty1 = exprType spec_rhs1 -- Maybe add a void arg to the specialised function, -- to avoid unlifted bindings @@ -1597,10 +1654,6 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs herald fn rule_bndrs rule_lhs_args (mkVarApps (Var spec_fn) spec_bndrs) - -- Add the { d1' = dx1; d2' = dx2 } usage stuff - -- See Note [Specialising Calls] - spec_uds = foldr consDictBind rhs_uds dx_binds - simpl_opts = initSimpleOpts dflags -------------------------------------- @@ -1615,9 +1668,12 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs = (inl_prag { inl_inline = NoUserInlinePrag }, noUnfolding) | otherwise - = (inl_prag, specUnfolding simpl_opts spec_bndrs (`mkApps` spec_args) + = (inl_prag, specUnfolding simpl_opts spec_bndrs spec_unf_body rule_lhs_args fn_unf) + spec_unf_body body = wrapDictBindsE dumped_dbs $ + body `mkApps` spec_args + -------------------------------------- -- Adding arity information just propagates it a bit faster -- See Note [Arity decrease] in GHC.Core.Opt.Simplify @@ -1786,11 +1842,23 @@ in the specialisation: {-# RULE "SPEC f @Int" forall x. f @Int x $dShow = $sf #-} This doesn’t save us much, since the arg would be removed later by -worker/wrapper, anyway, but it’s easy to do. Note, however, that we -only drop dead arguments if: +worker/wrapper, anyway, but it’s easy to do. + +Wrinkles - 1. We don’t specialise on them. - 2. They come before an argument we do specialise on. +* Note that we only drop dead arguments if: + 1. We don’t specialise on them. + 2. They come before an argument we do specialise on. + Doing the latter would require eta-expanding the RULE, which could + make it match less often, so it’s not worth it. Doing the former could + be more useful --- it would stop us from generating pointless + specialisations --- but it’s more involved to implement and unclear if + it actually provides much benefit in practice. + +* If the function has a stable unfolding, specHeader has to come up with + arguments to pass to that stable unfolding, when building the stable + unfolding of the specialised function: this is the last field in specHeader's + big result tuple. The right thing to do is to produce a LitRubbish; it should rapidly disappear. Rather like GHC.Core.Opt.WorkWrap.Utils.mk_absent_let. @@ -2268,11 +2336,11 @@ instance Outputable SpecArg where ppr (SpecDict d) = text "SpecDict" <+> ppr d ppr UnspecArg = text "UnspecArg" -specArgFreeVars :: SpecArg -> VarSet -specArgFreeVars (SpecType ty) = tyCoVarsOfType ty -specArgFreeVars (SpecDict dx) = exprFreeVars dx -specArgFreeVars UnspecType = emptyVarSet -specArgFreeVars UnspecArg = emptyVarSet +specArgFreeIds :: SpecArg -> IdSet +specArgFreeIds (SpecType {}) = emptyVarSet +specArgFreeIds (SpecDict dx) = exprFreeIds dx +specArgFreeIds UnspecType = emptyVarSet +specArgFreeIds UnspecArg = emptyVarSet isSpecDict :: SpecArg -> Bool isSpecDict (SpecDict {}) = True @@ -2342,24 +2410,30 @@ specHeader , [OutBndr] -- Binders for $sf , [DictBind] -- Auxiliary dictionary bindings , [OutExpr] -- Specialised arguments for unfolding - -- Same length as "args for LHS of rule" + -- Same length as "Args for LHS of rule" ) -- We want to specialise on type 'T1', and so we must construct a substitution -- 'a->T1', as well as a LHS argument for the resulting RULE and unfolding -- details. -specHeader env (bndr : bndrs) (SpecType t : args) - = do { let env' = extendTvSubstList env [(bndr, t)] - ; (useful, env'', leftover_bndrs, rule_bs, rule_es, bs', dx, spec_args) - <- specHeader env' bndrs args +specHeader env (bndr : bndrs) (SpecType ty : args) + = do { let in_scope = Core.getSubstInScope (se_subst env) + qvars = scopedSort $ + filterOut (`elemInScopeSet` in_scope) $ + tyCoVarsOfTypeList ty + (env1, qvars') = substBndrs env qvars + ty' = substTy env1 ty + env2 = extendTvSubstList env1 [(bndr, ty')] + ; (useful, env3, leftover_bndrs, rule_bs, rule_es, bs', dx, spec_args) + <- specHeader env2 bndrs args ; pure ( useful - , env'' + , env3 , leftover_bndrs - , rule_bs - , Type t : rule_es - , bs' + , qvars' ++ rule_bs + , Type ty' : rule_es + , qvars' ++ bs' , dx - , Type t : spec_args + , Type ty' : spec_args ) } @@ -2415,16 +2489,28 @@ specHeader env (bndr : bndrs) (UnspecArg : args) let (env', bndr') = substBndr env (zapIdOccInfo bndr) ; (useful, env'', leftover_bndrs, rule_bs, rule_es, bs', dx, spec_args) <- specHeader env' bndrs args + + ; let bndr_ty = idType bndr' + + -- See Note [Drop dead args from specialisations] + -- C.f. GHC.Core.Opt.WorkWrap.Utils.mk_absent_let + (mb_spec_bndr, spec_arg) + | isDeadBinder bndr + , Just lit_expr <- mkLitRubbish bndr_ty + = (Nothing, lit_expr) + | otherwise + = (Just bndr', varToCoreExpr bndr') + ; pure ( useful , env'' , leftover_bndrs , bndr' : rule_bs , varToCoreExpr bndr' : rule_es - , if isDeadBinder bndr - then bs' -- see Note [Drop dead args from specialisations] - else bndr' : bs' + , case mb_spec_bndr of + Just b' -> b' : bs' + Nothing -> bs' , dx - , varToCoreExpr bndr' : spec_args + , spec_arg : spec_args ) } @@ -2550,6 +2636,88 @@ successfully specialise 'f'. So the DictBinds in (ud_binds :: OrdList DictBind) may contain non-dictionary bindings too. + +Note [Specialising polymorphic dictionaries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + class M a where { foo :: a -> Int } + + instance M (ST s) where ... + -- dMST :: forall s. M (ST s) + + wimwam :: forall a. M a => a -> Int + wimwam = /\a \(d::M a). body + + f :: ST s -> Int + f = /\s \(x::ST s). wimwam @(ST s) (dMST @s) dx + 1 + +We'd like to specialise wimwam at (ST s), thus + $swimwam :: forall s. ST s -> Int + $swimwam = /\s. body[ST s/a, (dMST @s)/d] + + RULE forall s (d :: M (ST s)). + wimwam @(ST s) d = $swimwam @s + +Here are the moving parts: + +* We must /not/ dump the CallInfo + CIS wimwam (CI { ci_key = [@(ST s), dMST @s] + , ci_fvs = {dMST} }) + when we come to the /\s. Instead, we simply let it continue to float + upwards. Hence ci_fvs is an IdSet, listing the /Ids/ that + are free in the call, but not the /TyVars/. Hence using specArgFreeIds + in singleCall. + + NB to be fully kosher we should explicitly quantifying the CallInfo + over 's', but we don't bother. This would matter if there was an + enclosing binding of the same 's', which I don't expect to happen. + +* Whe we come to specialise the call, we must remember to quantify + over 's'. That is done in the SpecType case of specHeader, where + we add 's' (called qvars) to the binders of the RULE and the specialised + function. + +* If we have f :: forall m. Monoid m => blah, and two calls + (f @(Endo b) (d :: Monoid (Endo b)) + (f @(Endo (c->c)) (d :: Monoid (Endo (c->c))) + we want to generate a specialisation only for the first. The second + is just a substitution instance of the first, with no greater specialisation. + Hence the call to `remove_dups` in `filterCalls`. + +All this arose in #13873, in the unexpected form that a SPECIALISE +pragma made the program slower! The reason was that the specialised +function $sinsertWith arising from the pragma looked rather like `f` +above, and failed to specialise a call in its body like wimwam. +Without the pragma, the original call to `insertWith` was completely +monomorpic, and specialised in one go. + +Wrinkles. + +* With -XOverlappingInstances you might worry about this: + class C a where ... + instance C (Maybe Int) where ... -- $df1 :: C (Maybe Int) + instance C (Maybe a) where ... -- $df2 :: forall a. C (Maybe a) + + f :: C a => blah + f = rhs + + g = /\a. ...(f @(Maybe a) ($df2 a))... + h = ...f @(Maybe Int) $df1 + + There are two calls to f, but with different evidence. This patch will + combine them into one. But it's OK: this code will never arise unless you + use -XIncoherentInstances. Even with -XOverlappingInstances, GHC tries hard + to keep dictionaries as singleton types. But that goes out of the window + with -XIncoherentInstances -- and that is true even with ordianry type-class + specialisation (at least if any inlining has taken place). + + GHC makes very few guarantees when you use -XIncoherentInstances, and its + not worth crippling the normal case for the incoherent corner. (The best + thing might be to switch off specialisation altogether if incoherence is + involved... but incoherence is a property of an instance, not a class, so + it's a hard test to make.) + + But see Note [Specialisation and overlapping instances]. -} instance Outputable DictBind where @@ -2588,8 +2756,9 @@ data CallInfoSet = CIS Id (Bag CallInfo) data CallInfo = CI { ci_key :: [SpecArg] -- All arguments , ci_fvs :: IdSet -- Free Ids of the ci_key call - -- _not_ including the main id itself, of course + -- /not/ including the main id itself, of course -- NB: excluding tyvars: + -- See Note [Specialising polymorphic dictionaries] } type DictExpr = CoreExpr @@ -2638,7 +2807,7 @@ singleCall id args unitBag (CI { ci_key = args -- used to be tys , ci_fvs = call_fvs }) } where - call_fvs = foldr (unionVarSet . specArgFreeVars) emptyVarSet args + call_fvs = foldr (unionVarSet . specArgFreeIds) emptyVarSet args -- The type args (tys) are guaranteed to be part of the dictionary -- types, because they are just the constrained types, -- and the dictionary is therefore sure to be bound @@ -2968,15 +3137,15 @@ callsForMe fn uds at MkUD { ud_binds = orig_dbs, ud_calls = orig_calls } ---------------------- filterCalls :: CallInfoSet -> FloatedDictBinds -> [CallInfo] --- Remove dominated calls +-- Remove dominated calls (Note [Specialising polymorphic dictionaries]) -- and loopy DFuns (Note [Avoiding loops (DFuns)]) filterCalls (CIS fn call_bag) (FDB { fdb_binds = dbs }) | isDFunId fn -- Note [Avoiding loops (DFuns)] applies only to DFuns - = filter ok_call unfiltered_calls + = filter ok_call de_dupd_calls | otherwise -- Do not apply it to non-DFuns - = unfiltered_calls -- See Note [Avoiding loops (non-DFuns)] + = de_dupd_calls -- See Note [Avoiding loops (non-DFuns)] where - unfiltered_calls = bagToList call_bag + de_dupd_calls = remove_dups call_bag dump_set = foldl' go (unitVarSet fn) dbs -- This dump-set could also be computed by splitDictBinds @@ -2990,6 +3159,29 @@ filterCalls (CIS fn call_bag) (FDB { fdb_binds = dbs }) ok_call (CI { ci_fvs = fvs }) = fvs `disjointVarSet` dump_set +remove_dups :: Bag CallInfo -> [CallInfo] +remove_dups calls = foldr add [] calls + where + add :: CallInfo -> [CallInfo] -> [CallInfo] + add ci [] = [ci] + add ci1 (ci2:cis) | ci2 `beats_or_same` ci1 = ci2:cis + | ci1 `beats_or_same` ci2 = ci1:cis + | otherwise = ci2 : add ci1 cis + +beats_or_same :: CallInfo -> CallInfo -> Bool +beats_or_same (CI { ci_key = args1 }) (CI { ci_key = args2 }) + = go args1 args2 + where + go [] _ = True + go (arg1:args1) (arg2:args2) = go_arg arg1 arg2 && go args1 args2 + go (_:_) [] = False + + go_arg (SpecType ty1) (SpecType ty2) = isJust (tcMatchTy ty1 ty2) + go_arg UnspecType UnspecType = True + go_arg (SpecDict {}) (SpecDict {}) = True + go_arg UnspecArg UnspecArg = True + go_arg _ _ = False + ---------------------- splitDictBinds :: FloatedDictBinds -> IdSet -> (FloatedDictBinds, OrdList DictBind, IdSet) -- splitDictBinds dbs bndrs returns @@ -3020,15 +3212,18 @@ splitDictBinds (FDB { fdb_binds = dbs, fdb_bndrs = bs }) bndr_set ---------------------- deleteCallsMentioning :: VarSet -> CallDetails -> CallDetails --- Remove calls *mentioning* bs in any way -deleteCallsMentioning bs calls +-- Remove calls mentioning any Id in bndrs +-- NB: The call is allowed to mention TyVars in bndrs +-- Note [Specialising polymorphic dictionaries] +-- ci_fvs are just the free /Ids/ +deleteCallsMentioning bndrs calls = mapDVarEnv (ciSetFilter keep_call) calls where - keep_call (CI { ci_fvs = fvs }) = fvs `disjointVarSet` bs + keep_call (CI { ci_fvs = fvs }) = fvs `disjointVarSet` bndrs deleteCallsFor :: [Id] -> CallDetails -> CallDetails --- Remove calls *for* bs -deleteCallsFor bs calls = delDVarEnvList calls bs +-- Remove calls *for* bndrs +deleteCallsFor bndrs calls = delDVarEnvList calls bndrs {- ************************************************************************ ===================================== compiler/GHC/Core/Subst.hs ===================================== @@ -26,7 +26,8 @@ module GHC.Core.Subst ( extendIdSubstWithClone, extendSubst, extendSubstList, extendSubstWithVar, extendSubstInScope, extendSubstInScopeList, extendSubstInScopeSet, - isInScope, setInScope, extendTvSubst, extendCvSubst, + isInScope, setInScope, getSubstInScope, + extendTvSubst, extendCvSubst, delBndr, delBndrs, zapSubst, -- ** Substituting and cloning binders @@ -41,7 +42,6 @@ import GHC.Core import GHC.Core.FVs import GHC.Core.Seq import GHC.Core.Utils -import GHC.Core.TyCo.Subst ( substCo ) -- We are defining local versions import GHC.Core.Type hiding ( substTy ) ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -218,7 +218,7 @@ module GHC.Core.Type ( substTyAddInScope, substTyUnchecked, substTysUnchecked, substScaledTyUnchecked, substScaledTysUnchecked, substThetaUnchecked, substTyWithUnchecked, - substCoUnchecked, substCoWithUnchecked, + substCo, substCoUnchecked, substCoWithUnchecked, substTyVarBndr, substTyVarBndrs, substTyVar, substTyVars, substVarBndr, substVarBndrs, substTyCoBndr, ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -2,7 +2,6 @@ ref compiler/GHC/Core/Coercion/Axiom.hs:458:2: Note [RoughMap and rm_empt ref compiler/GHC/Core/Opt/OccurAnal.hs:857:15: Note [Loop breaking] ref compiler/GHC/Core/Opt/SetLevels.hs:1598:30: Note [Top level scope] ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2666:13: Note [Case binder next] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:3288:0: Note [Suppressing binder-swaps on linear case] ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:3816:8: Note [Lambda-bound unfoldings] ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1282:37: Note [Gentle mode] ref compiler/GHC/Core/Opt/Specialise.hs:1611:28: Note [Arity decrease] ===================================== testsuite/tests/numeric/should_compile/T19641.stderr ===================================== @@ -3,30 +3,30 @@ Result size of Tidy Core = {terms: 22, types: 20, coercions: 0, joins: 0/0} -integer_to_int +natural_to_word = \ eta -> case eta of { - IS ipv -> Just (I# ipv); - IP x1 -> Nothing; - IN ds -> Nothing + NS x1 -> Just (W# x1); + NB ds -> Nothing } -natural_to_word +integer_to_int = \ eta -> case eta of { - NS x1 -> Just (W# x1); - NB ds -> Nothing + IS ipv -> Just (I# ipv); + IP x1 -> Nothing; + IN ds -> Nothing } ------ Local rules for imported ids -------- -"SPEC/Test toIntegralSized @Natural @Word" - forall $dIntegral $dIntegral1 $dBits $dBits1. - toIntegralSized $dIntegral $dIntegral1 $dBits $dBits1 - = natural_to_word "SPEC/Test toIntegralSized @Integer @Int" forall $dIntegral $dIntegral1 $dBits $dBits1. toIntegralSized $dIntegral $dIntegral1 $dBits $dBits1 = integer_to_int +"SPEC/Test toIntegralSized @Natural @Word" + forall $dIntegral $dIntegral1 $dBits $dBits1. + toIntegralSized $dIntegral $dIntegral1 $dBits $dBits1 + = natural_to_word ===================================== testsuite/tests/simplCore/should_compile/T8331.stderr ===================================== @@ -1,5 +1,60 @@ ==================== Tidy Core rules ==================== +"SPEC $c*> @(ST s) @_" + forall (@s) (@r) ($dApplicative :: Applicative (ST s)). + $fApplicativeReaderT_$c*> @(ST s) @r $dApplicative + = ($fApplicativeReaderT3 @s @r) + `cast` (forall (a :: <*>_N) (b :: <*>_N). + _R + %<'Many>_N ->_R _R + %<'Many>_N ->_R _R %<'Many>_N ->_R Sym (N:ST[0] _N _R) + ; Sym (N:ReaderT[0] <*>_N _R _R _N) + :: Coercible + (forall {a} {b}. + ReaderT r (ST s) a -> ReaderT r (ST s) b -> r -> STRep s b) + (forall {a} {b}. + ReaderT r (ST s) a -> ReaderT r (ST s) b -> ReaderT r (ST s) b)) +"SPEC $c>> @(ST s) @_" + forall (@s) (@r) ($dMonad :: Monad (ST s)). + $fMonadReaderT1 @(ST s) @r $dMonad + = $fMonadAbstractIOSTReaderT_$s$c>> @s @r +"SPEC $cliftA2 @(ST s) @_" + forall (@s) (@r) ($dApplicative :: Applicative (ST s)). + $fApplicativeReaderT_$cliftA2 @(ST s) @r $dApplicative + = ($fApplicativeReaderT1 @s @r) + `cast` (forall (a :: <*>_N) (b :: <*>_N) (c :: <*>_N). + b -> c>_R + %<'Many>_N ->_R _R + %<'Many>_N ->_R _R + %<'Many>_N ->_R _R %<'Many>_N ->_R Sym (N:ST[0] _N _R) + ; Sym (N:ReaderT[0] <*>_N _R _R _N) + :: Coercible + (forall {a} {b} {c}. + (a -> b -> c) + -> ReaderT r (ST s) a -> ReaderT r (ST s) b -> r -> STRep s c) + (forall {a} {b} {c}. + (a -> b -> c) + -> ReaderT r (ST s) a -> ReaderT r (ST s) b -> ReaderT r (ST s) c)) +"SPEC $cp1Applicative @(ST s) @_" + forall (@s) (@r) ($dApplicative :: Applicative (ST s)). + $fApplicativeReaderT_$cp1Applicative @(ST s) @r $dApplicative + = $fApplicativeReaderT_$s$fFunctorReaderT @s @r +"SPEC $cp1Monad @(ST s) @_" + forall (@s) (@r) ($dMonad :: Monad (ST s)). + $fMonadReaderT_$cp1Monad @(ST s) @r $dMonad + = $fApplicativeReaderT_$s$fApplicativeReaderT @s @r +"SPEC $fApplicativeReaderT @(ST s) @_" + forall (@s) (@r) ($dApplicative :: Applicative (ST s)). + $fApplicativeReaderT @(ST s) @r $dApplicative + = $fApplicativeReaderT_$s$fApplicativeReaderT @s @r +"SPEC $fFunctorReaderT @(ST s) @_" + forall (@s) (@r) ($dFunctor :: Functor (ST s)). + $fFunctorReaderT @(ST s) @r $dFunctor + = $fApplicativeReaderT_$s$fFunctorReaderT @s @r +"SPEC $fMonadReaderT @(ST s) @_" + forall (@s) (@r) ($dMonad :: Monad (ST s)). + $fMonadReaderT @(ST s) @r $dMonad + = $fMonadAbstractIOSTReaderT_$s$fMonadReaderT @s @r "USPEC useAbstractMonad @(ReaderT Int (ST s))" forall (@s) ($dMonadAbstractIOST :: MonadAbstractIOST (ReaderT Int (ST s))). ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -359,7 +359,6 @@ test('T19586', normal, compile, ['']) test('T19599', normal, compile, ['-O -ddump-rules']) test('T19599a', normal, compile, ['-O -ddump-rules']) -test('T13873', [expect_broken(21229), grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) # Look for a specialisation rule for wimwam test('T19672', normal, compile, ['-O2 -ddump-rules']) @@ -429,3 +428,4 @@ test('T21763', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) test('T21763a', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) test('T22028', normal, compile, ['-O -ddump-rule-firings']) test('T22114', normal, compile, ['-O']) +test('T13873', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ff2734fa3eae10dc33ec77af632642a5ca9f6f3c...651265b431eacc3c35d001582d4de0eb36b66f74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ff2734fa3eae10dc33ec77af632642a5ca9f6f3c...651265b431eacc3c35d001582d4de0eb36b66f74 You're receiving 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 Sep 9 16:48:44 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 09 Sep 2022 12:48:44 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T21717 Message-ID: <631b6e6caacb8_869eb5152c65429a@gitlab.mail> Sebastian Graf pushed new branch wip/T21717 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T21717 You're receiving 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 Sep 9 16:51:54 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Sep 2022 12:51:54 -0400 Subject: [Git][ghc/ghc][wip/T21286] 3 commits: Improve aggressive specialisation Message-ID: <631b6f2a5c646_869eb5148c659559@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 8fe28b19 by Simon Peyton Jones at 2022-09-09T17:49:41+01: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 modules * 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: Metrics: compile_time/bytes allocated -------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 -50.1% GOOD ManyConstructors(normal) ghc/alloc 3,928,349,810 +1.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,523,518,560 +1.2% T12545(normal) ghc/alloc 1,633,149,272 +3.1% T13056(optasm) ghc/alloc 349,532,453 -8.7% GOOD T13253(normal) ghc/alloc 343,592,469 -3.3% GOOD T15164(normal) ghc/alloc 1,304,125,024 -3.4% GOOD T16190(normal) ghc/alloc 278,584,392 -1.5% T16577(normal) ghc/alloc 8,050,423,421 -2.8% GOOD T17836(normal) ghc/alloc 829,913,981 +2.3% T18223(normal) ghc/alloc 734,732,288 -33.3% GOOD T18282(normal) ghc/alloc 150,159,957 -2.9% GOOD T18478(normal) ghc/alloc 498,300,837 +1.2% T19695(normal) ghc/alloc 1,444,571,802 -2.5% GOOD T9630(normal) ghc/alloc 1,523,682,706 -32.8% GOOD WWRec(normal) ghc/alloc 624,174,317 -9.6% GOOD hie002(normal) ghc/alloc 9,020,356,301 +1.8% ------------------------------------------------------------------------- geo. mean -1.7% minimum -50.1% maximum +3.1% I diligently investigated all these big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlesslly specialising wrappers LargeRecord, T9630 I also got one runtime improvement: T9203(normal) run/alloc 105,672,160 -10.7% GOOD but I did not investigate. Nofib is a wash: +===============================++===============+===========+ | real/anna || -0.13% | 0.0% | | real/fem || +0.13% | 0.0% | | real/fulsom || -0.16% | 0.0% | | real/gamteb || +0.02% | 0.0% | | real/gg || +0.01% | 0.0% | | real/lift || -1.55% | 0.0% | | real/reptile || -0.11% | 0.0% | | real/scs || -0.08% | 0.0% | | real/smallpt || +0.51% | 0.0% | | real/symalg || -0.01% | 0.0% | | real/veritas || +0.05% | 0.0% | | shootout/binary-trees || +0.00% | 0.0% | | shootout/fannkuch-redux || -0.05% | 0.0% | | shootout/k-nucleotide || -0.01% | 0.0% | | shootout/n-body || -0.06% | 0.0% | | shootout/spectral-norm || +0.01% | 0.0% | | spectral/constraints || +0.20% | 0.0% | | spectral/dom-lt || +1.80% | 0.0% | | spectral/expert || +0.33% | 0.0% | Metric Decrease: LargeRecord T13056 T15164 T16577 T18223 T9630 WWRec T9203 - - - - - e72a1eb5 by Simon Peyton Jones at 2022-09-09T17:53:17+01: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. - - - - - 8be40982 by Simon Peyton Jones at 2022-09-09T17:53:17+01: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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Make.hs - libraries/base/Foreign/Marshal/Array.hs - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/deSugar/should_compile/T19969.stderr - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/indexed-types/should_compile/T7837.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbadbc1a6815da0f2eddfb7c4291f7026a93ad3a...8be40982755fa9872bbf3de0737accdb263c0500 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbadbc1a6815da0f2eddfb7c4291f7026a93ad3a...8be40982755fa9872bbf3de0737accdb263c0500 You're receiving 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 Sep 9 16:54:01 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Sep 2022 12:54:01 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] 68 commits: Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <631b6fa9a0ad_869eb5142866044f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 363a10bf by Simon Peyton Jones at 2022-09-09T17:55:30+01:00 Experimental patch to make rule rewriting "win" See #21851, #22097 Documentation to come - - - - - 55a9bb78 by Simon Peyton Jones at 2022-09-09T17:55:30+01:00 Wibbles - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − bindisttest/ghc.mk - boot - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d85d827d822823742a4ec69a24d5795d59f5c53...55a9bb78a92b7f8cc1bf8786ce74426adccfc763 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2d85d827d822823742a4ec69a24d5795d59f5c53...55a9bb78a92b7f8cc1bf8786ce74426adccfc763 You're receiving 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 Sep 9 16:54:44 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Sep 2022 12:54:44 -0400 Subject: [Git][ghc/ghc][wip/T22084] 67 commits: Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <631b6fd4e7498_869eb5148c6611ac@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22084 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 827f97be by Simon Peyton Jones at 2022-09-09T17:56:13+01:00 Don't keep exit join points so much ToDo: write a proper Note and commit message. This is for CI - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − bindisttest/ghc.mk - boot - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7c17f00a8dd3215ccf8ee5f9457a2360999f727...827f97bedd494025e969166b4c18cbb198515e34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7c17f00a8dd3215ccf8ee5f9457a2360999f727...827f97bedd494025e969166b4c18cbb198515e34 You're receiving 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 Sep 11 00:12:55 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Sat, 10 Sep 2022 20:12:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22167 Message-ID: <631d2807ad616_869eb515f47635cd@gitlab.mail> Ryan Scott pushed new branch wip/T22167 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22167 You're receiving 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 Sep 11 09:38:07 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 11 Sep 2022 05:38:07 -0400 Subject: [Git][ghc/ghc][wip/T21623] Wrap dictionaries in tuples Message-ID: <631dac7fe54fd_3b59a65148c11552e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 05f5d5f3 by Simon Peyton Jones at 2022-09-11T10:33:27+01:00 Wrap dictionaries in tuples This fixes the kind bugs in arrow desugaring. Needs some Notes, but I want to try CI. - - - - - 14 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/ListComp.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Binary.hs - libraries/ghc-prim/GHC/Magic/Dict.hs - libraries/ghc-prim/GHC/Types.hs - testsuite/tests/ghci.debugger/scripts/break013.stdout Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -334,6 +334,9 @@ basicKnownKeyNames fromListNName, toListName, + -- Non-empty lists + nonEmptyTyConName, + -- Overloaded record dot, record update getFieldName, setFieldName, @@ -1411,7 +1414,10 @@ constraintKindRepName = varQual gHC_TYPES (fsLit "krep$Constraint") con -- WithDict withDictClassName :: Name -withDictClassName = clsQual gHC_MAGIC_DICT (fsLit "WithDict") withDictClassKey +withDictClassName = clsQual gHC_MAGIC_DICT (fsLit "WithDict") withDictClassKey + +nonEmptyTyConName :: Name +nonEmptyTyConName = tcQual gHC_BASE (fsLit "NonEmpty") nonEmptyTyConKey -- Custom type errors errorMessageTypeErrorFamName @@ -1896,6 +1902,9 @@ voidTyConKey = mkPreludeTyConUnique 85 nonEmptyTyConKey :: Unique nonEmptyTyConKey = mkPreludeTyConUnique 86 +dictTyConKey :: Unique +dictTyConKey = mkPreludeTyConUnique 87 + -- Kind constructors liftedTypeKindTyConKey, unliftedTypeKindTyConKey, tYPETyConKey, cONSTRAINTTyConKey, @@ -2077,8 +2086,7 @@ charDataConKey, consDataConKey, doubleDataConKey, falseDataConKey, floatDataConKey, intDataConKey, nilDataConKey, ratioDataConKey, stableNameDataConKey, trueDataConKey, wordDataConKey, word8DataConKey, ioDataConKey, heqDataConKey, - coercibleDataConKey, eqDataConKey, nothingDataConKey, justDataConKey, - nonEmptyDataConKey :: Unique + eqDataConKey, nothingDataConKey, justDataConKey :: Unique charDataConKey = mkPreludeDataConUnique 1 consDataConKey = mkPreludeDataConUnique 2 @@ -2097,7 +2105,6 @@ trueDataConKey = mkPreludeDataConUnique 14 wordDataConKey = mkPreludeDataConUnique 15 ioDataConKey = mkPreludeDataConUnique 16 heqDataConKey = mkPreludeDataConUnique 18 -nonEmptyDataConKey = mkPreludeDataConUnique 19 -- Generic data constructors crossDataConKey, inlDataConKey, inrDataConKey, genUnitDataConKey :: Unique @@ -2115,7 +2122,10 @@ ordLTDataConKey = mkPreludeDataConUnique 27 ordEQDataConKey = mkPreludeDataConUnique 28 ordGTDataConKey = mkPreludeDataConUnique 29 +mkDictDataConKey :: Unique +mkDictDataConKey = mkPreludeDataConUnique 30 +coercibleDataConKey :: Unique coercibleDataConKey = mkPreludeDataConUnique 32 staticPtrDataConKey :: Unique ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -63,10 +63,6 @@ module GHC.Builtin.Types ( promotedNilDataCon, promotedConsDataCon, mkListTy, mkPromotedListTy, - -- * NonEmpty - nonEmptyTyCon, nonEmptyTyConName, - nonEmptyDataCon, nonEmptyDataConName, - -- * Maybe maybeTyCon, maybeTyConName, nothingDataCon, nothingDataConName, promotedNothingDataCon, @@ -100,6 +96,9 @@ module GHC.Builtin.Types ( -- * Sums mkSumTy, sumTyCon, sumDataCon, + -- * data type Dict + dictTyCon, mkDictDataCon, + -- * Kinds typeSymbolKindCon, typeSymbolKind, isLiftedTypeKindTyConName, @@ -321,7 +320,7 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because they , unliftedRepTyCon , zeroBitRepTyCon , zeroBitTypeTyCon - , nonEmptyTyCon + , dictTyCon ] mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name @@ -380,10 +379,6 @@ listTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "List") nilDataConName = mkWiredInDataConName BuiltInSyntax gHC_TYPES (fsLit "[]") nilDataConKey nilDataCon consDataConName = mkWiredInDataConName BuiltInSyntax gHC_TYPES (fsLit ":") consDataConKey consDataCon -nonEmptyTyConName, nonEmptyDataConName :: Name -nonEmptyTyConName = mkWiredInTyConName UserSyntax gHC_BASE (fsLit "NonEmpty") nonEmptyTyConKey nonEmptyTyCon -nonEmptyDataConName = mkWiredInDataConName UserSyntax gHC_BASE (fsLit ":|") nonEmptyDataConKey nonEmptyDataCon - maybeTyConName, nothingDataConName, justDataConName :: Name maybeTyConName = mkWiredInTyConName UserSyntax gHC_MAYBE (fsLit "Maybe") maybeTyConKey maybeTyCon @@ -1188,6 +1183,23 @@ unboxedUnitDataCon :: DataCon unboxedUnitDataCon = tupleDataCon Unboxed 0 +dictTyConName, mkDictDataConName :: Name +dictTyConName = mkWiredInTyConName UserSyntax gHC_MAGIC_DICT (fsLit "Dict") + dictTyConKey dictTyCon + +mkDictDataConName = mkWiredInDataConName UserSyntax gHC_MAGIC_DICT (fsLit "MkDict") + mkDictDataConKey mkDictDataCon + +dictTyCon :: TyCon +dictTyCon = pcTyCon dictTyConName Nothing [alphaConstraintTyVar] [mkDictDataCon] + +mkDictDataCon :: DataCon +mkDictDataCon = pcDataConConstraint mkDictDataConName + [alphaConstraintTyVar] + [alphaConstraintTy] + dictTyCon + + {- ********************************************************************* * * Unboxed sums @@ -1824,30 +1836,6 @@ int8ElemRepDataConTy, int16ElemRepDataConTy, int32ElemRepDataConTy, * * ********************************************************************* -} -boxingDataCon_maybe :: TyCon -> Maybe DataCon --- boxingDataCon_maybe Char# = C# --- boxingDataCon_maybe Int# = I# --- ... etc ... --- See Note [Boxing primitive types] -boxingDataCon_maybe tc - = lookupNameEnv boxing_constr_env (tyConName tc) - -boxing_constr_env :: NameEnv DataCon -boxing_constr_env - = mkNameEnv [(charPrimTyConName , charDataCon ) - ,(intPrimTyConName , intDataCon ) - ,(wordPrimTyConName , wordDataCon ) - ,(floatPrimTyConName , floatDataCon ) - ,(doublePrimTyConName, doubleDataCon) ] - -{- Note [Boxing primitive types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -For a handful of primitive types (Int, Char, Word, Float, Double), -we can readily box and an unboxed version (Int#, Char# etc) using -the corresponding data constructor. This is useful in a couple -of places, notably let-floating -} - - charTy :: Type charTy = mkTyConTy charTyCon @@ -1924,6 +1912,35 @@ doubleTyCon = pcTyCon doubleTyConName doubleDataCon :: DataCon doubleDataCon = pcDataCon doubleDataConName [] [doublePrimTy] doubleTyCon +{- ********************************************************************* +* * + Boxing data constructors +* * +********************************************************************* -} + +{- Note [Boxing primitive types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For a handful of primitive types (Int, Char, Word, Float, Double), +we can readily box and an unboxed version (Int#, Char# etc) using +the corresponding data constructor. This is useful in a couple +of places, notably let-floating -} + +boxingDataCon_maybe :: TyCon -> Maybe DataCon +-- boxingDataCon_maybe Char# = C# +-- boxingDataCon_maybe Int# = I# +-- ... etc ... +-- See Note [Boxing primitive types] +boxingDataCon_maybe tc + = lookupNameEnv boxing_constr_env (tyConName tc) + +boxing_constr_env :: NameEnv DataCon +boxing_constr_env + = mkNameEnv [(charPrimTyConName , charDataCon ) + ,(intPrimTyConName , intDataCon ) + ,(wordPrimTyConName , wordDataCon ) + ,(floatPrimTyConName , floatDataCon ) + ,(doublePrimTyConName, doubleDataCon) ] + {- ************************************************************************ * * @@ -2038,17 +2055,6 @@ consDataCon = pcDataConWithFixity True {- Declared infix -} -- We can't use (mkListTy alphaTy) in the defn of consDataCon, else mkListTy -- gets the over-specific type (Type -> Type) --- NonEmpty lists (used for 'ProjectionE') -nonEmptyTyCon :: TyCon -nonEmptyTyCon = pcTyCon nonEmptyTyConName Nothing [alphaTyVar] [nonEmptyDataCon] - -nonEmptyDataCon :: DataCon -nonEmptyDataCon = pcDataConWithFixity True {- Declared infix -} - nonEmptyDataConName - alpha_tyvar [] alpha_tyvar [] - (map linear [alphaTy, mkTyConApp listTyCon alpha_ty]) - nonEmptyTyCon - -- Wired-in type Maybe maybeTyCon :: TyCon ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -1,5 +1,3 @@ - - {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- | Handy functions for creating much Core syntax @@ -29,23 +27,18 @@ module GHC.Core.Make ( mkCoreTupBoxity, unitExpr, -- * Constructing big tuples - mkBigCoreVarTup, mkBigCoreVarTup1, + mkChunkified, chunkify, + mkBigCoreVarTup, mkBigCoreVarTupSolo, mkBigCoreVarTupTy, mkBigCoreTupTy, mkBigCoreTup, - -- * Deconstructing small tuples - mkSmallTupleSelector, mkSmallTupleCase, - - -- * Deconstructing big tuples - mkTupleSelector, mkTupleSelector1, mkTupleCase, + -- * Deconstructing big tuples + mkBigTupleSelector, mkBigTupleSelectorSolo, mkBigTupleCase, -- * Constructing list expressions mkNilExpr, mkConsExpr, mkListExpr, mkFoldrExpr, mkBuildExpr, - -- * Constructing non empty lists - mkNonEmptyListExpr, - -- * Constructing Maybe expressions mkNothingExpr, mkJustExpr, @@ -78,8 +71,6 @@ import GHC.Core.Coercion ( isCoVar ) import GHC.Core.DataCon ( DataCon, dataConWorkId ) import GHC.Core.Multiplicity -import GHC.Hs.Utils ( mkChunkified, chunkify ) - import GHC.Builtin.Types import GHC.Builtin.Names import GHC.Builtin.Types.Prim @@ -89,6 +80,7 @@ import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Panic.Plain +import GHC.Settings.Constants( mAX_TUPLE_SIZE ) import GHC.Data.FastString import Data.List ( partition ) @@ -334,20 +326,36 @@ mkStringExprFSWith ids str {- ************************************************************************ * * -\subsection{Tuple constructors} + Creating tuples and their types for Core expressions * * ************************************************************************ -} -{- -Creating tuples and their types for Core expressions +{- Note [Big tuples] +~~~~~~~~~~~~~~~~~~~~ +GHCs built-in tuples can only go up to 'mAX_TUPLE_SIZE' in arity, but +we might conceivably want to build such a massive tuple as part of the +output of a desugaring stage (notably that for list comprehensions). + +We call tuples above this size "big tuples", and emulate them by +creating and pattern matching on >nested< tuples that are expressible +by GHC. + +Nesting policy: it's better to have a 2-tuple of 10-tuples (3 objects) +than a 10-tuple of 2-tuples (11 objects), so we want the leaves of any +construction to be big. - at mkBigCoreVarTup@ builds a tuple; the inverse to @mkTupleSelector at . +If you just use the 'mkBigCoreTup', 'mkBigCoreVarTupTy', 'mkBigTupleSelector' +and 'mkBigTupleCase' functions to do all your work with tuples you should be +fine, and not have to worry about the arity limitation at all. + + +`mkBigCoreVarTup` builds a tuple; the inverse to `mkBigTupleSelector`. * If it has only one element, it is the identity function. * If there are more elements than a big tuple can have, it nests - the tuples. + the tuples. See Note [Big tuples] Note [Flattening one-tuples] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -360,8 +368,8 @@ We could do one of two things: mkCoreTup [e1] = e1 * Build a one-tuple (see Note [One-tuples] in GHC.Builtin.Types) - mkCoreTup1 [e1] = Solo e1 - We use a suffix "1" to indicate this. + mkCoreTupSolo [e1] = Solo e1 + We use a suffix "Solo" to indicate this. Usually we want the former, but occasionally the latter. @@ -390,14 +398,14 @@ mkCoreVarTupTy ids = mkBoxedTupleTy (map idType ids) -- One-tuples are flattened; see Note [Flattening one-tuples] mkCoreTup :: [CoreExpr] -> CoreExpr mkCoreTup [c] = c -mkCoreTup cs = mkCoreTup1 cs -- non-1-tuples are uniform +mkCoreTup cs = mkCoreTupSolo cs -- non-1-tuples are uniform -- | Build a small tuple holding the specified expressions -- One-tuples are *not* flattened; see Note [Flattening one-tuples] -- See also Note [Don't flatten tuples from HsSyn] -mkCoreTup1 :: [CoreExpr] -> CoreExpr -mkCoreTup1 cs = mkCoreConApps (tupleDataCon Boxed (length cs)) - (map (Type . exprType) cs ++ cs) +mkCoreTupSolo :: [CoreExpr] -> CoreExpr +mkCoreTupSolo cs = mkCoreConApps (tupleDataCon Boxed (length cs)) + (map (Type . exprType) cs ++ cs) -- | Build a small unboxed tuple holding the specified expressions, -- with the given types. The types must be the types of the expressions. @@ -412,7 +420,7 @@ mkCoreUbxTup tys exps -- | Make a core tuple of the given boxity; don't flatten 1-tuples mkCoreTupBoxity :: Boxity -> [CoreExpr] -> CoreExpr -mkCoreTupBoxity Boxed exps = mkCoreTup1 exps +mkCoreTupBoxity Boxed exps = mkCoreTupSolo exps mkCoreTupBoxity Unboxed exps = mkCoreUbxTup (map exprType exps) exps -- | Build an unboxed sum. @@ -427,37 +435,101 @@ mkCoreUbxSum arity alt tys exp ++ map Type tys ++ [exp]) +mkBigCoreVarTupSolo :: [Id] -> CoreExpr +-- Same as mkBigCoreVarTup, but +-- - one-tuples are not flattened +-- see Note [Flattening one-tuples] +-- - constraints are not wrapped -- they should never show up +mkBigCoreVarTupSolo [id] = mkCoreConApps (tupleDataCon Boxed 1) + [Type (idType id), Var id] +mkBigCoreVarTupSolo ids = mkChunkified mkCoreTup (map Var ids) + -- | Build a big tuple holding the specified variables -- One-tuples are flattened; see Note [Flattening one-tuples] +-- Constraints are wrapped in MkDict mkBigCoreVarTup :: [Id] -> CoreExpr mkBigCoreVarTup ids = mkBigCoreTup (map Var ids) -mkBigCoreVarTup1 :: [Id] -> CoreExpr --- Same as mkBigCoreVarTup, but one-tuples are NOT flattened --- see Note [Flattening one-tuples] -mkBigCoreVarTup1 [id] = mkCoreConApps (tupleDataCon Boxed 1) - [Type (idType id), Var id] -mkBigCoreVarTup1 ids = mkBigCoreTup (map Var ids) +-- | Build a "big" tuple holding the specified expressions +-- One-tuples are flattened; see Note [Flattening one-tuples] +-- Constraints are wrapped in MkDict +mkBigCoreTup :: [CoreExpr] -> CoreExpr +mkBigCoreTup exprs + = mkChunkified mkCoreTup (map wrapBox exprs) -- | Build the type of a big tuple that holds the specified variables -- One-tuples are flattened; see Note [Flattening one-tuples] mkBigCoreVarTupTy :: [Id] -> Type mkBigCoreVarTupTy ids = mkBigCoreTupTy (map idType ids) --- | Build a big tuple holding the specified expressions --- One-tuples are flattened; see Note [Flattening one-tuples] -mkBigCoreTup :: [CoreExpr] -> CoreExpr -mkBigCoreTup = mkChunkified mkCoreTup - -- | Build the type of a big tuple that holds the specified type of thing -- One-tuples are flattened; see Note [Flattening one-tuples] mkBigCoreTupTy :: [Type] -> Type -mkBigCoreTupTy = mkChunkified mkBoxedTupleTy +mkBigCoreTupTy tys = mkChunkified mkBoxedTupleTy $ + map boxTy tys -- | The unit expression unitExpr :: CoreExpr unitExpr = Var unitDataConId +-------------------------------------------------------------- +wrapBox :: CoreExpr -> CoreExpr +-- If (e :: ty) and (ty :: Type), wrapBox is a no-op +-- But if (ty :: Constraint), returns (MkDict @ty e) +-- which has kind Type +wrapBox e + | isPredTy e_ty = mkCoreConApps mkDictDataCon [Type e_ty, e] + | otherwise = e + where + e_ty = exprType e + +boxTy :: Type -> Type +-- If (ty :: Type) then boxTy is a no-op +-- but if (ty :: Constraint), boxTy returns (Dict ty) +boxTy ty + | isPredTy ty = assertPpr (not (isUnliftedType ty)) (ppr ty) $ + mkTyConApp dictTyCon [ty] + | otherwise = ty + +unwrapBox :: UniqSupply -> Id -> CoreExpr + -> (UniqSupply, Id, CoreExpr) +-- (unwrapBox us v body) +-- returns (case v' of MkDict v -> body) +-- together with v' +unwrapBox us var body + | isPredTy var_ty = (us', var', body') + | otherwise = (us, var, body) + where + (uniq, us') = takeUniqFromSupply us + var_ty = idType var + var' = mkSysLocal (fsLit "uc") uniq ManyTy (boxTy var_ty) + body' = Case (Var var') var' (exprType body) + [Alt (DataAlt mkDictDataCon) [var] body] + + +-- | Lifts a \"small\" constructor into a \"big\" constructor by recursive decomposition +mkChunkified :: ([a] -> a) -- ^ \"Small\" constructor function, of maximum input arity 'mAX_TUPLE_SIZE' + -> [a] -- ^ Possible \"big\" list of things to construct from + -> a -- ^ Constructed thing made possible by recursive decomposition +mkChunkified small_tuple as = mk_big_tuple (chunkify as) + where + -- Each sub-list is short enough to fit in a tuple + mk_big_tuple [as] = small_tuple as + mk_big_tuple as_s = mk_big_tuple (chunkify (map small_tuple as_s)) + +chunkify :: [a] -> [[a]] +-- ^ Split a list into lists that are small enough to have a corresponding +-- tuple arity. The sub-lists of the result all have length <= 'mAX_TUPLE_SIZE' +-- But there may be more than 'mAX_TUPLE_SIZE' sub-lists +chunkify xs + | n_xs <= mAX_TUPLE_SIZE = [xs] + | otherwise = split xs + where + n_xs = length xs + split [] = [] + split xs = take mAX_TUPLE_SIZE xs : split (drop mAX_TUPLE_SIZE xs) + + {- ************************************************************************ * * @@ -478,16 +550,16 @@ unitExpr = Var unitDataConId -- If necessary, we pattern match on a \"big\" tuple. -- -- A tuple selector is not linear in its argument. Consequently, the case --- expression built by `mkTupleSelector` must consume its scrutinee 'Many' +-- expression built by `mkBigTupleSelector` must consume its scrutinee 'Many' -- times. And all the argument variables must have multiplicity 'Many'. -mkTupleSelector, mkTupleSelector1 +mkBigTupleSelector, mkBigTupleSelectorSolo :: [Id] -- ^ The 'Id's to pattern match the tuple against -> Id -- ^ The 'Id' to select -> Id -- ^ A variable of the same type as the scrutinee -> CoreExpr -- ^ Scrutinee -> CoreExpr -- ^ Selector expression --- mkTupleSelector [a,b,c,d] b v e +-- mkBigTupleSelector [a,b,c,d] b v e -- = case e of v { -- (p,q) -> case p of p { -- (a,b) -> b }} @@ -498,7 +570,7 @@ mkTupleSelector, mkTupleSelector1 -- case (case e of v -- (p,q) -> p) of p -- (a,b) -> b -mkTupleSelector vars the_var scrut_var scrut +mkBigTupleSelector vars the_var scrut_var scrut = mk_tup_sel (chunkify vars) the_var where mk_tup_sel [vars] the_var = mkSmallTupleSelector vars the_var scrut_var scrut @@ -507,18 +579,18 @@ mkTupleSelector vars the_var scrut_var scrut where tpl_tys = [mkBoxedTupleTy (map idType gp) | gp <- vars_s] tpl_vs = mkTemplateLocals tpl_tys - [(tpl_v, group)] = [(tpl,gp) | (tpl,gp) <- zipEqual "mkTupleSelector" tpl_vs vars_s, + [(tpl_v, group)] = [(tpl,gp) | (tpl,gp) <- zipEqual "mkBigTupleSelector" tpl_vs vars_s, the_var `elem` gp ] --- ^ 'mkTupleSelector1' is like 'mkTupleSelector' +-- ^ 'mkBigTupleSelectorSolo' is like 'mkBigTupleSelector' -- but one-tuples are NOT flattened (see Note [Flattening one-tuples]) -mkTupleSelector1 vars the_var scrut_var scrut +mkBigTupleSelectorSolo vars the_var scrut_var scrut | [_] <- vars = mkSmallTupleSelector1 vars the_var scrut_var scrut | otherwise - = mkTupleSelector vars the_var scrut_var scrut + = mkBigTupleSelector vars the_var scrut_var scrut --- | Like 'mkTupleSelector' but for tuples that are guaranteed --- never to be \"big\". +-- | `mkSmallTupleSelector` is like 'mkBigTupleSelector', but for tuples that +-- are guaranteed never to be "big". Also does not unwrap Dict types. -- -- > mkSmallTupleSelector [x] x v e = [| e |] -- > mkSmallTupleSelector [x,y,z] x v e = [| case e of v { (x,y,z) -> x } |] @@ -541,45 +613,71 @@ mkSmallTupleSelector1 vars the_var scrut_var scrut Case scrut scrut_var (idType the_var) [Alt (DataAlt (tupleDataCon Boxed (length vars))) vars (Var the_var)] --- | A generalization of 'mkTupleSelector', allowing the body +-- | A generalization of 'mkBigTupleSelector', allowing the body -- of the case to be an arbitrary expression. -- -- To avoid shadowing, we use uniques to invent new variables. -- --- If necessary we pattern match on a \"big\" tuple. -mkTupleCase :: UniqSupply -- ^ For inventing names of intermediate variables - -> [Id] -- ^ The tuple identifiers to pattern match on - -> CoreExpr -- ^ Body of the case - -> Id -- ^ A variable of the same type as the scrutinee - -> CoreExpr -- ^ Scrutinee - -> CoreExpr +-- If necessary we pattern match on a "big" tuple. +mkBigTupleCase :: UniqSupply -- ^ For inventing names of intermediate variables + -> [Id] -- ^ The tuple identifiers to pattern match on; + -- Bring these into scope in the body + -> CoreExpr -- ^ Body of the case + -> CoreExpr -- ^ Scrutinee + -> CoreExpr -- ToDo: eliminate cases where none of the variables are needed. -- --- mkTupleCase uniqs [a,b,c,d] body v e +-- mkBigTupleCase uniqs [a,b,c,d] body v e -- = case e of v { (p,q) -> -- case p of p { (a,b) -> -- case q of q { (c,d) -> -- body }}} -mkTupleCase uniqs vars body scrut_var scrut - = mk_tuple_case uniqs (chunkify vars) body +mkBigTupleCase us vars body scrut + = mk_tuple_case wrapped_us (chunkify wrapped_vars) wrapped_body where + (wrapped_us, wrapped_vars, wrapped_body) = foldr unwrap (us,[],body) vars + + scrut_ty = exprType scrut + + unwrap var (us,vars,body) + = (us', var':vars, body') + where + (us', var', body') = unwrapBox us var body + + mk_tuple_case :: UniqSupply -> [[Id]] -> CoreExpr -> CoreExpr + -- mk_tuple_case [[a1..an], [b1..bm], ...] body + -- case scrut of (p,q, ...) -> + -- case p of (a1,..an) -> + -- case q of (b1,..bm) -> + -- ... -> body -- This is the case where don't need any nesting - mk_tuple_case _ [vars] body + mk_tuple_case us [vars] body = mkSmallTupleCase vars body scrut_var scrut + where + scrut_var = case scrut of + Var v -> v + _ -> snd (new_var us scrut_ty) - -- This is the case where we must make nest tuples at least once + -- This is the case where we must nest tuples at least once mk_tuple_case us vars_s body - = let (us', vars', body') = foldr one_tuple_case (us, [], body) vars_s - in mk_tuple_case us' (chunkify vars') body' + = mk_tuple_case us' (chunkify vars') body' + where + (us', vars', body') = foldr one_tuple_case (us, [], body) vars_s one_tuple_case chunk_vars (us, vs, body) - = let (uniq, us') = takeUniqFromSupply us - scrut_var = mkSysLocal (fsLit "ds") uniq ManyTy - (mkBoxedTupleTy (map idType chunk_vars)) - body' = mkSmallTupleCase chunk_vars body scrut_var (Var scrut_var) - in (us', scrut_var:vs, body') - --- | As 'mkTupleCase', but for a tuple that is small enough to be guaranteed + = (us', scrut_var:vs, body') + where + tup_ty = mkBoxedTupleTy (map idType chunk_vars) + (us', scrut_var) = new_var us tup_ty + body' = mkSmallTupleCase chunk_vars body scrut_var (Var scrut_var) + + new_var :: UniqSupply -> Type -> (UniqSupply, Id) + new_var us ty = (us', id) + where + (uniq, us') = takeUniqFromSupply us + id = mkSysLocal (fsLit "ds") uniq ManyTy ty + +-- | As 'mkBigTupleCase', but for a tuple that is small enough to be guaranteed -- not to need nesting. mkSmallTupleCase :: [Id] -- ^ The tuple args @@ -591,7 +689,6 @@ mkSmallTupleCase mkSmallTupleCase [var] body _scrut_var scrut = bindNonRec var scrut body mkSmallTupleCase vars body scrut_var scrut --- One branch no refinement? = Case scrut scrut_var (exprType body) [Alt (DataAlt (tupleDataCon Boxed (length vars))) vars body] @@ -654,9 +751,6 @@ mkConsExpr ty hd tl = mkCoreConApps consDataCon [Type ty, hd, tl] mkListExpr :: Type -> [CoreExpr] -> CoreExpr mkListExpr ty xs = foldr (mkConsExpr ty) (mkNilExpr ty) xs -mkNonEmptyListExpr :: Type -> CoreExpr -> [CoreExpr] -> CoreExpr -mkNonEmptyListExpr ty x xs = mkCoreConApps nonEmptyDataCon [Type ty, x, mkListExpr ty xs] - -- | Make a fully applied 'foldr' expression mkFoldrExpr :: MonadThings m => Type -- ^ Element type of the list ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -2652,6 +2652,7 @@ typeTypeOrConstraint ty isPredTy :: HasDebugCallStack => Type -> Bool -- Precondition: expects a type that classifies values -- See Note [Types for coercions, predicates, and evidence] in GHC.Core.TyCo.Rep +-- Returns True for types of kind Constraint, False for ones of kind Type isPredTy ty = case typeTypeOrConstraint ty of TypeLike -> False ConstraintLike -> True ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -55,10 +55,6 @@ module GHC.Hs.Utils( mkLHsTupleExpr, mkLHsVarTuple, missingTupArg, mkLocatedList, - -- * Constructing general big tuples - -- $big_tuples - mkChunkified, chunkify, - -- * Bindings mkFunBind, mkVarBind, mkHsVarBind, mkSimpleGeneratedFunBind, mkTopFunBind, mkPatSynBind, @@ -127,7 +123,8 @@ import GHC.Core.Coercion( isReflCo ) import GHC.Core.Multiplicity ( pattern ManyTy ) import GHC.Core.DataCon import GHC.Core.ConLike -import GHC.Core.Type( Type, isUnliftedType ) +import GHC.Core.Make ( mkChunkified ) +import GHC.Core.Type ( Type, isUnliftedType ) import GHC.Builtin.Types ( unitTy ) @@ -144,7 +141,6 @@ import GHC.Types.SourceText import GHC.Data.FastString import GHC.Data.Bag -import GHC.Settings.Constants import GHC.Utils.Misc import GHC.Utils.Outputable @@ -678,47 +674,6 @@ mkBigLHsVarPatTup bs = mkBigLHsPatTup (map nlVarPat bs) mkBigLHsPatTup :: [LPat GhcRn] -> LPat GhcRn mkBigLHsPatTup = mkChunkified mkLHsPatTup --- $big_tuples --- #big_tuples# --- --- GHCs built in tuples can only go up to 'mAX_TUPLE_SIZE' in arity, but --- we might conceivably want to build such a massive tuple as part of the --- output of a desugaring stage (notably that for list comprehensions). --- --- We call tuples above this size \"big tuples\", and emulate them by --- creating and pattern matching on >nested< tuples that are expressible --- by GHC. --- --- Nesting policy: it's better to have a 2-tuple of 10-tuples (3 objects) --- than a 10-tuple of 2-tuples (11 objects), so we want the leaves of any --- construction to be big. --- --- If you just use the 'mkBigCoreTup', 'mkBigCoreVarTupTy', 'mkTupleSelector' --- and 'mkTupleCase' functions to do all your work with tuples you should be --- fine, and not have to worry about the arity limitation at all. - --- | Lifts a \"small\" constructor into a \"big\" constructor by recursive decomposition -mkChunkified :: ([a] -> a) -- ^ \"Small\" constructor function, of maximum input arity 'mAX_TUPLE_SIZE' - -> [a] -- ^ Possible \"big\" list of things to construct from - -> a -- ^ Constructed thing made possible by recursive decomposition -mkChunkified small_tuple as = mk_big_tuple (chunkify as) - where - -- Each sub-list is short enough to fit in a tuple - mk_big_tuple [as] = small_tuple as - mk_big_tuple as_s = mk_big_tuple (chunkify (map small_tuple as_s)) - -chunkify :: [a] -> [[a]] --- ^ Split a list into lists that are small enough to have a corresponding --- tuple arity. The sub-lists of the result all have length <= 'mAX_TUPLE_SIZE' --- But there may be more than 'mAX_TUPLE_SIZE' sub-lists -chunkify xs - | n_xs <= mAX_TUPLE_SIZE = [xs] - | otherwise = split xs - where - n_xs = length xs - split [] = [] - split xs = take mAX_TUPLE_SIZE xs : split (drop mAX_TUPLE_SIZE xs) - {- ************************************************************************ * * ===================================== compiler/GHC/HsToCore/Arrows.hs ===================================== @@ -162,7 +162,7 @@ because the list of variables is typically not yet defined. coreCaseTuple :: UniqSupply -> Id -> [Id] -> CoreExpr -> CoreExpr coreCaseTuple uniqs scrut_var vars body - = mkTupleCase uniqs vars body scrut_var (Var scrut_var) + = mkBigTupleCase uniqs vars body (Var scrut_var) coreCasePair :: Id -> Id -> Id -> CoreExpr -> CoreExpr coreCasePair scrut_var var1 var2 body @@ -178,10 +178,19 @@ mkCorePairExpr e1 e2 = mkCoreTup [e1, e2] mkCoreUnitExpr :: CoreExpr mkCoreUnitExpr = mkCoreTup [] -{- -The input is divided into a local environment, which is a flat tuple -(unless it's too big), and a stack, which is a right-nested pair. -In general, the input has the form +{- Note [Environment and stack] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The input is divided into + +* A local environment, which is a flat tuple (unless it's too big) + The elements of the local environment can be + - of kind Type (for ordinary variables), or + - of kind Constraint (for dictionaries bound by patterns) + +* A stack, which is a right-nested pair. + The elements on the stack are always of kind Type. + +So in general, the input has the form ((x1,...,xn), (s1,...(sk,())...)) @@ -1120,7 +1129,7 @@ dsRecCmd ids local_vars stmts later_ids later_rets rec_ids rec_rets = do where selectVar v | v `elemVarSet` rec_id_set - = mkTupleSelector rec_ids v rec_id (Var rec_id) + = mkBigTupleSelector rec_ids v rec_id (Var rec_id) | otherwise = Var v squash_pair_fn <- matchEnvStack env1_ids rec_id core_body ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -314,7 +314,7 @@ dsAbsBinds dflags tyvars dicts exports = do { tup_id <- newSysLocalDs ManyTy tup_ty ; core_wrap <- dsHsWrapper wrap ; let rhs = core_wrap $ mkLams tyvars $ mkLams dicts $ - mkTupleSelector all_locals local tup_id $ + mkBigTupleSelector all_locals local tup_id $ mkVarApps (Var poly_tup_id) (tyvars ++ dicts) rhs_for_spec = Let (NonRec poly_tup_id poly_tup_rhs) rhs ; (spec_binds, rules) <- dsSpecs rhs_for_spec spec_prags ===================================== compiler/GHC/HsToCore/ListComp.hs ===================================== @@ -450,8 +450,8 @@ mkUnzipBind _ elt_tys concat_expressions = map mkConcatExpression (zip3 elt_tys (map Var xs) (map Var xss)) tupled_concat_expression = mkBigCoreTup concat_expressions - folder_body_inner_case = mkTupleCase us1 xss tupled_concat_expression axs (Var axs) - folder_body_outer_case = mkTupleCase us2 xs folder_body_inner_case ax (Var ax) + folder_body_inner_case = mkBigTupleCase us1 xss tupled_concat_expression (Var axs) + folder_body_outer_case = mkBigTupleCase us2 xs folder_body_inner_case (Var ax) folder_body = mkLams [ax, axs] folder_body_outer_case ; unzip_body <- mkFoldrExpr elt_tuple_ty elt_list_tuple_ty folder_body nil_tuple (Var ys) @@ -543,15 +543,12 @@ dsMcStmt (TransStmt { trS_stmts = stmts, trS_bndrs = bndrs -- Generate the expressions to build the grouped list -- Build a pattern that ensures the consumer binds into the NEW binders, -- which hold monads rather than single values - ; let tup_n_ty' = mkBigCoreVarTupTy to_bndrs - ; body <- dsMcStmts stmts_rest ; n_tup_var' <- newSysLocalDs ManyTy n_tup_ty' - ; tup_n_var' <- newSysLocalDs ManyTy tup_n_ty' ; tup_n_expr' <- mkMcUnzipM form fmap_op n_tup_var' from_bndr_tys ; us <- newUniqueSupply ; let rhs' = mkApps usingExpr' usingArgs' - body' = mkTupleCase us to_bndrs body tup_n_var' tup_n_expr' + body' = mkBigTupleCase us to_bndrs body tup_n_expr' ; dsSyntaxExpr bind_op [rhs', Lam n_tup_var' body'] } @@ -597,7 +594,7 @@ matchTuple :: [Id] -> CoreExpr -> DsM CoreExpr matchTuple ids body = do { us <- newUniqueSupply ; tup_id <- newSysLocalDs ManyTy (mkBigCoreVarTupTy ids) - ; return (Lam tup_id $ mkTupleCase us ids body tup_id (Var tup_id)) } + ; return (Lam tup_id $ mkBigTupleCase us ids body (Var tup_id)) } -- general `rhs' >>= \pat -> stmts` desugaring where `rhs'` is already a -- desugared `CoreExpr` @@ -660,6 +657,6 @@ mkMcUnzipM _ fmap_op ys elt_tys , mk_sel i, Var ys] mk_sel n = Lam tup_xs $ - mkTupleSelector xs (getNth xs n) tup_xs (Var tup_xs) + mkBigTupleSelector xs (getNth xs n) tup_xs (Var tup_xs) ; return (mkBigCoreTup (map mk_elt [0..length elt_tys - 1])) } ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -2963,7 +2963,9 @@ repGetField (MkC exp) fs = do repProjection :: NonEmpty FastString -> MetaM (Core (M TH.Exp)) repProjection fs = do - MkC xs <- coreListNonEmpty stringTy <$> mapM (coreStringLit . unpackFS) fs + ne_tycon <- lift $ dsLookupTyCon nonEmptyTyConName + MkC xs <- coreListNonEmpty ne_tycon stringTy <$> + mapM (coreStringLit . unpackFS) fs rep2 projectionEName [xs] ------------ Lists ------------------- @@ -2995,8 +2997,13 @@ coreList' :: Type -- The element type -> [Core a] -> Core [a] coreList' elt_ty es = MkC (mkListExpr elt_ty (map unC es )) -coreListNonEmpty :: Type -> NonEmpty (Core a) -> Core (NonEmpty a) -coreListNonEmpty ty (MkC x :| xs) = MkC $ mkNonEmptyListExpr ty x (map unC xs) +coreListNonEmpty :: TyCon -- TyCon for NonEmpty + -> Type -- Element type + -> NonEmpty (Core a) + -> Core (NonEmpty a) +coreListNonEmpty ne_tc ty (MkC x :| xs) + = MkC $ mkCoreConApps (tyConSingleDataCon ne_tc) + [Type ty, x, mkListExpr ty (map unC xs)] nonEmptyCoreList :: [Core a] -> Core [a] -- The list must be non-empty so we can get the element type ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -629,7 +629,7 @@ There are two cases. Note that we return 't' as the variable to force if the pattern is strict (i.e. with -XStrict or an outermost-bang-pattern) - Note that (A) /includes/ the situation where + Note that (C) /includes/ the situation where * The pattern binds exactly one variable let !(Just (Just x) = e in body @@ -639,7 +639,8 @@ There are two cases. in t `seq` body The 'Solo' is a one-tuple; see Note [One-tuples] in GHC.Builtin.Types Note that forcing 't' makes the pattern match happen, - but does not force 'v'. + but does not force 'v'. That's why we call `mkBigCoreVarTupSolo` + in `mkSeletcorBinds` * The pattern binds no variables let !(True,False) = e in body @@ -761,7 +762,7 @@ mkSelectorBinds ticks pat val_expr local_tuple error_expr ; let mk_tup_bind tick binder = (binder, mkOptTickBox tick $ - mkTupleSelector1 local_binders binder + mkBigTupleSelectorSolo local_binders binder tuple_var (Var tuple_var)) tup_binds = zipWith mk_tup_bind ticks' binders ; return (tuple_var, (tuple_var, tuple_expr) : tup_binds) } @@ -774,7 +775,7 @@ mkSelectorBinds ticks pat val_expr ticks' = ticks ++ repeat [] local_binders = map localiseId binders -- See Note [Localise pattern binders] - local_tuple = mkBigCoreVarTup1 binders + local_tuple = mkBigCoreVarTupSolo binders tuple_ty = exprType local_tuple strip_bangs :: LPat (GhcPass p) -> LPat (GhcPass p) ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -381,7 +381,7 @@ getSymtabName _name_cache _dict symtab bh = do in return $! case lookupKnownKeyName u of Nothing -> pprPanic "getSymtabName:unknown known-key unique" - (ppr i $$ ppr u) + (ppr i $$ ppr u $$ char tag $$ ppr ix) Just n -> n _ -> pprPanic "getSymtabName:unknown name tag" (ppr i) ===================================== libraries/ghc-prim/GHC/Magic/Dict.hs ===================================== @@ -29,7 +29,9 @@ -- ----------------------------------------------------------------------------- -module GHC.Magic.Dict (WithDict(..)) where +module GHC.Magic.Dict ( + WithDict( withDict ) + ) where import GHC.Types (RuntimeRep, TYPE) @@ -57,4 +59,4 @@ there is nothing that forces the `cls` Wanted from the call to `k` to unify with That's fine. But it means we need -XAllowAmbiguousTypes for the withDict definition, at least with deep subsumption. --} \ No newline at end of file +-} ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -1,7 +1,7 @@ {-# LANGUAGE MagicHash, NoImplicitPrelude, TypeFamilies, UnboxedTuples, MultiParamTypeClasses, RoleAnnotations, CPP, TypeOperators, PolyKinds, NegativeLiterals, DataKinds, ScopedTypeVariables, - TypeApplications, StandaloneKindSignatures, + TypeApplications, StandaloneKindSignatures, GADTs, FlexibleInstances, UndecidableInstances #-} -- NegativeLiterals: see Note [Fixity of (->)] {-# OPTIONS_HADDOCK print-explicit-runtime-reps #-} @@ -51,6 +51,11 @@ module GHC.Types ( VecCount(..), VecElem(..), Void#, + -- * Boxing constructors + DictBox( MkDictBox ), + WordBox( MkWordBox), IntBox( MkIntBox), + FloatBox( MkFloatBox), DoubleBox( MkDoubleBox), + -- * Multiplicity types Multiplicity(..), MultMul, @@ -501,6 +506,24 @@ data VecElem = Int8ElemRep {-# DEPRECATED Void# "Void# is now an alias for the unboxed tuple (# #)." #-} type Void# = (# #) +{- ********************************************************************* +* * + Boxing data constructors +* * +********************************************************************* -} + +-- These "boxing" data types allow us to wrap up a value of kind (TYPE rr) +-- in a box of kind Type, for each rr. +data WordBox (a :: TYPE WordRep) = MkWordBox a +data IntBox (a :: TYPE IntRep) = MkIntBox a +data FloatBox (a :: TYPE FloatRep) = MkFloatBox a +data DoubleBox (a :: TYPE DoubleRep) = MkDoubleBox a + +-- | Data type `Dict` provides a simple way to wrap up constraint as a type +data DictBox c where + MkDictBox :: c => DictBox c + + {- ********************************************************************* * * Runtime representation of TyCon ===================================== testsuite/tests/ghci.debugger/scripts/break013.stdout ===================================== @@ -3,7 +3,7 @@ _result :: (Bool, Bool, ()) = _ a :: Bool = _ b :: Bool = _ c :: () = _ -c :: () = _ b :: Bool = _ a :: Bool = _ +c :: () = _ _result :: (Bool, Bool, ()) = _ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/05f5d5f313c33d58063e95183bc722c8a0052411 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/05f5d5f313c33d58063e95183bc722c8a0052411 You're receiving 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 Sep 11 17:09:23 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Sun, 11 Sep 2022 13:09:23 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22159 Message-ID: <631e164358c29_3b59a6539581571c@gitlab.mail> Ryan Scott pushed new branch wip/T22159 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22159 You're receiving 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 Sep 12 08:07:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 04:07:05 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: CmmToC: enable 64-bit CallishMachOp on 32-bit targets Message-ID: <631ee8a96cfeb_3b59a6d8c860824302e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 9e599f1b by Cheng Shao at 2022-09-12T04:06:48-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToC.hs - compiler/GHC/StgToCmm/Prim.hs - docs/users_guide/9.6.1-notes.rst - libraries/base/Control/Exception/Base.hs - libraries/base/GHC/Exts.hs - libraries/ghc-heap/GHC/Exts/Heap/ClosureTypes.hs - libraries/ghc-prim/GHC/Prim/PtrEq.hs - rts/Apply.cmm - rts/ClosureFlags.c - rts/ClosureSize.c - rts/Compact.cmm - + rts/Continuation.c - + rts/Continuation.h - + rts/ContinuationOps.cmm - rts/Exception.cmm - rts/Heap.c - rts/HeapStackCheck.cmm - rts/LdvProfile.c - rts/PrimOps.cmm - rts/Printer.c - rts/ProfHeap.c - rts/RetainerProfile.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/Ticky.c - rts/TraverseHeap.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b131308ec561514941b31ec311f3d73dfc5a4148...9e599f1b215cbf3a4c43a0cdee2e308330a759c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b131308ec561514941b31ec311f3d73dfc5a4148...9e599f1b215cbf3a4c43a0cdee2e308330a759c8 You're receiving 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 Sep 12 09:18:16 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Mon, 12 Sep 2022 05:18:16 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Primops: T4442 finishes ByteArrayAs still fails Message-ID: <631ef958ccbd2_3b59a6514dc2583b@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: ee6f41dd by doyougnu at 2022-09-07T14:28:20-04:00 Primops: T4442 finishes ByteArrayAs still fails - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1038,20 +1038,28 @@ genPrim prof ty op = case op of IndexByteArrayOp_Word8AsChar -> \[r] [a,i] -> PrimInline $ r |= dv_u8 a i IndexByteArrayOp_Word8AsWideChar -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i IndexByteArrayOp_Word8AsAddr -> \[r1,r2] [a,i] -> - PrimInline $ jVar \t -> mconcat - [-- grab the "array" property - t |= a .^ "arr" - -- make sure we have a non-empty array - , ifBlockS (t .&&. t .! i) - -- we do, r1 is the ArrayBuffer, r2 is the payload offset - [ r1 |= t - , r2 |= dv_u32 t i - ] - -- we don't - [ r1 |= null_ - , r2 |= zero_ - ] - ] + PrimInline $ jVar \x -> mconcat + [ x |= i .<<. two_ + , ifS (a .^ "arr" .&&. a .^ "arr" .! x) + (mconcat [ r1 |= a .^ "arr" .! x .! zero_ + , r2 |= a .^ "arr" .! x .! one_ + ]) + (mconcat [r1 |= null_, r2 |= one_]) + ] + -- PrimInline $ jVar \t -> mconcat + -- [-- grab the "array" property + -- t |= a .^ "arr" + -- -- make sure we have a non-empty array + -- , ifBlockS (t .&&. t .! i) + -- -- we do, r1 is the ArrayBuffer, r2 is the payload offset + -- [ r1 |= t + -- , r2 |= dv_u32 t i + -- ] + -- -- we don't + -- [ r1 |= null_ + -- , r2 |= zero_ + -- ] + -- ] IndexByteArrayOp_Word8AsFloat -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i IndexByteArrayOp_Word8AsDouble -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i IndexByteArrayOp_Word8AsStablePtr -> \[r1,r2] [a,i] -> @@ -1079,20 +1087,28 @@ genPrim prof ty op = case op of ReadByteArrayOp_Word8AsChar -> \[r] [a,i] -> PrimInline $ r |= dv_u8 a i ReadByteArrayOp_Word8AsWideChar -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i ReadByteArrayOp_Word8AsAddr -> \[r1,r2] [a,i] -> - PrimInline $ jVar \t -> mconcat - [-- grab the "array" property - t |= a .^ "arr" - -- make sure we have a non-empty array - , ifBlockS (t .&&. t .! i) - -- we do, r1 is the ArrayBuffer, r2 is the payload offset - [ r1 |= t - , r2 |= dv_u32 t i - ] - -- we don't - [ r1 |= null_ - , r2 |= zero_ - ] - ] + PrimInline $ jVar \x -> mconcat + [ x |= i .<<. two_ + , ifS (a .^ "arr" .&&. a .^ "arr" .! x) + (mconcat [ r1 |= a .^ "arr" .! x .! zero_ + , r2 |= a .^ "arr" .! x .! one_ + ]) + (mconcat [r1 |= null_, r2 |= one_]) + ] + -- PrimInline $ jVar \t -> mconcat + -- [-- grab the "array" property + -- t |= a .^ "arr" + -- -- make sure we have a non-empty array + -- , ifBlockS (t .&&. t .! i) + -- -- we do, r1 is the ArrayBuffer, r2 is the payload offset + -- [ r1 |= t + -- , r2 |= dv_u32 t i + -- ] + -- -- we don't + -- [ r1 |= null_ + -- , r2 |= zero_ + -- ] + -- ] ReadByteArrayOp_Word8AsFloat -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i ReadByteArrayOp_Word8AsDouble -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i ReadByteArrayOp_Word8AsStablePtr -> \[r1,r2] [a,i] -> @@ -1121,13 +1137,19 @@ genPrim prof ty op = case op of WriteByteArrayOp_Word8AsWideChar -> \[] [a,i,e] -> PrimInline $ dv_s_i32 a i e WriteByteArrayOp_Word8AsAddr -> \[] [a,i,e1,e2] -> PrimInline $ mconcat - [ ifS (Not (a .^ "arr")) - -- if we don't have the "arr" property then make it - (a .^ "arr" |= ValExpr (JList [])) - -- else noop - mempty - , dv_s_i32 (a .^ "arr") i (ValExpr (JList [e1, e2])) - ] + [ ifS (Not (a .^ "arr")) (a .^ "arr" |= ValExpr (JList [])) mempty + , a .^ "arr" .! (i .<<. two_) |= ValExpr (JList [e1, e2]) + ] + + -- PrimInline $ mconcat + -- [ ifS (Not (a .^ "arr")) + -- -- if we don't have the "arr" property then make it with length 8 + -- -- bytes, 4 for the Addr, 4 for the offset + -- (newByteArray (a .^ "arr") (Int 8)) + -- -- else noop + -- mempty + -- , dv_s_i32 (a .^ "arr") i (ValExpr (JList [e1, e2])) + -- ] WriteByteArrayOp_Word8AsFloat -> \[] [a,i,e] -> PrimInline $ dv_s_f32 a i e WriteByteArrayOp_Word8AsDouble -> \[] [a,i,e] -> PrimInline $ dv_s_f32 a i e WriteByteArrayOp_Word8AsStablePtr -> \[] [a,i,_e1,e2] -> PrimInline $ dv_s_i32 a i e2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee6f41ddb1d8ad45959d0fec5d7f61f1fd0141cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee6f41ddb1d8ad45959d0fec5d7f61f1fd0141cd You're receiving 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 Sep 12 11:07:14 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 07:07:14 -0400 Subject: [Git][ghc/ghc][master] Add native delimited continuations to the RTS Message-ID: <631f12e213eba_3b59a65198c2794ce@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Parser.y - compiler/GHC/StgToCmm/Prim.hs - docs/users_guide/9.6.1-notes.rst - libraries/base/Control/Exception/Base.hs - libraries/base/GHC/Exts.hs - libraries/ghc-heap/GHC/Exts/Heap/ClosureTypes.hs - libraries/ghc-prim/GHC/Prim/PtrEq.hs - rts/Apply.cmm - rts/ClosureFlags.c - rts/ClosureSize.c - rts/Compact.cmm - + rts/Continuation.c - + rts/Continuation.h - + rts/ContinuationOps.cmm - rts/Exception.cmm - rts/Heap.c - rts/HeapStackCheck.cmm - rts/LdvProfile.c - rts/Printer.c - rts/ProfHeap.c - rts/RetainerProfile.c - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/Ticky.c - rts/TraverseHeap.c - rts/include/Cmm.h - rts/include/rts/storage/ClosureMacros.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04062510806e2a3ccf0ecdb71c704a8e1c548c53 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04062510806e2a3ccf0ecdb71c704a8e1c548c53 You're receiving 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 Sep 12 11:07:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 07:07:49 -0400 Subject: [Git][ghc/ghc][master] rts: fix missing dirty_MVAR argument in stg_writeIOPortzh Message-ID: <631f13057a2c1_3b59a651838283052@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - 1 changed file: - rts/PrimOps.cmm Changes: ===================================== rts/PrimOps.cmm ===================================== @@ -2246,7 +2246,7 @@ loop: if (q == stg_END_TSO_QUEUE_closure) { /* No takes, the IOPort is now full. */ if (info == stg_MVAR_CLEAN_info) { - ccall dirty_MVAR(BaseReg "ptr", ioport "ptr"); + ccall dirty_MVAR(BaseReg "ptr", ioport "ptr", StgMVar_value(ioport) "ptr"); } StgMVar_value(ioport) = val; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee471dfb8a4a4bb5131a5baa61d1d0d22c933d5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee471dfb8a4a4bb5131a5baa61d1d0d22c933d5f You're receiving 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 Sep 12 12:42:04 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 12 Sep 2022 08:42:04 -0400 Subject: [Git][ghc/ghc][wip/T21623] More on boxing data cons Message-ID: <631f291cdffa3_3b59a6194ff95c320146@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: d711fa4e by Simon Peyton Jones at 2022-09-12T13:41:37+01:00 More on boxing data cons - - - - - 5 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/SetLevels.hs - libraries/ghc-prim/GHC/Types.hs Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -34,7 +34,7 @@ module GHC.Builtin.Types ( promotedLTDataCon, promotedEQDataCon, promotedGTDataCon, -- * Boxing primitive types - boxingDataCon_maybe, + boxingDataCon_maybe, boxingDataConUnlifted_maybe, -- * Char charTyCon, charDataCon, charTyCon_RDR, @@ -96,9 +96,6 @@ module GHC.Builtin.Types ( -- * Sums mkSumTy, sumTyCon, sumDataCon, - -- * data type Dict - dictTyCon, mkDictDataCon, - -- * Kinds typeSymbolKindCon, typeSymbolKind, isLiftedTypeKindTyConName, @@ -174,25 +171,30 @@ import GHC.Builtin.Uniques -- others: import GHC.Core.Coercion.Axiom -import GHC.Types.Id -import GHC.Types.TyThing -import GHC.Types.SourceText -import GHC.Types.Var ( VarBndr (Bndr) ) -import GHC.Settings.Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE, mAX_SUM_SIZE ) -import GHC.Unit.Module ( Module ) import GHC.Core.Type -import qualified GHC.Core.TyCo.Rep as TyCoRep (Type(TyConApp)) -import GHC.Types.RepType +import GHC.Types.Id import GHC.Core.DataCon import GHC.Core.ConLike import GHC.Core.TyCon import GHC.Core.Class ( Class, mkClass ) +import GHC.Core.Map.Type ( TypeMap, emptyTypeMap, extendTypeMap, lookupTypeMap ) +import qualified GHC.Core.TyCo.Rep as TyCoRep (Type(TyConApp)) + +import GHC.Types.TyThing +import GHC.Types.SourceText +import GHC.Types.Var ( VarBndr (Bndr) ) +import GHC.Types.RepType import GHC.Types.Name.Reader import GHC.Types.Name as Name -import GHC.Types.Name.Env ( NameEnv, mkNameEnv, lookupNameEnv, lookupNameEnv_NF ) +import GHC.Types.Name.Env ( lookupNameEnv_NF ) import GHC.Types.Basic import GHC.Types.ForeignCall import GHC.Types.Unique.Set + + +import GHC.Settings.Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE, mAX_SUM_SIZE ) +import GHC.Unit.Module ( Module ) + import Data.Array import GHC.Data.FastString import GHC.Data.BooleanFormula ( mkAnd ) @@ -276,7 +278,8 @@ names in GHC.Builtin.Names, so they use wTcQual, wDataQual, etc -- See also Note [Known-key names] wiredInTyCons :: [TyCon] -wiredInTyCons = [ -- Units are not treated like other tuples, because they +wiredInTyCons = map (dataConTyCon . snd) boxingDataCons + ++ [ -- Units are not treated like other tuples, because they -- are defined in GHC.Base, and there's only a few of them. We -- put them in wiredInTyCons so that they will pre-populate -- the name cache, so the parser in isBuiltInOcc_maybe doesn't @@ -320,7 +323,6 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because they , unliftedRepTyCon , zeroBitRepTyCon , zeroBitTypeTyCon - , dictTyCon ] mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name @@ -508,40 +510,6 @@ typeSymbolKindConName :: Name typeSymbolKindConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Symbol") typeSymbolKindConNameKey typeSymbolKindCon -runtimeRepTyConName, vecRepDataConName, tupleRepDataConName, sumRepDataConName, boxedRepDataConName :: Name -runtimeRepTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "RuntimeRep") runtimeRepTyConKey runtimeRepTyCon -vecRepDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "VecRep") vecRepDataConKey vecRepDataCon -tupleRepDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "TupleRep") tupleRepDataConKey tupleRepDataCon -sumRepDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "SumRep") sumRepDataConKey sumRepDataCon -boxedRepDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "BoxedRep") boxedRepDataConKey boxedRepDataCon - -vecCountTyConName :: Name -vecCountTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "VecCount") vecCountTyConKey vecCountTyCon - --- See Note [Wiring in RuntimeRep] -vecCountDataConNames :: [Name] -vecCountDataConNames = zipWith3Lazy mk_special_dc_name - [ fsLit "Vec2", fsLit "Vec4", fsLit "Vec8" - , fsLit "Vec16", fsLit "Vec32", fsLit "Vec64" ] - vecCountDataConKeys - vecCountDataCons - -vecElemTyConName :: Name -vecElemTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "VecElem") vecElemTyConKey vecElemTyCon - --- See Note [Wiring in RuntimeRep] -vecElemDataConNames :: [Name] -vecElemDataConNames = zipWith3Lazy mk_special_dc_name - [ fsLit "Int8ElemRep", fsLit "Int16ElemRep", fsLit "Int32ElemRep" - , fsLit "Int64ElemRep", fsLit "Word8ElemRep", fsLit "Word16ElemRep" - , fsLit "Word32ElemRep", fsLit "Word64ElemRep" - , fsLit "FloatElemRep", fsLit "DoubleElemRep" ] - vecElemDataConKeys - vecElemDataCons - -mk_special_dc_name :: FastString -> Unique -> DataCon -> Name -mk_special_dc_name fs u dc = mkWiredInDataConName UserSyntax gHC_TYPES fs u dc - boolTyCon_RDR, false_RDR, true_RDR, intTyCon_RDR, charTyCon_RDR, stringTyCon_RDR, intDataCon_RDR, listTyCon_RDR, consDataCon_RDR :: RdrName boolTyCon_RDR = nameRdrName boolTyConName @@ -1182,24 +1150,6 @@ unboxedUnitTyCon = tupleTyCon Unboxed 0 unboxedUnitDataCon :: DataCon unboxedUnitDataCon = tupleDataCon Unboxed 0 - -dictTyConName, mkDictDataConName :: Name -dictTyConName = mkWiredInTyConName UserSyntax gHC_MAGIC_DICT (fsLit "Dict") - dictTyConKey dictTyCon - -mkDictDataConName = mkWiredInDataConName UserSyntax gHC_MAGIC_DICT (fsLit "MkDict") - mkDictDataConKey mkDictDataCon - -dictTyCon :: TyCon -dictTyCon = pcTyCon dictTyConName Nothing [alphaConstraintTyVar] [mkDictDataCon] - -mkDictDataCon :: DataCon -mkDictDataCon = pcDataConConstraint mkDictDataConName - [alphaConstraintTyVar] - [alphaConstraintTy] - dictTyCon - - {- ********************************************************************* * * Unboxed sums @@ -1600,12 +1550,26 @@ See also Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType. runtimeRepTyCon :: TyCon runtimeRepTyCon = pcTyCon runtimeRepTyConName Nothing [] + -- Here we list all the data constructors + -- of the RuntimeRep data type (vecRepDataCon : tupleRepDataCon : - sumRepDataCon : boxedRepDataCon : runtimeRepSimpleDataCons) + sumRepDataCon : boxedRepDataCon : + runtimeRepSimpleDataCons) runtimeRepTy :: Type runtimeRepTy = mkTyConTy runtimeRepTyCon +runtimeRepTyConName, vecRepDataConName, tupleRepDataConName, sumRepDataConName, boxedRepDataConName :: Name +runtimeRepTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "RuntimeRep") runtimeRepTyConKey runtimeRepTyCon + +vecRepDataConName = mk_runtime_rep_dc_name (fsLit "VecRep") vecRepDataConKey vecRepDataCon +tupleRepDataConName = mk_runtime_rep_dc_name (fsLit "TupleRep") tupleRepDataConKey tupleRepDataCon +sumRepDataConName = mk_runtime_rep_dc_name (fsLit "SumRep") sumRepDataConKey sumRepDataCon +boxedRepDataConName = mk_runtime_rep_dc_name (fsLit "BoxedRep") boxedRepDataConKey boxedRepDataCon + +mk_runtime_rep_dc_name :: FastString -> Unique -> DataCon -> Name +mk_runtime_rep_dc_name fs u dc = mkWiredInDataConName UserSyntax gHC_TYPES fs u dc + boxedRepDataCon :: DataCon boxedRepDataCon = pcSpecialDataCon boxedRepDataConName [ levityTy ] runtimeRepTyCon (RuntimeRep prim_rep_fun) @@ -1656,53 +1620,31 @@ sumRepDataCon = pcSpecialDataCon sumRepDataConName [ mkListTy runtimeRepTy ] sumRepDataConTyCon :: TyCon sumRepDataConTyCon = promoteDataCon sumRepDataCon -vecRepDataCon :: DataCon -vecRepDataCon = pcSpecialDataCon vecRepDataConName [ mkTyConTy vecCountTyCon - , mkTyConTy vecElemTyCon ] - runtimeRepTyCon - (RuntimeRep prim_rep_fun) - where - -- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType - prim_rep_fun [count, elem] - | VecCount n <- tyConPromDataConInfo (tyConAppTyCon count) - , VecElem e <- tyConPromDataConInfo (tyConAppTyCon elem) - = [VecRep n e] - prim_rep_fun args - = pprPanic "vecRepDataCon" (ppr args) - -vecRepDataConTyCon :: TyCon -vecRepDataConTyCon = promoteDataCon vecRepDataCon - -- See Note [Wiring in RuntimeRep] -- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType runtimeRepSimpleDataCons :: [DataCon] runtimeRepSimpleDataCons - = zipWithLazy mk_runtime_rep_dc - [ IntRep - , Int8Rep, Int16Rep, Int32Rep, Int64Rep - , WordRep - , Word8Rep, Word16Rep, Word32Rep, Word64Rep - , AddrRep - , FloatRep, DoubleRep - ] - runtimeRepSimpleDataConNames + = zipWith mk_runtime_rep_dc runtimeRepSimpleDataConKeys + [ (fsLit "IntRep", IntRep) + , (fsLit "Int8Rep", Int8Rep) + , (fsLit "Int16Rep", Int16Rep) + , (fsLit "Int32Rep", Int32Rep) + , (fsLit "Int64Rep", Int64Rep) + , (fsLit "WordRep", WordRep) + , (fsLit "Word8Rep", Word8Rep) + , (fsLit "Word16Rep", Word16Rep) + , (fsLit "Word32Rep", Word32Rep) + , (fsLit "Word64Rep", Word64Rep) + , (fsLit "AddrRep", AddrRep) + , (fsLit "FloatRep", FloatRep) + , (fsLit "DoubleRep", DoubleRep) ] where - mk_runtime_rep_dc primrep name - = pcSpecialDataCon name [] runtimeRepTyCon (RuntimeRep (\_ -> [primrep])) - --- See Note [Wiring in RuntimeRep] -runtimeRepSimpleDataConNames :: [Name] -runtimeRepSimpleDataConNames - = zipWith3Lazy mk_special_dc_name - [ fsLit "IntRep" - , fsLit "Int8Rep", fsLit "Int16Rep", fsLit "Int32Rep", fsLit "Int64Rep" - , fsLit "WordRep" - , fsLit "Word8Rep", fsLit "Word16Rep", fsLit "Word32Rep", fsLit "Word64Rep" - , fsLit "AddrRep" - , fsLit "FloatRep", fsLit "DoubleRep" - ] - runtimeRepSimpleDataConKeys - runtimeRepSimpleDataCons + mk_runtime_rep_dc :: Unique -> (FastString, PrimRep) -> DataCon + mk_runtime_rep_dc uniq (fs, primrep) + = data_con + where + data_con = pcSpecialDataCon dc_name [] runtimeRepTyCon (RuntimeRep (\_ -> [primrep])) + dc_name = mk_runtime_rep_dc_name fs uniq data_con -- See Note [Wiring in RuntimeRep] intRepDataConTy, @@ -1787,6 +1729,47 @@ unliftedRepTy = mkTyConTy unliftedRepTyCon * * ********************************************************************* -} +vecCountTyConName :: Name +vecCountTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "VecCount") vecCountTyConKey vecCountTyCon + +-- See Note [Wiring in RuntimeRep] +vecCountDataConNames :: [Name] +vecCountDataConNames = zipWith3Lazy mk_runtime_rep_dc_name + [ fsLit "Vec2", fsLit "Vec4", fsLit "Vec8" + , fsLit "Vec16", fsLit "Vec32", fsLit "Vec64" ] + vecCountDataConKeys + vecCountDataCons + +vecElemTyConName :: Name +vecElemTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "VecElem") vecElemTyConKey vecElemTyCon + +-- See Note [Wiring in RuntimeRep] +vecElemDataConNames :: [Name] +vecElemDataConNames = zipWith3Lazy mk_runtime_rep_dc_name + [ fsLit "Int8ElemRep", fsLit "Int16ElemRep", fsLit "Int32ElemRep" + , fsLit "Int64ElemRep", fsLit "Word8ElemRep", fsLit "Word16ElemRep" + , fsLit "Word32ElemRep", fsLit "Word64ElemRep" + , fsLit "FloatElemRep", fsLit "DoubleElemRep" ] + vecElemDataConKeys + vecElemDataCons + +vecRepDataCon :: DataCon +vecRepDataCon = pcSpecialDataCon vecRepDataConName [ mkTyConTy vecCountTyCon + , mkTyConTy vecElemTyCon ] + runtimeRepTyCon + (RuntimeRep prim_rep_fun) + where + -- See Note [Getting from RuntimeRep to PrimRep] in GHC.Types.RepType + prim_rep_fun [count, elem] + | VecCount n <- tyConPromDataConInfo (tyConAppTyCon count) + , VecElem e <- tyConPromDataConInfo (tyConAppTyCon elem) + = [VecRep n e] + prim_rep_fun args + = pprPanic "vecRepDataCon" (ppr args) + +vecRepDataConTyCon :: TyCon +vecRepDataConTyCon = promoteDataCon vecRepDataCon + vecCountTyCon :: TyCon vecCountTyCon = pcTyCon vecCountTyConName Nothing [] vecCountDataCons @@ -1918,28 +1901,97 @@ doubleDataCon = pcDataCon doubleDataConName [] [doublePrimTy] doubleTyCon * * ********************************************************************* -} -{- Note [Boxing primitive types] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -For a handful of primitive types (Int, Char, Word, Float, Double), -we can readily box and an unboxed version (Int#, Char# etc) using -the corresponding data constructor. This is useful in a couple -of places, notably let-floating -} - -boxingDataCon_maybe :: TyCon -> Maybe DataCon --- boxingDataCon_maybe Char# = C# --- boxingDataCon_maybe Int# = I# --- ... etc ... --- See Note [Boxing primitive types] -boxingDataCon_maybe tc - = lookupNameEnv boxing_constr_env (tyConName tc) - -boxing_constr_env :: NameEnv DataCon -boxing_constr_env - = mkNameEnv [(charPrimTyConName , charDataCon ) - ,(intPrimTyConName , intDataCon ) - ,(wordPrimTyConName , wordDataCon ) - ,(floatPrimTyConName , floatDataCon ) - ,(doublePrimTyConName, doubleDataCon) ] +{- Note [Boxing constructors} + +In ghc-prim:GHC.Types we have a family of data types, one for each RuntimeRep +that "box" unlifted values into a (boxed, lifted) value of kind Type. For example + + type IntBox :: TYPE IntRep -> Type + data IntBox (a :: TYPE IntRep) = MkIntBox a + -- MkIntBox :: forall (a :: TYPE IntRep). a -> IntBox a + +Then we can package an `Int#` into an `IntBox` with `MkIntBox`. We can also +package up a (lifted) Constraint as a value of kind Type. + +This is used: + +* In desugaring, when we need to package up a bunch of values into a tuple, + for example when desugaring arrows. See Note [Big tuples] in GHC.Core.Make. + +* In let-floating when we want to float an unlifted sub-expression. + See Note [Floating MFEs of unlifted type] in GHC.Core.Opt.SetLevels + +Here we make wired-in data type declarations for all of these boxing functions. +The goal is to define boxingDataCon_maybe. +-} + +boxingDataCon_maybe :: HasDebugCallStack => Type -> Maybe (DataCon, Type) +-- This variant panics if it is given an unlifted type +-- that it does not know how to box. +boxingDataCon_maybe ty + | tcIsLiftedTypeKind kind + = Nothing -- Fast path + | Just box_con <- lookupTypeMap boxingDataConMap kind + = Just (box_con, mkTyConApp (dataConTyCon box_con) [ty]) + | otherwise + = pprPanic "boxingDataCon_maybe" (ppr ty <+> dcolon <+> ppr kind) + where + kind = typeKind ty + +boxingDataConUnlifted_maybe :: HasDebugCallStack => Type -> Maybe (DataCon, Type) +-- This variant expects the type to be unlifted, and does not +-- fail if there is no suitable DataCon; used in SetLevels +boxingDataConUnlifted_maybe ty + | Just box_con <- lookupTypeMap boxingDataConMap kind + = Just (box_con, mkTyConApp (dataConTyCon box_con) [ty]) + | otherwise + = Nothing + where + kind = typeKind ty + +boxingDataConMap :: TypeMap DataCon +boxingDataConMap = foldl add emptyTypeMap boxingDataCons + where + add bdcm (kind, boxing_con) = extendTypeMap bdcm kind boxing_con + +boxingDataCons :: [(Kind, DataCon)] +-- The TyCon is the RuntimeRep for which the DataCon is the right boxing +boxingDataCons = zipWith mkBoxingDataCon + (map mkBoxingTyConUnique [1..]) + [ (mkTYPEapp wordRepDataConTy, fsLit "WordBox", fsLit "MkWordBox") + , (mkTYPEapp intRepDataConTy, fsLit "IntBox", fsLit "MkIntBox") + + , (mkTYPEapp floatRepDataConTy, fsLit "FloatBox", fsLit "MkFloatBox") + , (mkTYPEapp doubleRepDataConTy, fsLit "DoubleBox", fsLit "MkDoubleBox") + + , (mkTYPEapp int8RepDataConTy, fsLit "Int8Box", fsLit "MkInt8Box") + , (mkTYPEapp int16RepDataConTy, fsLit "Int16Box", fsLit "MkInt16Box") + , (mkTYPEapp int32RepDataConTy, fsLit "Int32Box", fsLit "MkInt32Box") + , (mkTYPEapp int64RepDataConTy, fsLit "Int64Box", fsLit "MkInt64Box") + + , (mkTYPEapp word8RepDataConTy, fsLit "Word8Box", fsLit "MkWord8Box") + , (mkTYPEapp word16RepDataConTy, fsLit "Word16Box", fsLit "MkWord16Box") + , (mkTYPEapp word32RepDataConTy, fsLit "Word32Box", fsLit "MkWord32Box") + , (mkTYPEapp word64RepDataConTy, fsLit "Word64Box", fsLit "MkWord64Box") + + , (unliftedTypeKind, fsLit "LiftBox", fsLit "MkLiftBox") + , (constraintKind, fsLit "DictBox", fsLit "MkDictBox") ] + +mkBoxingDataCon :: Unique -> (Kind, FastString, FastString) -> (Kind, DataCon) +mkBoxingDataCon uniq_tc (kind, fs_tc, fs_dc) + = (kind, dc) + where + uniq_dc = boxingDataConUnique uniq_tc + + (tv:_) = mkTemplateTyVars (repeat kind) + tc = pcTyCon tc_name Nothing [tv] [dc] + tc_name = mkWiredInTyConName UserSyntax gHC_TYPES fs_tc uniq_tc tc + + dc | isConstraintKind kind + = pcDataConConstraint dc_name [tv] [mkTyVarTy tv] tc + | otherwise + = pcDataCon dc_name [tv] [mkTyVarTy tv] tc + dc_name = mkWiredInDataConName UserSyntax gHC_TYPES fs_dc uniq_dc dc {- ************************************************************************ ===================================== compiler/GHC/Builtin/Uniques.hs ===================================== @@ -13,8 +13,8 @@ module GHC.Builtin.Uniques -- * Getting the 'Unique's of 'Name's -- ** Anonymous sums - , mkSumTyConUnique - , mkSumDataConUnique + , mkSumTyConUnique, mkSumDataConUnique + -- ** Tuples -- *** Vanilla , mkTupleTyConUnique @@ -45,6 +45,9 @@ module GHC.Builtin.Uniques , initExitJoinUnique + -- Boxing data types + , mkBoxingTyConUnique, boxingDataConUnique + ) where import GHC.Prelude @@ -297,6 +300,7 @@ Allocation of unique supply characters: other a-z: lower case chars for unique supplies. Used so far: a TypeChecking? + b RuntimeRep c StgToCmm/Renamer d desugarer f AbsC flattener @@ -351,7 +355,6 @@ mkTcOccUnique fs = mkUnique 'c' (uniqueOfFS fs) initExitJoinUnique :: Unique initExitJoinUnique = mkUnique 's' 0 - -------------------------------------------------- -- Wired-in type constructor keys occupy *two* slots: -- * u: the TyCon itself @@ -373,7 +376,22 @@ tyConRepNameUnique u = incrUnique u mkPreludeDataConUnique :: Int -> Unique mkPreludeDataConUnique i = mkUnique '6' (3*i) -- Must be alphabetic --------------------------------------------------- dataConTyRepNameUnique, dataConWorkerUnique :: Unique -> Unique dataConWorkerUnique u = incrUnique u dataConTyRepNameUnique u = stepUnique u 2 + +-------------------------------------------------- +-- The data constructors of RuntimeRep occupy *six* slots: +-- Example: WordRep +-- +-- * u: the TyCon of the boxing data type WordBox +-- * u+1: the TyConRepName of the boxing data type +-- * u+2: the DataCon for MkWordBox +-- * u+3: the worker id for MkWordBox +-- * u+4: the TyConRepName of the promoted TyCon 'MkWordBox + +mkBoxingTyConUnique :: Int -> Unique +mkBoxingTyConUnique i = mkUnique 'b' (5*i) + +boxingDataConUnique :: Unique -> Unique +boxingDataConUnique u = stepUnique u 2 ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -478,8 +478,10 @@ wrapBox :: CoreExpr -> CoreExpr -- But if (ty :: Constraint), returns (MkDict @ty e) -- which has kind Type wrapBox e - | isPredTy e_ty = mkCoreConApps mkDictDataCon [Type e_ty, e] - | otherwise = e + | Just (boxing_con, _) <- boxingDataCon_maybe e_ty + = mkCoreConApps boxing_con [Type e_ty, e] + | otherwise + = e where e_ty = exprType e @@ -487,9 +489,10 @@ boxTy :: Type -> Type -- If (ty :: Type) then boxTy is a no-op -- but if (ty :: Constraint), boxTy returns (Dict ty) boxTy ty - | isPredTy ty = assertPpr (not (isUnliftedType ty)) (ppr ty) $ - mkTyConApp dictTyCon [ty] - | otherwise = ty + | Just (_, box_ty) <- boxingDataCon_maybe ty + = box_ty + | otherwise + = ty unwrapBox :: UniqSupply -> Id -> CoreExpr -> (UniqSupply, Id, CoreExpr) @@ -497,15 +500,15 @@ unwrapBox :: UniqSupply -> Id -> CoreExpr -- returns (case v' of MkDict v -> body) -- together with v' unwrapBox us var body - | isPredTy var_ty = (us', var', body') - | otherwise = (us, var, body) - where - (uniq, us') = takeUniqFromSupply us - var_ty = idType var - var' = mkSysLocal (fsLit "uc") uniq ManyTy (boxTy var_ty) - body' = Case (Var var') var' (exprType body) - [Alt (DataAlt mkDictDataCon) [var] body] + | let var_ty = idType var + , Just (box_con, box_ty) <- boxingDataCon_maybe var_ty + , let var' = mkSysLocal (fsLit "uc") uniq ManyTy box_ty + body' = Case (Var var') var' (exprType body) + [Alt (DataAlt box_con) [var] body] + (uniq, us') = takeUniqFromSupply us + = (us', var', body') + | otherwise = (us, var, body) -- | Lifts a \"small\" constructor into a \"big\" constructor by recursive decomposition mkChunkified :: ([a] -> a) -- ^ \"Small\" constructor function, of maximum input arity 'mAX_TUPLE_SIZE' ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -88,12 +88,11 @@ import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, isOneShotBndr ) import GHC.Core.FVs -- all of it import GHC.Core.Subst import GHC.Core.Make ( sortQuantVars ) -import GHC.Core.Type ( Type, splitTyConApp_maybe, tyCoVarsOfType +import GHC.Core.Type ( Type, tyCoVarsOfType , mightBeUnliftedType, closeOverKindsDSet , typeHasFixedRuntimeRep ) import GHC.Core.Multiplicity ( pattern ManyTy ) -import GHC.Core.DataCon ( dataConOrigResTy ) import GHC.Types.Id import GHC.Types.Id.Info @@ -673,21 +672,19 @@ lvlMFE env strict_ctxt ann_expr | escapes_value_lam , not expr_ok_for_spec -- Boxing/unboxing isn't worth it for cheap expressions -- See Note [Test cheapness with exprOkForSpeculation] - , Just (tc, _) <- splitTyConApp_maybe expr_ty - , Just dc <- boxingDataCon_maybe tc - , let dc_res_ty = dataConOrigResTy dc -- No free type variables - [bx_bndr, ubx_bndr] = mkTemplateLocals [dc_res_ty, expr_ty] + , Just (box_dc, box_ty) <- boxingDataConUnlifted_maybe expr_ty + , let [bx_bndr, ubx_bndr] = mkTemplateLocals [box_ty, expr_ty] = do { expr1 <- lvlExpr rhs_env ann_expr ; let l1r = incMinorLvlFrom rhs_env float_rhs = mkLams abs_vars_w_lvls $ - Case expr1 (stayPut l1r ubx_bndr) dc_res_ty - [Alt DEFAULT [] (mkConApp dc [Var ubx_bndr])] + Case expr1 (stayPut l1r ubx_bndr) box_ty + [Alt DEFAULT [] (mkConApp box_dc [Type expr_ty, Var ubx_bndr])] ; var <- newLvlVar float_rhs Nothing is_mk_static ; let l1u = incMinorLvlFrom env use_expr = Case (mkVarApps (Var var) abs_vars) (stayPut l1u bx_bndr) expr_ty - [Alt (DataAlt dc) [stayPut l1u ubx_bndr] (Var ubx_bndr)] + [Alt (DataAlt box_dc) [stayPut l1u ubx_bndr] (Var ubx_bndr)] ; return (Let (NonRec (TB var (FloatMe dest_lvl)) float_rhs) use_expr) } ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -514,12 +514,25 @@ type Void# = (# #) -- These "boxing" data types allow us to wrap up a value of kind (TYPE rr) -- in a box of kind Type, for each rr. -data WordBox (a :: TYPE WordRep) = MkWordBox a -data IntBox (a :: TYPE IntRep) = MkIntBox a -data FloatBox (a :: TYPE FloatRep) = MkFloatBox a -data DoubleBox (a :: TYPE DoubleRep) = MkDoubleBox a +data LiftBox (a :: TYPE UnliftedRep) = MkLiftBox a --- | Data type `Dict` provides a simple way to wrap up constraint as a type +data IntBox (a :: TYPE IntRep) = MkIntBox a +data Int8Box (a :: TYPE Int8Rep) = MkInt8Box a +data Int16Box (a :: TYPE Int16Rep) = MkInt16Box a +data Int32Box (a :: TYPE Int32Rep) = MkInt32Box a +data Int64Box (a :: TYPE Int64Rep) = MkInt64Box a + +data WordBox (a :: TYPE WordRep) = MkWordBox a +data Word8Box (a :: TYPE Word8Rep) = MkWord8Box a +data Word16Box (a :: TYPE Word16Rep) = MkWord16Box a +data Word32Box (a :: TYPE Word32Rep) = MkWord32Box a +data Word64Box (a :: TYPE Word64Rep) = MkWord64Box a + +data FloatBox (a :: TYPE FloatRep) = MkFloatBox a +data DoubleBox (a :: TYPE DoubleRep) = MkDoubleBox a + +-- | Data type `Dict` provides a simple way to wrap up a (lifted) +-- constraint as a type data DictBox c where MkDictBox :: c => DictBox c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d711fa4ebc3b29494bf96ddd5415cdb2ff79565b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d711fa4ebc3b29494bf96ddd5415cdb2ff79565b You're receiving 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 Sep 12 13:42:51 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 12 Sep 2022 09:42:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/tidy-94 Message-ID: <631f375bf1936_3b59a6d8c86f8335971@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/tidy-94 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/tidy-94 You're receiving 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 Sep 12 14:04:45 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 12 Sep 2022 10:04:45 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/jsem Message-ID: <631f3c7ddd76e_3b59a6195e331434422b@gitlab.mail> sheaf pushed new branch wip/jsem at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/jsem You're receiving 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 Sep 12 14:09:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 10:09:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: rts: fix missing dirty_MVAR argument in stg_writeIOPortzh Message-ID: <631f3d89ae20a_3b59a6194ffb503528a1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - c4853e43 by Cheng Shao at 2022-09-12T10:08:58-04:00 ci: enable parallel compression for xz - - - - - 5060f11b by Ryan Scott at 2022-09-12T10:08:58-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. - - - - - 8 changed files: - .gitlab/ci.sh - m4/fp_setup_windows_toolchain.m4 - rts/PrimOps.cmm - testsuite/tests/ffi/should_run/Makefile - + testsuite/tests/ffi/should_run/T22159.hs - + testsuite/tests/ffi/should_run/T22159.stdout - + testsuite/tests/ffi/should_run/T22159_c.c - testsuite/tests/ffi/should_run/all.T Changes: ===================================== .gitlab/ci.sh ===================================== @@ -503,7 +503,7 @@ function build_hadrian() { if [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian build-cabal -V else - run_hadrian binary-dist -V + XZ_OPT="${XZ_OPT:-} -T$cores" run_hadrian binary-dist -V mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" fi ===================================== m4/fp_setup_windows_toolchain.m4 ===================================== @@ -82,7 +82,11 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[ CC="${mingwbin}clang.exe" CXX="${mingwbin}clang++.exe" - cflags="--rtlib=compiler-rt" + + # Signal that we are linking against UCRT with the _UCRT macro. This is + # necessary to ensure correct behavior when MinGW-w64 headers are in the + # header include path (#22159). + cflags="--rtlib=compiler-rt -D_UCRT" CFLAGS="$cflags" CONF_CC_OPTS_STAGE1="$cflags" CONF_CC_OPTS_STAGE2="$cflags" ===================================== rts/PrimOps.cmm ===================================== @@ -2246,7 +2246,7 @@ loop: if (q == stg_END_TSO_QUEUE_closure) { /* No takes, the IOPort is now full. */ if (info == stg_MVAR_CLEAN_info) { - ccall dirty_MVAR(BaseReg "ptr", ioport "ptr"); + ccall dirty_MVAR(BaseReg "ptr", ioport "ptr", StgMVar_value(ioport) "ptr"); } StgMVar_value(ioport) = val; ===================================== testsuite/tests/ffi/should_run/Makefile ===================================== @@ -49,3 +49,10 @@ T15933: '$(TEST_HC)' $(TEST_HC_OPTS) -c T15933.hs '$(TEST_HC)' $(TEST_HC_OPTS) T15933_c.o T15933.o -o T15933 ./T15933 + +.PHONY: T22159 +T22159: + C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) -c T22159.hs + C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) -c T22159_c.c + C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) T22159.o T22159_c.o -o T22159 + ./T22159 ===================================== testsuite/tests/ffi/should_run/T22159.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE CPP #-} +module Main (main) where + +#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 + +import Foreign.C.String (peekCWString) +import Foreign.C.Types (CWchar) +import Foreign.Marshal.Alloc (allocaBytes) +import Foreign.Ptr (Ptr) + +foreign import WINDOWS_CCONV "hello" c_hello :: Ptr CWchar -> IO () + +main :: IO () +main = allocaBytes 12 $ \buf -> do + c_hello buf + str <- peekCWString buf + putStrLn str ===================================== testsuite/tests/ffi/should_run/T22159.stdout ===================================== @@ -0,0 +1 @@ +hello ===================================== testsuite/tests/ffi/should_run/T22159_c.c ===================================== @@ -0,0 +1,6 @@ +#include +#include + +void hello(wchar_t *buf) { + swprintf_s(buf, 12, L"hello"); +} ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -229,3 +229,8 @@ test('T19237', normal, compile_and_run, ['T19237_c.c']) test('T21305', omit_ways(['ghci']), multi_compile_and_run, ['T21305', [('T21305_cmm.cmm', '')], '']) + +test('T22159', + [unless(opsys('mingw32'), skip), + extra_files(['T22159_c.c'])], + makefile_test, ['T22159']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e599f1b215cbf3a4c43a0cdee2e308330a759c8...5060f11b2bca2bcb052c91dc8eb20664f61c49e0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e599f1b215cbf3a4c43a0cdee2e308330a759c8...5060f11b2bca2bcb052c91dc8eb20664f61c49e0 You're receiving 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 Sep 12 14:31:57 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Sep 2022 10:31:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-interface Message-ID: <631f42dd54b3f_3b59a6195e331436394a@gitlab.mail> Matthew Pickering pushed new branch wip/ghc-interface at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-interface You're receiving 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 Sep 12 14:45:22 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 12 Sep 2022 10:45:22 -0400 Subject: [Git][ghc/ghc][wip/andreask/tidy-94] Fix a nasty loop in Tidy Message-ID: <631f460262b8b_3b59a6195e33143681ec@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/tidy-94 at Glasgow Haskell Compiler / GHC Commits: 0afdddd5 by Simon Peyton Jones at 2022-09-12T16:44:06+02: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] This is the 9.4 packport based on commit 4945953823620b223a0b51b2b1275a1de8f4a851 - - - - - 6 changed files: - compiler/GHC/Core/Tidy.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Types/Id/Info.hs - + testsuite/tests/simplCore/should_compile/T22112.hs - + testsuite/tests/simplCore/should_compile/T22112.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -10,7 +10,7 @@ The code for *top-level* bindings is in GHC.Iface.Tidy. {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Core.Tidy ( - tidyExpr, tidyRules, tidyUnfolding, tidyCbvInfoTop + tidyExpr, tidyRules, tidyCbvInfoTop, tidyBndrs ) where import GHC.Prelude @@ -345,33 +345,36 @@ tidyLetBndr rec_tidy_env env@(tidy_env, var_env) id `setUnfoldingInfo` new_unf old_unf = realUnfoldingInfo old_info - new_unf | isStableUnfolding old_unf = tidyUnfolding rec_tidy_env old_unf old_unf - | otherwise = trimUnfolding old_unf - -- See Note [Preserve evaluatedness] + new_unf = tidyNestedUnfolding rec_tidy_env old_unf in ((tidy_env', var_env'), id') } ------------ Unfolding -------------- -tidyUnfolding :: TidyEnv -> Unfolding -> Unfolding -> Unfolding -tidyUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) _ +tidyNestedUnfolding :: TidyEnv -> Unfolding -> Unfolding +tidyNestedUnfolding _ NoUnfolding = NoUnfolding +tidyNestedUnfolding _ BootUnfolding = BootUnfolding +tidyNestedUnfolding _ (OtherCon {}) = evaldUnfolding + +tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } where (tidy_env', bndrs') = tidyBndrs tidy_env bndrs -tidyUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) - unf_from_rhs +tidyNestedUnfolding tidy_env + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) - - | otherwise - = unf_from_rhs - where seqIt unf = seqUnfolding unf `seq` unf -tidyUnfolding _ unf _ = unf -- NoUnfolding or OtherCon + -- This seqIt avoids a space leak: otherwise the uf_is_value, + -- uf_is_conlike, ... fields may retain a reference to the + -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + + -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] + | is_value = evaldUnfolding + | otherwise = noUnfolding + + where + seqIt unf = seqUnfolding unf `seq` unf {- Note [Tidy IdInfo] ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -28,9 +28,9 @@ import GHC.Core.Unfold.Make import GHC.Core.FVs import GHC.Core.Tidy import GHC.Core.Seq (seqBinds) -import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe ) +import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe, typeArity ) import GHC.Core.InstEnv -import GHC.Core.Type ( tidyTopType ) +import GHC.Core.Type ( tidyTopType, Type ) import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Core.Class @@ -74,6 +74,7 @@ import Data.Function import Data.List ( sortBy, mapAccumL ) import qualified Data.Set as S import GHC.Types.CostCentre +import GHC.Core.Opt.OccurAnal (occurAnalyseExpr) {- Constructing the TypeEnv, Instances, Rules from which the @@ -384,8 +385,7 @@ tidyProgram opts (ModGuts { mg_module = mod (unfold_env, tidy_occ_env) <- chooseExternalIds opts mod binds implicit_binds imp_rules let (trimmed_binds, trimmed_rules) = findExternalRules opts binds imp_rules unfold_env - let uf_opts = opt_unfolding_opts opts - (tidy_env, tidy_binds) <- tidyTopBinds uf_opts unfold_env boot_exports tidy_occ_env trimmed_binds + (tidy_env, tidy_binds) <- tidyTopBinds unfold_env boot_exports tidy_occ_env trimmed_binds -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. (spt_entries, mcstub, tidy_binds') <- case opt_static_ptr_opts opts of @@ -1146,60 +1146,49 @@ tidyTopName mod name_cache maybe_ref occ_env id -- -- * subst_env: A Var->Var mapping that substitutes the new Var for the old -tidyTopBinds :: UnfoldingOpts - -> UnfoldEnv +tidyTopBinds :: UnfoldEnv -> NameSet -> TidyOccEnv -> CoreProgram -> IO (TidyEnv, CoreProgram) -tidyTopBinds uf_opts unfold_env boot_exports init_occ_env binds +tidyTopBinds unfold_env boot_exports init_occ_env binds = do let result = tidy init_env binds seqBinds (snd result) `seq` return result -- This seqBinds avoids a spike in space usage (see #13564) where init_env = (init_occ_env, emptyVarEnv) - tidy = mapAccumL (tidyTopBind uf_opts unfold_env boot_exports) + tidy = mapAccumL (tidyTopBind unfold_env boot_exports) ------------------------ -tidyTopBind :: UnfoldingOpts - -> UnfoldEnv +tidyTopBind :: UnfoldEnv -> NameSet -> TidyEnv -> CoreBind -> (TidyEnv, CoreBind) -tidyTopBind uf_opts unfold_env boot_exports +tidyTopBind unfold_env boot_exports (occ_env,subst1) (NonRec bndr rhs) = (tidy_env2, NonRec bndr' rhs') where - Just (name',show_unfold) = lookupVarEnv unfold_env bndr - (bndr', rhs') = tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (bndr, rhs) + (bndr', rhs') = tidyTopPair unfold_env boot_exports tidy_env2 (bndr, rhs) subst2 = extendVarEnv subst1 bndr bndr' tidy_env2 = (occ_env, subst2) -tidyTopBind uf_opts unfold_env boot_exports (occ_env, subst1) (Rec prs) +tidyTopBind unfold_env boot_exports (occ_env, subst1) (Rec prs) = (tidy_env2, Rec prs') where - prs' = [ tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (id,rhs) - | (id,rhs) <- prs, - let (name',show_unfold) = - expectJust "tidyTopBind" $ lookupVarEnv unfold_env id - ] - - subst2 = extendVarEnvList subst1 (bndrs `zip` map fst prs') + prs' = map (tidyTopPair unfold_env boot_exports tidy_env2) prs + subst2 = extendVarEnvList subst1 (map fst prs `zip` map fst prs') tidy_env2 = (occ_env, subst2) - - bndrs = map fst prs + -- This is where we "tie the knot": tidy_env2 is fed into tidyTopPair ----------------------------------------------------------- -tidyTopPair :: UnfoldingOpts - -> Bool -- show unfolding +tidyTopPair :: UnfoldEnv -> NameSet -> TidyEnv -- The TidyEnv is used to tidy the IdInfo -- It is knot-tied: don't look at it! - -> Name -- New name -> (Id, CoreExpr) -- Binder and RHS before tidying -> (Id, CoreExpr) -- This function is the heart of Step 2 @@ -1208,18 +1197,19 @@ tidyTopPair :: UnfoldingOpts -- group, a variable late in the group might be mentioned -- in the IdInfo of one early in the group -tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) +tidyTopPair unfold_env boot_exports rhs_tidy_env (bndr, rhs) = -- pprTrace "tidyTop" (ppr name' <+> ppr details <+> ppr rhs) $ (bndr1, rhs1) where + Just (name',show_unfold) = lookupVarEnv unfold_env bndr !cbv_bndr = tidyCbvInfoTop boot_exports bndr rhs bndr1 = mkGlobalId details name' ty' idinfo' details = idDetails cbv_bndr -- Preserve the IdDetails ty' = tidyTopType (idType cbv_bndr) rhs1 = tidyExpr rhs_tidy_env rhs - idinfo' = tidyTopIdInfo uf_opts rhs_tidy_env name' rhs rhs1 (idInfo cbv_bndr) - show_unfold + idinfo' = tidyTopIdInfo rhs_tidy_env name' ty' + rhs rhs1 (idInfo cbv_bndr) show_unfold -- tidyTopIdInfo creates the final IdInfo for top-level -- binders. The delicate piece: @@ -1228,9 +1218,9 @@ tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) -- Indeed, CorePrep must eta expand where necessary to make -- the manifest arity equal to the claimed arity. -- -tidyTopIdInfo :: UnfoldingOpts -> TidyEnv -> Name -> CoreExpr -> CoreExpr +tidyTopIdInfo :: TidyEnv -> Name -> Type -> CoreExpr -> CoreExpr -> IdInfo -> Bool -> IdInfo -tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold +tidyTopIdInfo rhs_tidy_env name rhs_ty orig_rhs tidy_rhs idinfo show_unfold | not is_external -- For internal Ids (not externally visible) = vanillaIdInfo -- we only need enough info for code generation -- Arity and strictness info are enough; @@ -1281,13 +1271,17 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold --------- Unfolding ------------ unf_info = realUnfoldingInfo idinfo - unfold_info - | isCompulsoryUnfolding unf_info || show_unfold - = tidyUnfolding rhs_tidy_env unf_info unf_from_rhs - | otherwise - = minimal_unfold_info - minimal_unfold_info = trimUnfolding unf_info - unf_from_rhs = mkFinalUnfolding uf_opts InlineRhs final_sig tidy_rhs + !minimal_unfold_info = trimUnfolding unf_info + + !unfold_info | isCompulsoryUnfolding unf_info || show_unfold + = tidyTopUnfolding rhs_tidy_env tidy_rhs unf_info + | otherwise + = minimal_unfold_info + + -- NB: use `orig_rhs` not `tidy_rhs` in this call to mkFinalUnfolding + -- else you get a black hole (#22122). Reason: mkFinalUnfolding + -- looks at IdInfo, and that is knot-tied in tidyTopBind (the Rec case) + -- NB: do *not* expose the worker if show_unfold is off, -- because that means this thing is a loop breaker or -- marked NOINLINE or something like that @@ -1311,4 +1305,54 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold -- did was to let-bind a non-atomic argument and then float -- it to the top level. So it seems more robust just to -- fix it here. - arity = exprArity orig_rhs + arity = exprArity orig_rhs `min` (length $ typeArity rhs_ty) + + +------------ Unfolding -------------- +tidyTopUnfolding :: TidyEnv -> CoreExpr -> Unfolding -> Unfolding +tidyTopUnfolding _ _ NoUnfolding = NoUnfolding +tidyTopUnfolding _ _ BootUnfolding = BootUnfolding +tidyTopUnfolding _ _ (OtherCon {}) = evaldUnfolding + +tidyTopUnfolding tidy_env _ df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) + = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } + where + (tidy_env', bndrs') = tidyBndrs tidy_env bndrs + +tidyTopUnfolding tidy_env tidy_rhs + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) + = -- See Note [tidyTopUnfolding: avoiding black holes] + unf { uf_tmpl = tidy_unf_rhs } + where + tidy_unf_rhs | isStableSource src + = tidyExpr tidy_env unf_rhs -- Preserves OccInfo in unf_rhs + | otherwise + = occurAnalyseExpr tidy_rhs -- Do occ-anal + +{- Note [tidyTopUnfolding: avoiding black holes] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we are exposing all unfoldings we don't want to tidy the unfolding +twice -- we just want to use the tidied RHS. That tidied RHS itself +contains fully-tidied Ids -- it is knot-tied. So the uf_tmpl for the +unfolding contains stuff we can't look at. Now consider (#22112) + foo = foo +If we freshly compute the uf_is_value field for foo's unfolding, +we'll call `exprIsValue`, which will look at foo's unfolding! +Whether or not the RHS is a value depends on whether foo is a value... +black hole. + +In the Simplifier we deal with this by not giving `foo` an unfolding +in its own RHS. And we could do that here. But it's qite nice +to common everything up to a single Id for foo, used everywhere. + +And it's not too hard: simply leave the unfolding undisturbed, except +tidy the uf_tmpl field. Hence tidyTopUnfolding does + unf { uf_tmpl = tidy_unf_rhs } + +Don't mess with uf_is_value, or guidance; in particular don't recompute +them from tidy_unf_rhs. + +And (unlike tidyNestedUnfolding) don't deep-seq the new unfolding, +because that'll cause a black hole (I /think/ because occurAnalyseExpr +looks in IdInfo). +-} \ No newline at end of file ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -834,7 +834,7 @@ zapFragileUnfolding unf trimUnfolding :: Unfolding -> Unfolding -- Squash all unfolding info, preserving only evaluated-ness trimUnfolding unf | isEvaldUnfolding unf = evaldUnfolding - | otherwise = noUnfolding + | otherwise = noUnfolding zapTailCallInfo :: IdInfo -> Maybe IdInfo zapTailCallInfo info ===================================== testsuite/tests/simplCore/should_compile/T22112.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Rec where + +-- This one created a black hole in Tidy, +-- when creating the tidied unfolding for foo +foo :: () -> () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T22112.stderr ===================================== @@ -0,0 +1,14 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 2, types: 2, coercions: 0, joins: 0/0} + +Rec { +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foo [Occ=LoopBreaker] :: () -> () +[GblId, Str=b, Cpr=b] +foo = foo +end Rec } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -392,5 +392,31 @@ 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('T21144', normal, compile, ['-O']) +# Key here is that the argument to ifoldl' is eta-reduced in Core to +# `/\m. f @(S m)` +# which will erase completely in STG +test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) + +# Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) + +# We expect to see a SPEC rule for $cm +test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) +# We expect to see a SPEC rule for $cm +test('T19644', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) +test('T21391', normal, compile, ['-O -dcore-lint']) +test('T21144', normal, compile, ['-O']) +test('T22112', normal, compile, ['-O -dsuppress-uniques -dno-typeable-binds -ddump-simpl']) +test('T21391a', normal, compile, ['-O -dcore-lint']) +# We don't want to see a thunk allocation for the insertBy expression after CorePrep. +test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]'), expect_broken(21392) ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) +test('T21689', [extra_files(['T21689a.hs'])], multimod_compile, ['T21689', '-v0 -O']) +test('T21801', normal, compile, ['-O -dcore-lint']) +test('T21848', [grep_errmsg(r'SPEC wombat') ], compile, ['-O -ddump-spec']) +test('T21694b', [grep_errmsg(r'Arity=4') ], compile, ['-O -ddump-simpl']) +test('T21960', [grep_errmsg(r'^ Arity=5') ], compile, ['-O2 -ddump-simpl']) +test('T21948', [grep_errmsg(r'^ Arity=5') ], compile, ['-O -ddump-simpl']) +test('T21763', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) +test('T21763a', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0afdddd5e5017050e786bea656d2d740e256f5f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0afdddd5e5017050e786bea656d2d740e256f5f2 You're receiving 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 Sep 12 15:01:47 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 12 Sep 2022 11:01:47 -0400 Subject: [Git][ghc/ghc][wip/jsem] 2 commits: remove -jsemcreate: semaphores should be created externally Message-ID: <631f49dbb18ff_3b59a6d8c86f8370547@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 701cbecd by sheaf at 2022-09-12T17:00:45+02:00 remove -jsemcreate: semaphores should be created externally - - - - - 21bed9d5 by sheaf at 2022-09-12T17:01:15+02:00 jsem: add debouncing - - - - - 3 changed files: - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeSem.hs - compiler/GHC/Driver/Session.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -662,7 +662,7 @@ createBuildPlan mod_graph maybe_top_mod = mkWorkerLimit :: DynFlags -> IO WorkerLimit mkWorkerLimit dflags = case jsemHandle dflags of - Just h -> pure (JSemLimit (SemaphoreName h) (jsemCreate dflags)) + Just h -> pure (JSemLimit (SemaphoreName h)) Nothing -> case parMakeCount dflags of Nothing -> pure $ num_procs 1 Just ParMakeNumProcessors -> num_procs <$> getNumProcessors @@ -682,9 +682,6 @@ data WorkerLimit | JSemLimit SemaphoreName -- ^ Semaphore name to use - (Maybe Int) - -- ^ Create a semaphore with this many tokens, - -- or re-use an existing semaphore? deriving Eq -- | Generalized version of 'load' which also supports a custom @@ -2812,8 +2809,8 @@ runWorkerLimit :: WorkerLimit -> (AbstractSem -> IO a) -> IO a runWorkerLimit worker_limit action = case worker_limit of NumProcessorsLimit n_jobs -> runNjobsAbstractSem n_jobs action - JSemLimit sem mb_create -> - runJSemAbstractSem sem mb_create action + JSemLimit sem -> + runJSemAbstractSem sem action -- | Build and run a pipeline runParPipelines :: WorkerLimit -- ^ How to limit work parallelism ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -34,7 +34,6 @@ import Control.Concurrent.MVar import Control.Concurrent.STM import Data.Foldable import Data.Functor -import Data.Maybe #if defined(mingw32_HOST_OS) import qualified System.Win32.Event as Win32 @@ -42,10 +41,8 @@ import qualified System.Win32.Event as Win32 import qualified System.Win32.Process as Win32 ( iNFINITE ) import qualified System.Win32.Semaphore as Win32 - ( Semaphore(..) - , createSemaphore, releaseSemaphore ) -import qualified System.Win32.Types as Win32 - ( errorWin ) + ( Semaphore(..), sEMAPHORE_ALL_ACCESS + , openSemaphore, releaseSemaphore ) #else import qualified System.Posix.Semaphore as Posix ( Semaphore, OpenSemFlags(..) @@ -82,35 +79,17 @@ newtype SemaphoreName = SemaphoreName FilePath -- | Open a semaphore with the given name. -- --- If no such semaphore exists: --- --- - create one with @toks@ tokens, --- if the second argument is @Just toks@, --- - error, if the second argument is @Nothing at . +-- If no such semaphore exists, throws an error. openSemaphore :: String -- ^ semaphore name - -> Maybe Int -- ^ create a new semaphore with the given number of tokens, - -- or only open an existing semaphore? -> IO Semaphore -openSemaphore sem_name mb_create = +openSemaphore sem_name = #if defined(mingw32_HOST_OS) - do - (sem, exists) <- Win32.createSemaphore Nothing init_toks init_toks (Just sem_name) - unless (isJust mb_create || exists) $ - Win32.errorWin ("jsem: no semaphore " ++ sem_name ++ ", but not allowed to create one") - pprTraceM "openSemaphore" $ - vcat [ text "sem_name:" <+> text sem_name - , text "exists:" <+> ppr exists ] - return sem - where - init_toks = maybe 0 fromIntegral mb_create + Win32.openSemaphore Win32.sEMAPHORE_ALL_ACCESS True sem_name #else - Posix.semOpen sem_name flags Posix.stdFileMode init_toks + Posix.semOpen sem_name flags Posix.stdFileMode 0 where - init_toks = fromMaybe 0 mb_create flags = Posix.OpenSemFlags - { Posix.semCreate = isJust mb_create - -- NB: this ensures we throw an error if no semaphore - -- is found and we're not creating one + { Posix.semCreate = False , Posix.semExclusive = False } #endif @@ -155,6 +134,23 @@ data Jobserver -- obtained from the semaphore } +data JobserverOptions + = JobserverOptions + { releaseDebounce :: !Int + -- ^ Minimum delay, in milliseconds, between acquiring a token + -- and releasing a token. + , setNumCapsDebounce :: !Int + -- ^ Minimum delay, in milliseconds, between two consecutive + -- calls of 'setNumCapabilities'. + } + +defaultJobserverOptions :: JobserverOptions +defaultJobserverOptions = + JobserverOptions + { releaseDebounce = 100 + , setNumCapsDebounce = 100 + } + -- | Resources available for running jobs, i.e. -- tokens obtained from the parallelism semaphore. data JobResources @@ -167,6 +163,7 @@ data JobResources -- ^ Pending jobs waiting on a token } + -- | Add one new token. addToken :: JobResources -> JobResources addToken jobs@( Jobs { tokensOwned = owned, tokensFree = free }) @@ -200,6 +197,19 @@ addJob job jobs@( Jobs { jobsWaiting = wait }) -- | The state of the semaphore job server. data JobserverState + = JobserverState + { jobserverAction :: !JobserverAction + -- ^ The current action being performed by the + -- job server. + , canChangeNumCaps :: !(TVar Bool) + -- ^ A TVar that signals whether it has been long + -- enough since we last changed 'numCapabilities'. + , canReleaseToken :: !(TVar Bool) + -- ^ A TVar that signals whether we last acquired + -- a token long enough ago that we can now release + -- a token. + } +data JobserverAction -- | The jobserver is idle: no thread is currently -- interacting with the semaphore. = Idle @@ -214,7 +224,7 @@ data JobserverState -- | Retrieve the 'TMVar' that signals if the current thread has finished, -- if any thread is currently active in the jobserver. -activeThread_maybe :: JobserverState -> Maybe (TMVar (Maybe MC.SomeException)) +activeThread_maybe :: JobserverAction -> Maybe (TMVar (Maybe MC.SomeException)) activeThread_maybe Idle = Nothing activeThread_maybe (Acquiring { threadFinished = tmvar }) = Just tmvar activeThread_maybe (Releasing { threadFinished = tmvar }) = Just tmvar @@ -309,7 +319,7 @@ modifyJobResources jobs_tvar action = do -- | Spawn a new thread that waits on the semaphore in order to acquire -- an additional token. -acquireThread :: Jobserver -> IO JobserverState +acquireThread :: Jobserver -> IO JobserverAction acquireThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do threadFinished_tmvar <- newEmptyTMVarIO @@ -330,13 +340,14 @@ acquireThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) -- | Spawn a thread to release ownership of one resource from the semaphore, -- provided we have spare resources and no pending jobs. -releaseThread :: Jobserver -> IO JobserverState +releaseThread :: Jobserver -> IO JobserverAction releaseThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do threadFinished_tmvar <- newEmptyTMVarIO MC.mask_ do still_ok_to_release <- atomically $ modifyJobResources jobs_tvar \ jobs -> if guardRelease jobs + -- TODO: should this also debounce? then return (True , removeFreeToken jobs) else return (False, jobs) if not still_ok_to_release @@ -372,15 +383,22 @@ releaseThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do -- spawn a thread to acquire a new token from the semaphore. -- -- See 'acquireThread'. -tryAcquire :: Jobserver +tryAcquire :: JobserverOptions + -> Jobserver -> JobserverState -> STM (IO JobserverState) -tryAcquire sjs@( Jobserver { jobs = jobs_tvar }) Idle +tryAcquire opts js@( Jobserver { jobs = jobs_tvar }) + st@( JobserverState { jobserverAction = Idle } ) = do jobs <- readTVar jobs_tvar guard $ guardAcquire jobs - return $ acquireThread sjs -tryAcquire _ _ = retry + return do + action <- acquireThread js + -- Set a debounce after acquiring a token. + can_release_tvar <- registerDelay $ releaseDebounce opts + return $ st { jobserverAction = action + , canReleaseToken = can_release_tvar } +tryAcquire _ _ _ = retry -- | When there are free tokens and no pending jobs, -- spawn a thread to release a token from the semamphore. @@ -389,43 +407,64 @@ tryAcquire _ _ = retry tryRelease :: Jobserver -> JobserverState -> STM (IO JobserverState) -tryRelease sjs@( Jobserver { jobs = jobs_tvar }) Idle +tryRelease sjs@( Jobserver { jobs = jobs_tvar } ) + st@( JobserverState + { jobserverAction = Idle + , canReleaseToken = can_release_tvar } ) = do jobs <- readTVar jobs_tvar guard $ guardRelease jobs - return $ releaseThread sjs + can_release <- readTVar can_release_tvar + guard can_release + return do + action <- releaseThread sjs + return $ st { jobserverAction = action } tryRelease _ _ = retry -- | Wait for an active thread to finish. Once it finishes: -- --- - set the 'JobserverState' to 'Idle', +-- - set the 'JobserverAction' to 'Idle', -- - update the number of capabilities to reflect the number -- of owned tokens from the semaphore. -tryNoticeIdle :: TVar JobResources +tryNoticeIdle :: JobserverOptions + -> TVar JobResources -> JobserverState -> STM (IO JobserverState) -tryNoticeIdle jobs_tvar jobserver_state - | Just threadFinished_tmvar <- activeThread_maybe jobserver_state - = sync_num_caps threadFinished_tmvar +tryNoticeIdle opts jobs_tvar jobserver_state + | Just threadFinished_tmvar <- activeThread_maybe $ jobserverAction jobserver_state + = sync_num_caps (canChangeNumCaps jobserver_state) threadFinished_tmvar | otherwise = retry -- no active thread: wait until jobserver isn't idle where - sync_num_caps :: TMVar (Maybe MC.SomeException) -> STM (IO JobserverState) - sync_num_caps threadFinished_tmvar = do + sync_num_caps :: TVar Bool + -> TMVar (Maybe MC.SomeException) + -> STM (IO JobserverState) + sync_num_caps can_change_numcaps_tvar threadFinished_tmvar = do mb_ex <- takeTMVar threadFinished_tmvar for_ mb_ex MC.throwM Jobs { tokensOwned } <- readTVar jobs_tvar + can_change_numcaps <- readTVar can_change_numcaps_tvar + guard can_change_numcaps return do x <- getNumCapabilities + can_change_numcaps_tvar_2 <- + if x == tokensOwned + then return can_change_numcaps_tvar + else do + setNumCapabilities tokensOwned + registerDelay $ setNumCapsDebounce opts when (x /= tokensOwned) $ setNumCapabilities tokensOwned - return Idle + return $ + jobserver_state + { jobserverAction = Idle + , canChangeNumCaps = can_change_numcaps_tvar_2 } -- | Try to stop the current thread which is acquiring/releasing resources -- if that operation is no longer relevant. tryStopThread :: TVar JobResources -> JobserverState -> STM (IO JobserverState) -tryStopThread jobs_tvar ls = case ls of +tryStopThread jobs_tvar jsj = case jobserverAction jsj of Acquiring { activeThread = tid } -> do jobs <- readTVar jobs_tvar guard $ null (jobsWaiting jobs) @@ -436,36 +475,50 @@ tryStopThread jobs_tvar ls = case ls of return $ kill_thread_and_idle tid Idle -> retry where - kill_thread_and_idle tid = killThread tid $> Idle + kill_thread_and_idle tid = + killThread tid $> jsj { jobserverAction = Idle } -- | Main jobserver loop: acquire/release resources as -- needed for the pending jobs and available semaphore tokens. -jobserverLoop :: Jobserver -> IO () -jobserverLoop sjs@(Jobserver { jobs = jobs_tvar }) - = loop Idle +jobserverLoop :: JobserverOptions -> Jobserver -> IO () +jobserverLoop opts sjs@(Jobserver { jobs = jobs_tvar }) + = do + true_tvar <- newTVarIO True + let init_state :: JobserverState + init_state = + JobserverState + { jobserverAction = Idle + , canChangeNumCaps = true_tvar + , canReleaseToken = true_tvar } + loop init_state where loop s = do action <- atomically $ asum $ (\x -> x s) <$> [ tryRelease sjs - , tryAcquire sjs - , tryNoticeIdle jobs_tvar + , tryAcquire opts sjs + , tryNoticeIdle opts jobs_tvar , tryStopThread jobs_tvar ] s <- action loop s -- | Create a new jobserver using the given semaphore handle. -makeJobserver :: SemaphoreName -> Maybe Int -> IO (AbstractSem, IO ()) -makeJobserver (SemaphoreName sem_path) mb_create = do - semaphore <- openSemaphore sem_path mb_create +makeJobserver :: SemaphoreName -> IO (AbstractSem, IO ()) +makeJobserver (SemaphoreName sem_path) = do + semaphore <- openSemaphore sem_path let - init_jobs = Jobs { tokensOwned = 1, tokensFree = 1, jobsWaiting = NilOL } + init_jobs = + Jobs { tokensOwned = 1 + , tokensFree = 1 + , jobsWaiting = NilOL + } jobs_tvar <- newTVarIO init_jobs let + opts = defaultJobserverOptions -- TODO: allow this to be configure sjs = Jobserver { semaphore, jobs = jobs_tvar } loop_finished_mvar <- newEmptyMVar loop_tid <- forkIOWithUnmask \ unmask -> do - r <- try $ unmask $ jobserverLoop sjs + r <- try $ unmask $ jobserverLoop opts sjs putMVar loop_finished_mvar $ case r of Left e @@ -489,12 +542,11 @@ makeJobserver (SemaphoreName sem_path) mb_create = do -- | Implement an abstract semaphore using a semaphore 'Jobserver' -- which queries the system semaphore of the given name for resources. runJSemAbstractSem :: SemaphoreName -- ^ the system semaphore to use - -> Maybe Int -- ^ create a semaphore if none exists? -> (AbstractSem -> IO a) -- ^ the operation to run -- which requires a semaphore -> IO a -runJSemAbstractSem sem mb_create action = MC.mask \ unmask -> do - (abs, cleanup) <- makeJobserver sem mb_create +runJSemAbstractSem sem action = MC.mask \ unmask -> do + (abs, cleanup) <- makeJobserver sem r <- try $ unmask $ action abs case r of Left (e1 :: MC.SomeException) -> do ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -466,9 +466,6 @@ data DynFlags = DynFlags { jsemHandle :: Maybe FilePath, -- ^ A handle to a parallelism semaphore - jsemCreate :: Maybe Int, - -- ^ Create a semaphore with the given number of tokens? - -- If 'Nothing', then use an existing semaphore. enableTimeStats :: Bool, -- ^ Enable RTS timing statistics? ghcHeapSize :: Maybe Int, -- ^ The heap size to set. @@ -1155,7 +1152,6 @@ defaultDynFlags mySettings = parMakeCount = Nothing, jsemHandle = Nothing, - jsemCreate = Nothing, enableTimeStats = False, ghcHeapSize = Nothing, @@ -2087,8 +2083,7 @@ dynamic_flags_deps = [ -- as specifying that the number of -- parallel builds is equal to the -- result of getNumProcessors - , make_ord_flag defGhcFlag "jsem" $ hasArg $ \f d -> d { jsemHandle = Just f } - , make_ord_flag defGhcFlag "jsem-create" $ intSuffix $ \i d -> d { jsemCreate = Just i } + , make_ord_flag defGhcFlag "jsem" $ hasArg $ \f d -> d { jsemHandle = Just f } , make_ord_flag defFlag "instantiated-with" (sepArg setUnitInstantiations) , make_ord_flag defFlag "this-component-id" (sepArg setUnitInstanceOf) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d40400534078b9151ceee6d55bf1a89d0f4dff7...21bed9d573ec6fb79c6776e9c27d64732235ebad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d40400534078b9151ceee6d55bf1a89d0f4dff7...21bed9d573ec6fb79c6776e9c27d64732235ebad You're receiving 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 Sep 12 15:04:25 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 12 Sep 2022 11:04:25 -0400 Subject: [Git][ghc/ghc][wip/andreask/tidy-94] Fix a nasty loop in Tidy Message-ID: <631f4a79911d8_3b59a6d8c86083708d1@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/tidy-94 at Glasgow Haskell Compiler / GHC Commits: a8598930 by Simon Peyton Jones at 2022-09-12T17:03:07+02: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] This is the 9.4 packport based on commit 4945953823620b223a0b51b2b1275a1de8f4a851 - - - - - 6 changed files: - compiler/GHC/Core/Tidy.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Types/Id/Info.hs - + testsuite/tests/simplCore/should_compile/T22112.hs - + testsuite/tests/simplCore/should_compile/T22112.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -10,7 +10,7 @@ The code for *top-level* bindings is in GHC.Iface.Tidy. {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Core.Tidy ( - tidyExpr, tidyRules, tidyUnfolding, tidyCbvInfoTop + tidyExpr, tidyRules, tidyCbvInfoTop, tidyBndrs ) where import GHC.Prelude @@ -345,33 +345,36 @@ tidyLetBndr rec_tidy_env env@(tidy_env, var_env) id `setUnfoldingInfo` new_unf old_unf = realUnfoldingInfo old_info - new_unf | isStableUnfolding old_unf = tidyUnfolding rec_tidy_env old_unf old_unf - | otherwise = trimUnfolding old_unf - -- See Note [Preserve evaluatedness] + new_unf = tidyNestedUnfolding rec_tidy_env old_unf in ((tidy_env', var_env'), id') } ------------ Unfolding -------------- -tidyUnfolding :: TidyEnv -> Unfolding -> Unfolding -> Unfolding -tidyUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) _ +tidyNestedUnfolding :: TidyEnv -> Unfolding -> Unfolding +tidyNestedUnfolding _ NoUnfolding = NoUnfolding +tidyNestedUnfolding _ BootUnfolding = BootUnfolding +tidyNestedUnfolding _ (OtherCon {}) = evaldUnfolding + +tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } where (tidy_env', bndrs') = tidyBndrs tidy_env bndrs -tidyUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) - unf_from_rhs +tidyNestedUnfolding tidy_env + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) - - | otherwise - = unf_from_rhs - where seqIt unf = seqUnfolding unf `seq` unf -tidyUnfolding _ unf _ = unf -- NoUnfolding or OtherCon + -- This seqIt avoids a space leak: otherwise the uf_is_value, + -- uf_is_conlike, ... fields may retain a reference to the + -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + + -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] + | is_value = evaldUnfolding + | otherwise = noUnfolding + + where + seqIt unf = seqUnfolding unf `seq` unf {- Note [Tidy IdInfo] ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -24,13 +24,12 @@ import GHC.Tc.Utils.Env import GHC.Core import GHC.Core.Unfold -import GHC.Core.Unfold.Make import GHC.Core.FVs import GHC.Core.Tidy import GHC.Core.Seq (seqBinds) -import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe ) +import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe, typeArity ) import GHC.Core.InstEnv -import GHC.Core.Type ( tidyTopType ) +import GHC.Core.Type ( tidyTopType, Type ) import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Core.Class @@ -74,6 +73,7 @@ import Data.Function import Data.List ( sortBy, mapAccumL ) import qualified Data.Set as S import GHC.Types.CostCentre +import GHC.Core.Opt.OccurAnal (occurAnalyseExpr) {- Constructing the TypeEnv, Instances, Rules from which the @@ -384,8 +384,7 @@ tidyProgram opts (ModGuts { mg_module = mod (unfold_env, tidy_occ_env) <- chooseExternalIds opts mod binds implicit_binds imp_rules let (trimmed_binds, trimmed_rules) = findExternalRules opts binds imp_rules unfold_env - let uf_opts = opt_unfolding_opts opts - (tidy_env, tidy_binds) <- tidyTopBinds uf_opts unfold_env boot_exports tidy_occ_env trimmed_binds + (tidy_env, tidy_binds) <- tidyTopBinds unfold_env boot_exports tidy_occ_env trimmed_binds -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. (spt_entries, mcstub, tidy_binds') <- case opt_static_ptr_opts opts of @@ -1146,60 +1145,49 @@ tidyTopName mod name_cache maybe_ref occ_env id -- -- * subst_env: A Var->Var mapping that substitutes the new Var for the old -tidyTopBinds :: UnfoldingOpts - -> UnfoldEnv +tidyTopBinds :: UnfoldEnv -> NameSet -> TidyOccEnv -> CoreProgram -> IO (TidyEnv, CoreProgram) -tidyTopBinds uf_opts unfold_env boot_exports init_occ_env binds +tidyTopBinds unfold_env boot_exports init_occ_env binds = do let result = tidy init_env binds seqBinds (snd result) `seq` return result -- This seqBinds avoids a spike in space usage (see #13564) where init_env = (init_occ_env, emptyVarEnv) - tidy = mapAccumL (tidyTopBind uf_opts unfold_env boot_exports) + tidy = mapAccumL (tidyTopBind unfold_env boot_exports) ------------------------ -tidyTopBind :: UnfoldingOpts - -> UnfoldEnv +tidyTopBind :: UnfoldEnv -> NameSet -> TidyEnv -> CoreBind -> (TidyEnv, CoreBind) -tidyTopBind uf_opts unfold_env boot_exports +tidyTopBind unfold_env boot_exports (occ_env,subst1) (NonRec bndr rhs) = (tidy_env2, NonRec bndr' rhs') where - Just (name',show_unfold) = lookupVarEnv unfold_env bndr - (bndr', rhs') = tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (bndr, rhs) + (bndr', rhs') = tidyTopPair unfold_env boot_exports tidy_env2 (bndr, rhs) subst2 = extendVarEnv subst1 bndr bndr' tidy_env2 = (occ_env, subst2) -tidyTopBind uf_opts unfold_env boot_exports (occ_env, subst1) (Rec prs) +tidyTopBind unfold_env boot_exports (occ_env, subst1) (Rec prs) = (tidy_env2, Rec prs') where - prs' = [ tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (id,rhs) - | (id,rhs) <- prs, - let (name',show_unfold) = - expectJust "tidyTopBind" $ lookupVarEnv unfold_env id - ] - - subst2 = extendVarEnvList subst1 (bndrs `zip` map fst prs') + prs' = map (tidyTopPair unfold_env boot_exports tidy_env2) prs + subst2 = extendVarEnvList subst1 (map fst prs `zip` map fst prs') tidy_env2 = (occ_env, subst2) - - bndrs = map fst prs + -- This is where we "tie the knot": tidy_env2 is fed into tidyTopPair ----------------------------------------------------------- -tidyTopPair :: UnfoldingOpts - -> Bool -- show unfolding +tidyTopPair :: UnfoldEnv -> NameSet -> TidyEnv -- The TidyEnv is used to tidy the IdInfo -- It is knot-tied: don't look at it! - -> Name -- New name -> (Id, CoreExpr) -- Binder and RHS before tidying -> (Id, CoreExpr) -- This function is the heart of Step 2 @@ -1208,18 +1196,19 @@ tidyTopPair :: UnfoldingOpts -- group, a variable late in the group might be mentioned -- in the IdInfo of one early in the group -tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) +tidyTopPair unfold_env boot_exports rhs_tidy_env (bndr, rhs) = -- pprTrace "tidyTop" (ppr name' <+> ppr details <+> ppr rhs) $ (bndr1, rhs1) where + Just (name',show_unfold) = lookupVarEnv unfold_env bndr !cbv_bndr = tidyCbvInfoTop boot_exports bndr rhs bndr1 = mkGlobalId details name' ty' idinfo' details = idDetails cbv_bndr -- Preserve the IdDetails ty' = tidyTopType (idType cbv_bndr) rhs1 = tidyExpr rhs_tidy_env rhs - idinfo' = tidyTopIdInfo uf_opts rhs_tidy_env name' rhs rhs1 (idInfo cbv_bndr) - show_unfold + idinfo' = tidyTopIdInfo rhs_tidy_env name' ty' + rhs rhs1 (idInfo cbv_bndr) show_unfold -- tidyTopIdInfo creates the final IdInfo for top-level -- binders. The delicate piece: @@ -1228,9 +1217,9 @@ tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) -- Indeed, CorePrep must eta expand where necessary to make -- the manifest arity equal to the claimed arity. -- -tidyTopIdInfo :: UnfoldingOpts -> TidyEnv -> Name -> CoreExpr -> CoreExpr +tidyTopIdInfo :: TidyEnv -> Name -> Type -> CoreExpr -> CoreExpr -> IdInfo -> Bool -> IdInfo -tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold +tidyTopIdInfo rhs_tidy_env name rhs_ty orig_rhs tidy_rhs idinfo show_unfold | not is_external -- For internal Ids (not externally visible) = vanillaIdInfo -- we only need enough info for code generation -- Arity and strictness info are enough; @@ -1281,13 +1270,17 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold --------- Unfolding ------------ unf_info = realUnfoldingInfo idinfo - unfold_info - | isCompulsoryUnfolding unf_info || show_unfold - = tidyUnfolding rhs_tidy_env unf_info unf_from_rhs - | otherwise - = minimal_unfold_info - minimal_unfold_info = trimUnfolding unf_info - unf_from_rhs = mkFinalUnfolding uf_opts InlineRhs final_sig tidy_rhs + !minimal_unfold_info = trimUnfolding unf_info + + !unfold_info | isCompulsoryUnfolding unf_info || show_unfold + = tidyTopUnfolding rhs_tidy_env tidy_rhs unf_info + | otherwise + = minimal_unfold_info + + -- NB: use `orig_rhs` not `tidy_rhs` in this call to mkFinalUnfolding + -- else you get a black hole (#22122). Reason: mkFinalUnfolding + -- looks at IdInfo, and that is knot-tied in tidyTopBind (the Rec case) + -- NB: do *not* expose the worker if show_unfold is off, -- because that means this thing is a loop breaker or -- marked NOINLINE or something like that @@ -1311,4 +1304,54 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold -- did was to let-bind a non-atomic argument and then float -- it to the top level. So it seems more robust just to -- fix it here. - arity = exprArity orig_rhs + arity = exprArity orig_rhs `min` (length $ typeArity rhs_ty) + + +------------ Unfolding -------------- +tidyTopUnfolding :: TidyEnv -> CoreExpr -> Unfolding -> Unfolding +tidyTopUnfolding _ _ NoUnfolding = NoUnfolding +tidyTopUnfolding _ _ BootUnfolding = BootUnfolding +tidyTopUnfolding _ _ (OtherCon {}) = evaldUnfolding + +tidyTopUnfolding tidy_env _ df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) + = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } + where + (tidy_env', bndrs') = tidyBndrs tidy_env bndrs + +tidyTopUnfolding tidy_env tidy_rhs + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) + = -- See Note [tidyTopUnfolding: avoiding black holes] + unf { uf_tmpl = tidy_unf_rhs } + where + tidy_unf_rhs | isStableSource src + = tidyExpr tidy_env unf_rhs -- Preserves OccInfo in unf_rhs + | otherwise + = occurAnalyseExpr tidy_rhs -- Do occ-anal + +{- Note [tidyTopUnfolding: avoiding black holes] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we are exposing all unfoldings we don't want to tidy the unfolding +twice -- we just want to use the tidied RHS. That tidied RHS itself +contains fully-tidied Ids -- it is knot-tied. So the uf_tmpl for the +unfolding contains stuff we can't look at. Now consider (#22112) + foo = foo +If we freshly compute the uf_is_value field for foo's unfolding, +we'll call `exprIsValue`, which will look at foo's unfolding! +Whether or not the RHS is a value depends on whether foo is a value... +black hole. + +In the Simplifier we deal with this by not giving `foo` an unfolding +in its own RHS. And we could do that here. But it's qite nice +to common everything up to a single Id for foo, used everywhere. + +And it's not too hard: simply leave the unfolding undisturbed, except +tidy the uf_tmpl field. Hence tidyTopUnfolding does + unf { uf_tmpl = tidy_unf_rhs } + +Don't mess with uf_is_value, or guidance; in particular don't recompute +them from tidy_unf_rhs. + +And (unlike tidyNestedUnfolding) don't deep-seq the new unfolding, +because that'll cause a black hole (I /think/ because occurAnalyseExpr +looks in IdInfo). +-} \ No newline at end of file ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -834,7 +834,7 @@ zapFragileUnfolding unf trimUnfolding :: Unfolding -> Unfolding -- Squash all unfolding info, preserving only evaluated-ness trimUnfolding unf | isEvaldUnfolding unf = evaldUnfolding - | otherwise = noUnfolding + | otherwise = noUnfolding zapTailCallInfo :: IdInfo -> Maybe IdInfo zapTailCallInfo info ===================================== testsuite/tests/simplCore/should_compile/T22112.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Rec where + +-- This one created a black hole in Tidy, +-- when creating the tidied unfolding for foo +foo :: () -> () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T22112.stderr ===================================== @@ -0,0 +1,14 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 2, types: 2, coercions: 0, joins: 0/0} + +Rec { +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foo [Occ=LoopBreaker] :: () -> () +[GblId, Str=b, Cpr=b] +foo = foo +end Rec } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -392,5 +392,31 @@ 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('T21144', normal, compile, ['-O']) +# Key here is that the argument to ifoldl' is eta-reduced in Core to +# `/\m. f @(S m)` +# which will erase completely in STG +test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) + +# Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) + +# We expect to see a SPEC rule for $cm +test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) +# We expect to see a SPEC rule for $cm +test('T19644', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) +test('T21391', normal, compile, ['-O -dcore-lint']) +test('T21144', normal, compile, ['-O']) +test('T22112', normal, compile, ['-O -dsuppress-uniques -dno-typeable-binds -ddump-simpl']) +test('T21391a', normal, compile, ['-O -dcore-lint']) +# We don't want to see a thunk allocation for the insertBy expression after CorePrep. +test('T21392', [ grep_errmsg(r'sat.* :: \[\(.*Unique, .*Int\)\]'), expect_broken(21392) ], compile, ['-O -ddump-prep -dno-typeable-binds -dsuppress-uniques']) +test('T21689', [extra_files(['T21689a.hs'])], multimod_compile, ['T21689', '-v0 -O']) +test('T21801', normal, compile, ['-O -dcore-lint']) +test('T21848', [grep_errmsg(r'SPEC wombat') ], compile, ['-O -ddump-spec']) +test('T21694b', [grep_errmsg(r'Arity=4') ], compile, ['-O -ddump-simpl']) +test('T21960', [grep_errmsg(r'^ Arity=5') ], compile, ['-O2 -ddump-simpl']) +test('T21948', [grep_errmsg(r'^ Arity=5') ], compile, ['-O -ddump-simpl']) +test('T21763', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) +test('T21763a', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a85989308d975a4871080455936d145f7c9418f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a85989308d975a4871080455936d145f7c9418f5 You're receiving 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 Sep 12 15:15:24 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Sep 2022 11:15:24 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-template-haskell-syntax Message-ID: <631f4d0c622ba_3b59a6d8c86f83730bc@gitlab.mail> Matthew Pickering pushed new branch wip/ghc-template-haskell-syntax at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-template-haskell-syntax You're receiving 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 Sep 12 15:18:01 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Sep 2022 11:18:01 -0400 Subject: [Git][ghc/ghc][wip/ghc-template-haskell-syntax] 2 commits: Split template-haskell into template-haskell-syntax and template-haskell Message-ID: <631f4da95fa8a_3b59a6194ffb50375288@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-template-haskell-syntax at Glasgow Haskell Compiler / GHC Commits: 370b9e48 by Matthew Pickering at 2022-09-12T16:16:32+01:00 Split template-haskell into template-haskell-syntax and template-haskell WIP - - - - - 0d14ae19 by Matthew Pickering at 2022-09-12T16:16:33+01:00 Bump submodule - - - - - 30 changed files: - .gitignore - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Plugins.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Gen/Splice.hs-boot - compiler/GHC/Tc/Types.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Types.hs - compiler/ghc.cabal.in - configure.ac - hadrian/src/Hadrian/Haskell/Cabal.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Hadrian/Haskell/Cabal/Type.hs - hadrian/src/Packages.hs - hadrian/src/Rules/CabalReinstall.hs - hadrian/src/Rules/Selftest.hs - hadrian/src/Rules/Test.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - hadrian/src/Utilities.hs - libraries/bytestring - libraries/exceptions - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/TH.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/ghci/ghci.cabal.in - + libraries/template-haskell-syntax/Language/Haskell/TH.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/97427d5209ecaf2c9f9fbbee02b67998d3e3a2c3...0d14ae19d488a4412fba6923cca0a9943b4a5c7c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/97427d5209ecaf2c9f9fbbee02b67998d3e3a2c3...0d14ae19d488a4412fba6923cca0a9943b4a5c7c You're receiving 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 Sep 12 15:30:07 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 12 Sep 2022 11:30:07 -0400 Subject: [Git][ghc/ghc][wip/jsem] jsem: add debouncing Message-ID: <631f507f64ccc_3b59a619d991943892b@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: c5cc0bc3 by sheaf at 2022-09-12T17:29:55+02:00 jsem: add debouncing - - - - - 1 changed file: - compiler/GHC/Driver/MakeSem.hs Changes: ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -134,6 +134,23 @@ data Jobserver -- obtained from the semaphore } +data JobserverOptions + = JobserverOptions + { releaseDebounce :: !Int + -- ^ Minimum delay, in milliseconds, between acquiring a token + -- and releasing a token. + , setNumCapsDebounce :: !Int + -- ^ Minimum delay, in milliseconds, between two consecutive + -- calls of 'setNumCapabilities'. + } + +defaultJobserverOptions :: JobserverOptions +defaultJobserverOptions = + JobserverOptions + { releaseDebounce = 100 + , setNumCapsDebounce = 100 + } + -- | Resources available for running jobs, i.e. -- tokens obtained from the parallelism semaphore. data JobResources @@ -180,6 +197,19 @@ addJob job jobs@( Jobs { jobsWaiting = wait }) -- | The state of the semaphore job server. data JobserverState + = JobserverState + { jobserverAction :: !JobserverAction + -- ^ The current action being performed by the + -- job server. + , canChangeNumCaps :: !(TVar Bool) + -- ^ A TVar that signals whether it has been long + -- enough since we last changed 'numCapabilities'. + , canReleaseToken :: !(TVar Bool) + -- ^ A TVar that signals whether we last acquired + -- a token long enough ago that we can now release + -- a token. + } +data JobserverAction -- | The jobserver is idle: no thread is currently -- interacting with the semaphore. = Idle @@ -194,7 +224,7 @@ data JobserverState -- | Retrieve the 'TMVar' that signals if the current thread has finished, -- if any thread is currently active in the jobserver. -activeThread_maybe :: JobserverState -> Maybe (TMVar (Maybe MC.SomeException)) +activeThread_maybe :: JobserverAction -> Maybe (TMVar (Maybe MC.SomeException)) activeThread_maybe Idle = Nothing activeThread_maybe (Acquiring { threadFinished = tmvar }) = Just tmvar activeThread_maybe (Releasing { threadFinished = tmvar }) = Just tmvar @@ -289,7 +319,7 @@ modifyJobResources jobs_tvar action = do -- | Spawn a new thread that waits on the semaphore in order to acquire -- an additional token. -acquireThread :: Jobserver -> IO JobserverState +acquireThread :: Jobserver -> IO JobserverAction acquireThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do threadFinished_tmvar <- newEmptyTMVarIO @@ -310,13 +340,14 @@ acquireThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) -- | Spawn a thread to release ownership of one resource from the semaphore, -- provided we have spare resources and no pending jobs. -releaseThread :: Jobserver -> IO JobserverState +releaseThread :: Jobserver -> IO JobserverAction releaseThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do threadFinished_tmvar <- newEmptyTMVarIO MC.mask_ do still_ok_to_release <- atomically $ modifyJobResources jobs_tvar \ jobs -> if guardRelease jobs + -- TODO: should this also debounce? then return (True , removeFreeToken jobs) else return (False, jobs) if not still_ok_to_release @@ -352,15 +383,22 @@ releaseThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do -- spawn a thread to acquire a new token from the semaphore. -- -- See 'acquireThread'. -tryAcquire :: Jobserver +tryAcquire :: JobserverOptions + -> Jobserver -> JobserverState -> STM (IO JobserverState) -tryAcquire sjs@( Jobserver { jobs = jobs_tvar }) Idle +tryAcquire opts js@( Jobserver { jobs = jobs_tvar }) + st@( JobserverState { jobserverAction = Idle } ) = do jobs <- readTVar jobs_tvar guard $ guardAcquire jobs - return $ acquireThread sjs -tryAcquire _ _ = retry + return do + action <- acquireThread js + -- Set a debounce after acquiring a token. + can_release_tvar <- registerDelay $ releaseDebounce opts + return $ st { jobserverAction = action + , canReleaseToken = can_release_tvar } +tryAcquire _ _ _ = retry -- | When there are free tokens and no pending jobs, -- spawn a thread to release a token from the semamphore. @@ -369,43 +407,63 @@ tryAcquire _ _ = retry tryRelease :: Jobserver -> JobserverState -> STM (IO JobserverState) -tryRelease sjs@( Jobserver { jobs = jobs_tvar }) Idle +tryRelease sjs@( Jobserver { jobs = jobs_tvar } ) + st@( JobserverState + { jobserverAction = Idle + , canReleaseToken = can_release_tvar } ) = do jobs <- readTVar jobs_tvar guard $ guardRelease jobs - return $ releaseThread sjs + can_release <- readTVar can_release_tvar + guard can_release + return do + action <- releaseThread sjs + return $ st { jobserverAction = action } tryRelease _ _ = retry -- | Wait for an active thread to finish. Once it finishes: -- --- - set the 'JobserverState' to 'Idle', +-- - set the 'JobserverAction' to 'Idle', -- - update the number of capabilities to reflect the number -- of owned tokens from the semaphore. -tryNoticeIdle :: TVar JobResources +tryNoticeIdle :: JobserverOptions + -> TVar JobResources -> JobserverState -> STM (IO JobserverState) -tryNoticeIdle jobs_tvar jobserver_state - | Just threadFinished_tmvar <- activeThread_maybe jobserver_state - = sync_num_caps threadFinished_tmvar +tryNoticeIdle opts jobs_tvar jobserver_state + | Just threadFinished_tmvar <- activeThread_maybe $ jobserverAction jobserver_state + = sync_num_caps (canChangeNumCaps jobserver_state) threadFinished_tmvar | otherwise = retry -- no active thread: wait until jobserver isn't idle where - sync_num_caps :: TMVar (Maybe MC.SomeException) -> STM (IO JobserverState) - sync_num_caps threadFinished_tmvar = do + sync_num_caps :: TVar Bool + -> TMVar (Maybe MC.SomeException) + -> STM (IO JobserverState) + sync_num_caps can_change_numcaps_tvar threadFinished_tmvar = do mb_ex <- takeTMVar threadFinished_tmvar for_ mb_ex MC.throwM Jobs { tokensOwned } <- readTVar jobs_tvar + can_change_numcaps <- readTVar can_change_numcaps_tvar + guard can_change_numcaps return do x <- getNumCapabilities - when (x /= tokensOwned) $ setNumCapabilities tokensOwned - return Idle + can_change_numcaps_tvar_2 <- + if x == tokensOwned + then return can_change_numcaps_tvar + else do + setNumCapabilities tokensOwned + registerDelay $ setNumCapsDebounce opts + return $ + jobserver_state + { jobserverAction = Idle + , canChangeNumCaps = can_change_numcaps_tvar_2 } -- | Try to stop the current thread which is acquiring/releasing resources -- if that operation is no longer relevant. tryStopThread :: TVar JobResources -> JobserverState -> STM (IO JobserverState) -tryStopThread jobs_tvar ls = case ls of +tryStopThread jobs_tvar jsj = case jobserverAction jsj of Acquiring { activeThread = tid } -> do jobs <- readTVar jobs_tvar guard $ null (jobsWaiting jobs) @@ -416,19 +474,28 @@ tryStopThread jobs_tvar ls = case ls of return $ kill_thread_and_idle tid Idle -> retry where - kill_thread_and_idle tid = killThread tid $> Idle + kill_thread_and_idle tid = + killThread tid $> jsj { jobserverAction = Idle } -- | Main jobserver loop: acquire/release resources as -- needed for the pending jobs and available semaphore tokens. -jobserverLoop :: Jobserver -> IO () -jobserverLoop sjs@(Jobserver { jobs = jobs_tvar }) - = loop Idle +jobserverLoop :: JobserverOptions -> Jobserver -> IO () +jobserverLoop opts sjs@(Jobserver { jobs = jobs_tvar }) + = do + true_tvar <- newTVarIO True + let init_state :: JobserverState + init_state = + JobserverState + { jobserverAction = Idle + , canChangeNumCaps = true_tvar + , canReleaseToken = true_tvar } + loop init_state where loop s = do action <- atomically $ asum $ (\x -> x s) <$> [ tryRelease sjs - , tryAcquire sjs - , tryNoticeIdle jobs_tvar + , tryAcquire opts sjs + , tryNoticeIdle opts jobs_tvar , tryStopThread jobs_tvar ] s <- action @@ -446,10 +513,11 @@ makeJobserver (SemaphoreName sem_path) = do } jobs_tvar <- newTVarIO init_jobs let + opts = defaultJobserverOptions -- TODO: allow this to be configure sjs = Jobserver { semaphore, jobs = jobs_tvar } loop_finished_mvar <- newEmptyMVar loop_tid <- forkIOWithUnmask \ unmask -> do - r <- try $ unmask $ jobserverLoop sjs + r <- try $ unmask $ jobserverLoop opts sjs putMVar loop_finished_mvar $ case r of Left e View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5cc0bc320a34fee0dd27ad965bf929c59425df7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5cc0bc320a34fee0dd27ad965bf929c59425df7 You're receiving 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 Sep 12 17:29:19 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 13:29:19 -0400 Subject: [Git][ghc/ghc][master] ci: enable parallel compression for xz Message-ID: <631f6c6f79893_3b59a6d8c8608418657@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -503,7 +503,7 @@ function build_hadrian() { if [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian build-cabal -V else - run_hadrian binary-dist -V + XZ_OPT="${XZ_OPT:-} -T$cores" run_hadrian binary-dist -V mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" fi View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a5f9c35f5831ef5108e87813a96eac62803852ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a5f9c35f5831ef5108e87813a96eac62803852ab You're receiving 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 Sep 12 17:29:55 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 13:29:55 -0400 Subject: [Git][ghc/ghc][master] Windows: Always define _UCRT when compiling C code Message-ID: <631f6c93945c0_3b59a65198c423946@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 6 changed files: - m4/fp_setup_windows_toolchain.m4 - testsuite/tests/ffi/should_run/Makefile - + testsuite/tests/ffi/should_run/T22159.hs - + testsuite/tests/ffi/should_run/T22159.stdout - + testsuite/tests/ffi/should_run/T22159_c.c - testsuite/tests/ffi/should_run/all.T Changes: ===================================== m4/fp_setup_windows_toolchain.m4 ===================================== @@ -82,7 +82,11 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[ CC="${mingwbin}clang.exe" CXX="${mingwbin}clang++.exe" - cflags="--rtlib=compiler-rt" + + # Signal that we are linking against UCRT with the _UCRT macro. This is + # necessary to ensure correct behavior when MinGW-w64 headers are in the + # header include path (#22159). + cflags="--rtlib=compiler-rt -D_UCRT" CFLAGS="$cflags" CONF_CC_OPTS_STAGE1="$cflags" CONF_CC_OPTS_STAGE2="$cflags" ===================================== testsuite/tests/ffi/should_run/Makefile ===================================== @@ -49,3 +49,10 @@ T15933: '$(TEST_HC)' $(TEST_HC_OPTS) -c T15933.hs '$(TEST_HC)' $(TEST_HC_OPTS) T15933_c.o T15933.o -o T15933 ./T15933 + +.PHONY: T22159 +T22159: + C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) -c T22159.hs + C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) -c T22159_c.c + C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) T22159.o T22159_c.o -o T22159 + ./T22159 ===================================== testsuite/tests/ffi/should_run/T22159.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE CPP #-} +module Main (main) where + +#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 + +import Foreign.C.String (peekCWString) +import Foreign.C.Types (CWchar) +import Foreign.Marshal.Alloc (allocaBytes) +import Foreign.Ptr (Ptr) + +foreign import WINDOWS_CCONV "hello" c_hello :: Ptr CWchar -> IO () + +main :: IO () +main = allocaBytes 12 $ \buf -> do + c_hello buf + str <- peekCWString buf + putStrLn str ===================================== testsuite/tests/ffi/should_run/T22159.stdout ===================================== @@ -0,0 +1 @@ +hello ===================================== testsuite/tests/ffi/should_run/T22159_c.c ===================================== @@ -0,0 +1,6 @@ +#include +#include + +void hello(wchar_t *buf) { + swprintf_s(buf, 12, L"hello"); +} ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -229,3 +229,8 @@ test('T19237', normal, compile_and_run, ['T19237_c.c']) test('T21305', omit_ways(['ghci']), multi_compile_and_run, ['T21305', [('T21305_cmm.cmm', '')], '']) + +test('T22159', + [unless(opsys('mingw32'), skip), + extra_files(['T22159_c.c'])], + makefile_test, ['T22159']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3a815f30bcba5672085e823aeef90863253b0b1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3a815f30bcba5672085e823aeef90863253b0b1a You're receiving 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 Sep 12 20:01:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 16:01:05 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: ci: enable parallel compression for xz Message-ID: <631f9001dd8b5_3b59a6d8c8608469814@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - b99e8ae7 by sheaf at 2022-09-12T16:00:53-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 - - - - - 464b22c0 by sheaf at 2022-09-12T16:00:54-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. - - - - - 3fb2e891 by Cheng Shao at 2022-09-12T16:00:56-04:00 ci: remove unused appveyor config - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − appveyor.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5060f11b2bca2bcb052c91dc8eb20664f61c49e0...3fb2e891ac34caf3f76bd089f70b4582443a6de9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5060f11b2bca2bcb052c91dc8eb20664f61c49e0...3fb2e891ac34caf3f76bd089f70b4582443a6de9 You're receiving 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 Sep 13 02:21:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Sep 2022 22:21:42 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Add diagnostic codes Message-ID: <631fe93635b61_3b59a6194ff95c510257@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1d565e35 by sheaf at 2022-09-12T22:21:19-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 - - - - - c37043d1 by sheaf at 2022-09-12T22:21:20-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. - - - - - 5faa044f by Adam Gundry at 2022-09-12T22:21:22-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. - - - - - f3ac7877 by Cheng Shao at 2022-09-12T22:21:24-04:00 ci: remove unused appveyor config - - - - - 30 changed files: - − .appveyor.sh - − appveyor.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fb2e891ac34caf3f76bd089f70b4582443a6de9...f3ac7877003118467995112a877a072a96cdaa11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fb2e891ac34caf3f76bd089f70b4582443a6de9...f3ac7877003118467995112a877a072a96cdaa11 You're receiving 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 Sep 13 05:12:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 01:12:05 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Add diagnostic codes Message-ID: <63201125e514b_3b59a620aecbec5500a3@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0693cbba by sheaf at 2022-09-13T01:11:42-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 - - - - - 09e18608 by sheaf at 2022-09-13T01:11:43-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. - - - - - 8ad28b5a by Adam Gundry at 2022-09-13T01:11:44-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. - - - - - 70b30a49 by Cheng Shao at 2022-09-13T01:11:47-04:00 ci: remove unused appveyor config - - - - - 021874d3 by Cheng Shao at 2022-09-13T01:11:49-04:00 compiler: remove unused lazy state monad - - - - - 30 changed files: - − .appveyor.sh - − appveyor.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f3ac7877003118467995112a877a072a96cdaa11...021874d3ae144e9ec277ca9c10f8478817084930 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f3ac7877003118467995112a877a072a96cdaa11...021874d3ae144e9ec277ca9c10f8478817084930 You're receiving 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 Sep 13 07:52:26 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 03:52:26 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Add diagnostic codes Message-ID: <632036ba63aa9_3b59a65152c589578@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: dad99396 by sheaf at 2022-09-13T03:52:05-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 - - - - - f286238e by sheaf at 2022-09-13T03:52:05-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. - - - - - ba820f09 by Adam Gundry at 2022-09-13T03:52:06-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. - - - - - a8ae1608 by Cheng Shao at 2022-09-13T03:52:09-04:00 ci: remove unused appveyor config - - - - - cc1baeb9 by Cheng Shao at 2022-09-13T03:52:11-04:00 compiler: remove unused lazy state monad - - - - - 30 changed files: - − .appveyor.sh - − appveyor.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/021874d3ae144e9ec277ca9c10f8478817084930...cc1baeb905caf7011d50dd959e9d3f65f6e9fb82 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/021874d3ae144e9ec277ca9c10f8478817084930...cc1baeb905caf7011d50dd959e9d3f65f6e9fb82 You're receiving 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 Sep 13 08:46:45 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 13 Sep 2022 04:46:45 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: GHC.Utils.Binary: BinDictionary -> FSTable Message-ID: <63204375b6e5f_3b59a6539306186f8@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 7dc26712 by doyougnu at 2022-09-12T05:56:42-04:00 GHC.Utils.Binary: BinDictionary -> FSTable Rename to avoid naming conflict with haddock. - - - - - 08fec920 by doyougnu at 2022-09-13T04:43:37-04:00 JS.Prim: More IndexByteAAs primops - - - - - 4 changed files: - compiler/GHC/Iface/Binary.hs - compiler/GHC/StgToJS/Object.hs - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Iface/Binary.hs ===================================== @@ -235,7 +235,7 @@ putWithTables bh put_payload = do , bin_symtab_map = symtab_map } - (bh_fs, bin_dict, put_dict) <- initBinDictionary bh + (bh_fs, bin_dict, put_dict) <- initFSTable bh (fs_count,(name_count,r)) <- forwardPut bh (const put_dict) $ do @@ -331,7 +331,7 @@ serialiseName bh name _ = do -- See Note [Symbol table representation of names] -putName :: BinDictionary -> BinSymbolTable -> BinHandle -> Name -> IO () +putName :: FSTable -> BinSymbolTable -> BinHandle -> Name -> IO () putName _dict BinSymbolTable{ bin_symtab_map = symtab_map_ref, bin_symtab_next = symtab_next } ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -205,7 +205,7 @@ putObject bh mod_name deps os = do -- object in an archive. put_ bh (moduleNameString mod_name) - (bh_fs, _bin_dict, put_dict) <- initBinDictionary bh + (bh_fs, _bin_dict, put_dict) <- initFSTable bh forwardPut_ bh (const put_dict) $ do put_ bh_fs deps ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1046,20 +1046,6 @@ genPrim prof ty op = case op of ]) (mconcat [r1 |= null_, r2 |= one_]) ] - -- PrimInline $ jVar \t -> mconcat - -- [-- grab the "array" property - -- t |= a .^ "arr" - -- -- make sure we have a non-empty array - -- , ifBlockS (t .&&. t .! i) - -- -- we do, r1 is the ArrayBuffer, r2 is the payload offset - -- [ r1 |= t - -- , r2 |= dv_u32 t i - -- ] - -- -- we don't - -- [ r1 |= null_ - -- , r2 |= zero_ - -- ] - -- ] IndexByteArrayOp_Word8AsFloat -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i IndexByteArrayOp_Word8AsDouble -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i IndexByteArrayOp_Word8AsStablePtr -> \[r1,r2] [a,i] -> @@ -1071,7 +1057,7 @@ genPrim prof ty op = case op of IndexByteArrayOp_Word8AsInt32 -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i IndexByteArrayOp_Word8AsInt64 -> \[h,l] [a,i] -> PrimInline $ mconcat - [ h |= dv_u32 a (Add i (Int 4)) + [ h |= dv_i32 a (Add i (Int 4)) , l |= dv_u32 a i ] IndexByteArrayOp_Word8AsInt -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i @@ -1095,20 +1081,6 @@ genPrim prof ty op = case op of ]) (mconcat [r1 |= null_, r2 |= one_]) ] - -- PrimInline $ jVar \t -> mconcat - -- [-- grab the "array" property - -- t |= a .^ "arr" - -- -- make sure we have a non-empty array - -- , ifBlockS (t .&&. t .! i) - -- -- we do, r1 is the ArrayBuffer, r2 is the payload offset - -- [ r1 |= t - -- , r2 |= dv_u32 t i - -- ] - -- -- we don't - -- [ r1 |= null_ - -- , r2 |= zero_ - -- ] - -- ] ReadByteArrayOp_Word8AsFloat -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i ReadByteArrayOp_Word8AsDouble -> \[r] [a,i] -> PrimInline $ r |= dv_f32 a i ReadByteArrayOp_Word8AsStablePtr -> \[r1,r2] [a,i] -> @@ -1141,15 +1113,6 @@ genPrim prof ty op = case op of , a .^ "arr" .! (i .<<. two_) |= ValExpr (JList [e1, e2]) ] - -- PrimInline $ mconcat - -- [ ifS (Not (a .^ "arr")) - -- -- if we don't have the "arr" property then make it with length 8 - -- -- bytes, 4 for the Addr, 4 for the offset - -- (newByteArray (a .^ "arr") (Int 8)) - -- -- else noop - -- mempty - -- , dv_s_i32 (a .^ "arr") i (ValExpr (JList [e1, e2])) - -- ] WriteByteArrayOp_Word8AsFloat -> \[] [a,i,e] -> PrimInline $ dv_s_f32 a i e WriteByteArrayOp_Word8AsDouble -> \[] [a,i,e] -> PrimInline $ dv_s_f32 a i e WriteByteArrayOp_Word8AsStablePtr -> \[] [a,i,_e1,e2] -> PrimInline $ dv_s_i32 a i e2 @@ -1158,8 +1121,8 @@ genPrim prof ty op = case op of WriteByteArrayOp_Word8AsInt64 -> \[] [a,i,h,l] -> -- JS Numbers are little-endian and 32-bit, so write the lower 4 bytes at i -- then write the higher 4 bytes to i+4 - PrimInline $ mconcat [ dv_s_i32 a (Add i (Int 4)) h - , dv_s_i32 a i l + PrimInline $ mconcat [ dv_s_i32 a (Add i (Int 4)) (i32 h) + , dv_s_u32 a i l ] -- it is probably strange to be using dv_s_i32, and dv_s_i16 when dv_s_u16 and -- dv_s_u32 exist. Unfortunately this is a infelicity of the JS Backend. u32_ ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -77,7 +77,7 @@ module GHC.Utils.Binary -- * String table ("dictionary") putDictionary, getDictionary, putFS, - BinDictionary, initBinDictionary, getDictFastString, putDictFastString, + FSTable, initFSTable, getDictFastString, putDictFastString, ) where import GHC.Prelude @@ -1143,13 +1143,13 @@ getDictFastString dict bh = do return $! (dict ! fromIntegral (j :: Word32)) -initBinDictionary :: BinHandle -> IO (BinHandle, BinDictionary, IO Int) -initBinDictionary bh = do +initFSTable :: BinHandle -> IO (BinHandle, FSTable, IO Int) +initFSTable bh = do dict_next_ref <- newFastMutInt 0 dict_map_ref <- newIORef emptyUFM - let bin_dict = BinDictionary - { bin_dict_next = dict_next_ref - , bin_dict_map = dict_map_ref + let bin_dict = FSTable + { fs_tab_next = dict_next_ref + , fs_tab_map = dict_map_ref } let put_dict = do fs_count <- readFastMutInt dict_next_ref @@ -1164,12 +1164,13 @@ initBinDictionary bh = do return (bh_fs,bin_dict,put_dict) -putDictFastString :: BinDictionary -> BinHandle -> FastString -> IO () +putDictFastString :: FSTable -> BinHandle -> FastString -> IO () putDictFastString dict bh fs = allocateFastString dict fs >>= put_ bh -allocateFastString :: BinDictionary -> FastString -> IO Word32 -allocateFastString BinDictionary { bin_dict_next = j_r, - bin_dict_map = out_r} f = do +allocateFastString :: FSTable -> FastString -> IO Word32 +allocateFastString FSTable { fs_tab_next = j_r + , fs_tab_map = out_r + } f = do out <- readIORef out_r let !uniq = getUnique f case lookupUFM_Directly out uniq of @@ -1180,9 +1181,10 @@ allocateFastString BinDictionary { bin_dict_next = j_r, writeIORef out_r $! addToUFM_Directly out uniq (j, f) return (fromIntegral j :: Word32) -data BinDictionary = BinDictionary { - bin_dict_next :: !FastMutInt, -- The next index to use - bin_dict_map :: !(IORef (UniqFM FastString (Int,FastString))) +-- FSTable is an exact copy of Haddock.InterfaceFile.BinDictionary. We rename to +-- avoid a collision and copy to avoid a dependency. +data FSTable = FSTable { fs_tab_next :: !FastMutInt -- The next index to use + , fs_tab_map :: !(IORef (UniqFM FastString (Int,FastString))) -- indexed by FastString } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee6f41ddb1d8ad45959d0fec5d7f61f1fd0141cd...08fec920f375a1eb8fb88872c569ec47047f0f71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee6f41ddb1d8ad45959d0fec5d7f61f1fd0141cd...08fec920f375a1eb8fb88872c569ec47047f0f71 You're receiving 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 Sep 13 09:08:17 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 13 Sep 2022 05:08:17 -0400 Subject: [Git][ghc/ghc][wip/js-staging] JS.Prim: Prefetch PrimOps are noOps Message-ID: <632048819aa6d_3b59a65152c61884@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: a67f9d94 by doyougnu at 2022-09-13T05:07:42-04:00 JS.Prim: Prefetch PrimOps are noOps - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1207,22 +1207,22 @@ genPrim prof ty op = case op of VecReadScalarOffAddrOp _ _ _ -> unhandledPrimop op VecWriteScalarOffAddrOp _ _ _ -> unhandledPrimop op - PrefetchByteArrayOp3 -> unhandledPrimop op - PrefetchMutableByteArrayOp3 -> unhandledPrimop op - PrefetchAddrOp3 -> unhandledPrimop op - PrefetchValueOp3 -> unhandledPrimop op - PrefetchByteArrayOp2 -> unhandledPrimop op - PrefetchMutableByteArrayOp2 -> unhandledPrimop op - PrefetchAddrOp2 -> unhandledPrimop op - PrefetchValueOp2 -> unhandledPrimop op - PrefetchByteArrayOp1 -> unhandledPrimop op - PrefetchMutableByteArrayOp1 -> unhandledPrimop op - PrefetchAddrOp1 -> unhandledPrimop op - PrefetchValueOp1 -> unhandledPrimop op - PrefetchByteArrayOp0 -> unhandledPrimop op - PrefetchMutableByteArrayOp0 -> unhandledPrimop op - PrefetchAddrOp0 -> unhandledPrimop op - PrefetchValueOp0 -> unhandledPrimop op + PrefetchByteArrayOp3 -> noOp + PrefetchMutableByteArrayOp3 -> noOp + PrefetchAddrOp3 -> noOp + PrefetchValueOp3 -> noOp + PrefetchByteArrayOp2 -> noOp + PrefetchMutableByteArrayOp2 -> noOp + PrefetchAddrOp2 -> noOp + PrefetchValueOp2 -> noOp + PrefetchByteArrayOp1 -> noOp + PrefetchMutableByteArrayOp1 -> noOp + PrefetchAddrOp1 -> noOp + PrefetchValueOp1 -> noOp + PrefetchByteArrayOp0 -> noOp + PrefetchMutableByteArrayOp0 -> noOp + PrefetchAddrOp0 -> noOp + PrefetchValueOp0 -> noOp unhandledPrimop :: PrimOp -> [JExpr] -> [JExpr] -> PrimRes unhandledPrimop op rs as = PrimInline $ mconcat @@ -1237,6 +1237,12 @@ unhandledPrimop op rs as = PrimInline $ mconcat , mconcat $ zipWith (\r reg -> r |= toJExpr reg) rs (enumFrom Ret1) ] +-- | A No Op, used for primops the JS platform cannot or do not support. For +-- example, the prefetching primops do not make sense on the JS platform because +-- we do not have enough control over memory to provide any kind of prefetching +-- mechanism. Hence, these are NoOps. +noOp :: Foldable f => f a -> f a -> PrimRes +noOp = const . const $ PrimInline mempty -- tuple returns appT :: [JExpr] -> FastString -> [JExpr] -> JStat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a67f9d940ce9502cdf478aba34cf8fd218077402 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a67f9d940ce9502cdf478aba34cf8fd218077402 You're receiving 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 Sep 13 09:14:37 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Sep 2022 05:14:37 -0400 Subject: [Git][ghc/ghc][wip/ghc-interface] Don't include BufPos in interface files Message-ID: <632049fde31b0_3b59a6194ff95c61905b@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-interface at Glasgow Haskell Compiler / GHC Commits: 4621c6ac by Matthew Pickering at 2022-09-13T10:14:21+01: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 - - - - - 3 changed files: - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Iface/Ext/Types.hs ===================================== @@ -781,5 +781,5 @@ toHieName name | isKnownKeyName name = KnownKeyName (nameUnique name) | isExternalName name = ExternalName (nameModule name) (nameOccName name) - (nameSrcSpan name) - | otherwise = LocalName (nameOccName name) (nameSrcSpan name) + (removeBufSpan $ nameSrcSpan name) + | otherwise = LocalName (nameOccName name) (removeBufSpan $ nameSrcSpan name) ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -68,6 +68,7 @@ module GHC.Types.SrcLoc ( getBufPos, BufSpan(..), getBufSpan, + removeBufSpan, -- * Located Located, @@ -397,6 +398,10 @@ data UnhelpfulSpanReason | UnhelpfulOther !FastString deriving (Eq, Show) +removeBufSpan :: SrcSpan -> SrcSpan +removeBufSpan (RealSrcSpan s _) = RealSrcSpan s Strict.Nothing +removeBufSpan s = s + {- Note [Why Maybe BufPos] ~~~~~~~~~~~~~~~~~~~~~~~~~~ In SrcLoc we store (Maybe BufPos); in SrcSpan we store (Maybe BufSpan). ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -1312,19 +1312,6 @@ instance Binary RealSrcSpan where return (mkRealSrcSpan (mkRealSrcLoc f sl sc) (mkRealSrcLoc f el ec)) -instance Binary BufPos where - put_ bh (BufPos i) = put_ bh i - get bh = BufPos <$> get bh - -instance Binary BufSpan where - put_ bh (BufSpan start end) = do - put_ bh start - put_ bh end - get bh = do - start <- get bh - end <- get bh - return (BufSpan start end) - instance Binary UnhelpfulSpanReason where put_ bh r = case r of UnhelpfulNoLocationInfo -> putByte bh 0 @@ -1343,10 +1330,11 @@ instance Binary UnhelpfulSpanReason where _ -> UnhelpfulOther <$> get bh instance Binary SrcSpan where - put_ bh (RealSrcSpan ss sb) = do + put_ bh (RealSrcSpan ss _sb) = do putByte bh 0 + -- BufSpan doesn't ever get serialised because the positions depend + -- on build location. put_ bh ss - put_ bh sb put_ bh (UnhelpfulSpan s) = do putByte bh 1 @@ -1356,8 +1344,7 @@ instance Binary SrcSpan where h <- getByte bh case h of 0 -> do ss <- get bh - sb <- get bh - return (RealSrcSpan ss sb) + return (RealSrcSpan ss Strict.Nothing) _ -> do s <- get bh return (UnhelpfulSpan s) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4621c6ac142af0cc175f8e14c63079dd8f4a0332 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4621c6ac142af0cc175f8e14c63079dd8f4a0332 You're receiving 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 Sep 13 09:24:49 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Sep 2022 05:24:49 -0400 Subject: [Git][ghc/ghc][wip/ghc-template-haskell-syntax] fix Message-ID: <63204c61557a2_3b59a6194ffb506194b6@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-template-haskell-syntax at Glasgow Haskell Compiler / GHC Commits: 009caf63 by Matthew Pickering at 2022-09-13T10:24:29+01:00 fix - - - - - 1 changed file: - libraries/template-haskell/template-haskell.cabal.in Changes: ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -61,10 +61,6 @@ Library ghc-options: -Wall - -- We need to set the unit ID to template-haskell (without a - -- version number) as it's magic. - ghc-options: -this-unit-id template-haskell - -- This should match the default-extensions used in 'ghc.cabal'. This way, -- GHCi can be used to load it along with the compiler. Default-Extensions: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/009caf6324f61dbb176e4ae2a6a27cfe8750ce44 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/009caf6324f61dbb176e4ae2a6a27cfe8750ce44 You're receiving 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 Sep 13 09:27:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 05:27:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Allow imports to reference multiple fields with the same name (#21625) Message-ID: <63204d0012e67_3b59a619d99194621237@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cae325b7 by Adam Gundry at 2022-09-13T05:27:15-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. - - - - - 7f31358c by Matthew Pickering at 2022-09-13T05:27:16-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. - - - - - 232fe1c5 by Matthew Pickering at 2022-09-13T05:27:16-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. - - - - - 79dd0b94 by Matthew Pickering at 2022-09-13T05:27:16-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. - - - - - 296be313 by Matthew Pickering at 2022-09-13T05:27:16-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 - - - - - 9e354152 by Matthew Pickering at 2022-09-13T05:27:16-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 - - - - - 2f8257fa by Cheng Shao at 2022-09-13T05:27:18-04:00 ci: remove unused appveyor config - - - - - 12b37549 by Cheng Shao at 2022-09-13T05:27:19-04:00 compiler: remove unused lazy state monad - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − appveyor.yml - compiler/GHC/Rename/Names.hs - − compiler/GHC/Utils/Monad/State/Lazy.hs - compiler/ghc.cabal.in - docs/users_guide/exts/duplicate_record_fields.rst - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Context/Type.hs - hadrian/src/Hadrian/Builder.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Nofib.hs - hadrian/src/Rules/Program.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/Rts.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Rules/Test.hs - hadrian/src/Rules/ToolArgs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc1baeb905caf7011d50dd959e9d3f65f6e9fb82...12b37549763de33b84ef30a8b116d2ff32a5743f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc1baeb905caf7011d50dd959e9d3f65f6e9fb82...12b37549763de33b84ef30a8b116d2ff32a5743f You're receiving 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 Sep 13 10:39:55 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Tue, 13 Sep 2022 06:39:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22166 Message-ID: <63205dfbee909_3b59a6195e3314643951@gitlab.mail> Ryan Scott pushed new branch wip/T22166 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22166 You're receiving 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 Sep 13 11:04:40 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Sep 2022 07:04:40 -0400 Subject: [Git][ghc/ghc][wip/inplace-final] 49 commits: Various Hadrian bootstrapping fixes Message-ID: <632063c88d162_3b59a65152c648390@gitlab.mail> Matthew Pickering pushed to branch wip/inplace-final at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - f9606592 by Matthew Pickering at 2022-09-13T11:04:38+00: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. - - - - - 7f009c1e by Matthew Pickering at 2022-09-13T11:04:38+00: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. - - - - - ec6cd1fc by Matthew Pickering at 2022-09-13T11:04:38+00: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. - - - - - 2ab462a8 by Matthew Pickering at 2022-09-13T11:04:38+00: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 - - - - - ca739b9c by Matthew Pickering at 2022-09-13T11:04:38+00: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 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/CoreToStg/Prep.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/481e568a572852886a564ffec13c7114f198d091...ca739b9cb6ef698b56bebca7be2d44cbb7a62f85 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/481e568a572852886a564ffec13c7114f198d091...ca739b9cb6ef698b56bebca7be2d44cbb7a62f85 You're receiving 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 Sep 13 11:58:00 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 07:58:00 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Add diagnostic codes Message-ID: <632070485b8a4_3b59a620aecc1466853c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 351467b3 by sheaf at 2022-09-13T07:57:36-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 - - - - - 6467e131 by sheaf at 2022-09-13T07:57:37-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. - - - - - fbb2acc6 by Adam Gundry at 2022-09-13T07:57:38-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. - - - - - 66394191 by Cheng Shao at 2022-09-13T07:57:41-04:00 ci: remove unused appveyor config - - - - - 96294453 by Cheng Shao at 2022-09-13T07:57:43-04:00 compiler: remove unused lazy state monad - - - - - 30 changed files: - − .appveyor.sh - − appveyor.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/12b37549763de33b84ef30a8b116d2ff32a5743f...96294453342740023224c3e2f2936143992be0a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/12b37549763de33b84ef30a8b116d2ff32a5743f...96294453342740023224c3e2f2936143992be0a6 You're receiving 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 Sep 13 13:18:55 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 13 Sep 2022 09:18:55 -0400 Subject: [Git][ghc/ghc][wip/js-staging] JS.Primops: Doc explaining lack of vector support Message-ID: <6320833fa7220_3b59a620aecc146917af@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: f5c4cbab by doyougnu at 2022-09-13T09:18:30-04:00 JS.Primops: Doc explaining lack of vector support - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1182,6 +1182,12 @@ genPrim prof ty op = case op of ListThreadsOp -> unhandledPrimop op LabelThreadOp -> unhandledPrimop op -- \[] [t,la,lo] -> PrimInline $ t .^ "label" |= ValExpr (JList [la, lo]) +------------------------------- Vector ----------------------------------------- +-- For now, vectors are unsupported on the JS backend. Simply put, they do not +-- make much sense to support given support for arrays and lack of SIMD support +-- in JS. We could try to roll something special but we would not be able to +-- give any performance guarentees to the user and so we leave these has +-- unhandled for now. VecBroadcastOp _ _ _ -> unhandledPrimop op VecPackOp _ _ _ -> unhandledPrimop op VecUnpackOp _ _ _ -> unhandledPrimop op View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5c4cbabc3f398f4b4be7e1740e4909913da44c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5c4cbabc3f398f4b4be7e1740e4909913da44c9 You're receiving 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 Sep 13 14:28:11 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 10:28:11 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Add diagnostic codes Message-ID: <6320937b33cc_3b59a6194ffb50749628@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Driver/Errors.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Errors/Types.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a815f30bcba5672085e823aeef90863253b0b1a...362cca13858faf7e1158273780ea900e7dad5827 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a815f30bcba5672085e823aeef90863253b0b1a...362cca13858faf7e1158273780ea900e7dad5827 You're receiving 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 Sep 13 14:28:46 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 10:28:46 -0400 Subject: [Git][ghc/ghc][master] Allow imports to reference multiple fields with the same name (#21625) Message-ID: <6320939e7c336_3b59a620aecbec753468@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 7 changed files: - compiler/GHC/Rename/Names.hs - docs/users_guide/exts/duplicate_record_fields.rst - + testsuite/tests/overloadedrecflds/should_compile/T21625.hs - + testsuite/tests/overloadedrecflds/should_compile/T21625B.hs - testsuite/tests/overloadedrecflds/should_compile/all.T - testsuite/tests/overloadedrecflds/should_fail/T16745.stderr - testsuite/tests/overloadedrecflds/should_fail/T16745A.hs Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1165,7 +1165,7 @@ Suppose we have: data T = mkT { foo :: Int } module N where - import M (foo) -- this is an ambiguity error (A) + import M (foo) -- this is allowed (A) import M (S(foo)) -- this is allowed (B) Here M exports the OccName 'foo' twice, so we get an imp_occ_env where 'foo' @@ -1176,8 +1176,8 @@ names (see Note [FieldLabel] in GHC.Types.FieldLabel). , $sel:foo:MKT -> (foo, T(foo), Nothing) ] -Then when we look up 'foo' in lookup_name for case (A) we get both entries and -hence report an ambiguity error. Whereas in case (B) we reach the lookup_ie +Then when we look up 'foo' in lookup_names for case (A) we get both entries and +hence two Avails. Whereas in case (B) we reach the lookup_ie case for IEThingWith, which looks up 'S' and then finds the unique 'foo' amongst its children. @@ -1252,13 +1252,21 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items)) isAvailTC AvailTC{} = True isAvailTC _ = False + -- Look up a RdrName used in an import, failing if it is ambiguous + -- (e.g. because it refers to multiple record fields) lookup_name :: IE GhcPs -> RdrName -> IELookupM (Name, AvailInfo, Maybe Name) - lookup_name ie rdr + lookup_name ie rdr = do + xs <- lookup_names ie rdr + case xs of + [cax] -> return cax + _ -> failLookupWith (AmbiguousImport rdr (map sndOf3 xs)) + + -- Look up a RdrName used in an import, returning multiple values if there + -- are several fields with the same name exposed by the module + lookup_names :: IE GhcPs -> RdrName -> IELookupM [(Name, AvailInfo, Maybe Name)] + lookup_names ie rdr | isQual rdr = failLookupWith (QualImportError rdr) - | Just succ <- mb_success = case nonDetNameEnvElts succ of - -- See Note [Importing DuplicateRecordFields] - [(c,a,x)] -> return (greNameMangledName c, a, x) - xs -> failLookupWith (AmbiguousImport rdr (map sndOf3 xs)) + | Just succ <- mb_success = return $ map (\ (c,a,x) -> (greNameMangledName c, a, x)) (nonDetNameEnvElts succ) | otherwise = failLookupWith (BadImport ie) where mb_success = lookupOccEnv imp_occ_env (rdrNameOcc rdr) @@ -1311,9 +1319,11 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items)) lookup_ie ie = handle_bad_import $ case ie of IEVar _ (L l n) -> do - (name, avail, _) <- lookup_name ie $ ieWrappedName n + -- See Note [Importing DuplicateRecordFields] + xs <- lookup_names ie (ieWrappedName n) return ([(IEVar noExtField (L l (replaceWrappedName n name)), - trimAvail avail name)], []) + trimAvail avail name) + | (name, avail, _) <- xs ], []) IEThingAll _ (L l tc) -> do (name, avail, mb_parent) <- lookup_name ie $ ieWrappedName tc ===================================== docs/users_guide/exts/duplicate_record_fields.rst ===================================== @@ -57,4 +57,11 @@ However, this would not be permitted, because ``x`` is ambiguous: :: module M (x) where ... -The same restrictions apply on imports. +For ``import`` statements, it is possible to import multiple fields with the +same name, as well as importing individual fields as part of their datatypes. +For example, the following imports are allowed: :: + + import M (S(x)) -- imports the type S and the 'x' field of S (but not the field of T) + import M (x) -- imports both 'x' fields + import M hiding (S(x)) -- imports everything except the type S and its 'x' field + import M hiding (x) -- imports everything except the two 'x' fields ===================================== testsuite/tests/overloadedrecflds/should_compile/T21625.hs ===================================== @@ -0,0 +1,5 @@ +module T21625 where + +import T21625B hiding (B, f) + +c = C 'x' ===================================== testsuite/tests/overloadedrecflds/should_compile/T21625B.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE DuplicateRecordFields #-} + +module T21625B where + +data B = B {f :: Int} +data C = C {f :: Char} ===================================== testsuite/tests/overloadedrecflds/should_compile/all.T ===================================== @@ -11,3 +11,4 @@ test('T18999_FieldSelectors', normal, compile, ['']) test('T19154', normal, compile, ['']) test('T20723', normal, compile, ['']) test('T20989', normal, compile, ['']) +test('T21625', [], multimod_compile, ['T21625', '-v0']) ===================================== testsuite/tests/overloadedrecflds/should_fail/T16745.stderr ===================================== @@ -3,12 +3,12 @@ [3 of 4] Compiling T16745D ( T16745D.hs, T16745D.o ) [4 of 4] Compiling T16745A ( T16745A.hs, T16745A.o ) -T16745A.hs:3:24: error: - Ambiguous name ‘field’ in import item. It could refer to: - T16745C.field - T16745B.R(field) - -T16745A.hs:4:24: error: - Ambiguous name ‘foo’ in import item. It could refer to: - T16745D.T(foo) - T16745D.S(foo) +T16745A.hs:8:9: error: + Ambiguous occurrence ‘field’ + It could refer to + either the field ‘field’ of record ‘T16745B.R’, + imported from ‘T16745B’ at T16745A.hs:3:24-28 + (and originally defined at T16745B.hs:11:14-18) + or ‘T16745B.field’, + imported from ‘T16745B’ at T16745A.hs:3:24-28 + (and originally defined in ‘T16745C’ at T16745C.hs:2:1-5) ===================================== testsuite/tests/overloadedrecflds/should_fail/T16745A.hs ===================================== @@ -1,6 +1,8 @@ module T16745A where -import T16745B hiding (field) -import T16745D hiding (foo) +import T16745B (field) -- imports both 'field's +import T16745D hiding (foo) -- allowed, hides both 'foo' fields -wrong = foo -- should not be in scope +foo = foo + +wrong = field -- ambiguous which 'field' is meant View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08f6730cd04ae9cdba30c0e371522ddc9a25b716 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08f6730cd04ae9cdba30c0e371522ddc9a25b716 You're receiving 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 Sep 13 14:29:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 10:29:22 -0400 Subject: [Git][ghc/ghc][master] ci: remove unused appveyor config Message-ID: <632093c25a2e6_3b59a619d9919475722c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - 2 changed files: - − .appveyor.sh - − appveyor.yml Changes: ===================================== .appveyor.sh deleted ===================================== @@ -1,44 +0,0 @@ -# Configure the environment -MSYSTEM=MINGW64 -THREADS=9 -SKIP_PERF_TESTS=YES -BUILD_FLAVOUR= -source /etc/profile || true # a terrible, terrible workaround for msys2 brokenness - -# Don't set -e until after /etc/profile is sourced -set -ex -cd $APPVEYOR_BUILD_FOLDER - -case "$1" in - "prepare") - # Prepare the tree - git config remote.origin.url git://github.com/ghc/ghc.git - git config --global url."git://github.com/ghc/packages-".insteadOf git://github.com/ghc/packages/ - git submodule init - git submodule --quiet update --recursive - ;; - "build") - # Build the compiler - ./boot - cat <> mk/build.mk - BuildFlavour=$BUILD_FLAVOUR - ifneq "\$(BuildFlavour)" "" - include mk/flavours/\$(BuildFlavour).mk - endif -EOF - ./configure --enable-tarballs-autodownload - make -j$THREADS - ;; - - "test") - make binary-dist - curl https://ghc-artifacts.s3.amazonaws.com/tools/ghc-artifact-collector-x86_64-windows --output ghc-artifact-collector - ./ghc-artifact-collector *.tar.xz - make test THREADS=$THREADS - ;; - - *) - echo "$0: unknown mode $1" - exit 1 - ;; -esac ===================================== appveyor.yml deleted ===================================== @@ -1,31 +0,0 @@ -version: "{build}" -build_cloud: ghc-gce-cloud -image: GHC-GCE - -build: - verbosity: normal - -environment: - matrix: - - COMPILER: msys2 - PLATFORM: x64 - MSYS2_ARCH: x86_64 - MSYS2_DIR: msys64 - MSYSTEM: MINGW64 - BIT: 64 - -deploy: off - -install: - - cmd: | - SET "PATH=C:\%MSYS2_DIR%\%MSYSTEM%\bin;C:\%MSYS2_DIR%\usr\bin;%PATH%" - bash .appveyor.sh prepare - -build_script: - - bash .appveyor.sh build - - bash .appveyor.sh test - -artifacts: - - path: ghc-windows.zip - name: GHC Windows bindist - type: zip View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c14370d765efb81ead9a80dc5450dc97e3167b6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c14370d765efb81ead9a80dc5450dc97e3167b6e You're receiving 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 Sep 13 14:30:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Sep 2022 10:30:02 -0400 Subject: [Git][ghc/ghc][master] compiler: remove unused lazy state monad Message-ID: <632093ea331f2_3b59a6194ff95c7609eb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 2 changed files: - − compiler/GHC/Utils/Monad/State/Lazy.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Utils/Monad/State/Lazy.hs deleted ===================================== @@ -1,78 +0,0 @@ -{-# LANGUAGE DeriveFunctor #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE PatternSynonyms #-} - --- | A lazy state monad. -module GHC.Utils.Monad.State.Lazy - ( -- * The State monda - State(State) - , state - , evalState - , execState - , runState - -- * Operations - , get - , gets - , put - , modify - ) where - -import GHC.Prelude - -import GHC.Exts (oneShot) - --- | A state monad which is lazy in the state. -newtype State s a = State' { runState' :: s -> (# a, s #) } - deriving (Functor) - -pattern State :: (s -> (# a, s #)) - -> State s a - --- This pattern synonym makes the monad eta-expand, --- which as a very beneficial effect on compiler performance --- See #18202. --- See Note [The one-shot state monad trick] in GHC.Utils.Monad -pattern State m <- State' m - where - State m = State' (oneShot $ \s -> m s) - -instance Applicative (State s) where - pure x = State $ \s -> (# x, s #) - m <*> n = State $ \s -> case runState' m s of - (# f, s' #) -> case runState' n s' of - (# x, s'' #) -> (# f x, s'' #) - -instance Monad (State s) where - m >>= n = State $ \s -> case runState' m s of - (# r, s' #) -> runState' (n r) s' - -state :: (s -> (a, s)) -> State s a -state f = State $ \s -> case f s of - (r, s') -> (# r, s' #) - -get :: State s s -get = State $ \s -> (# s, s #) - -gets :: (s -> a) -> State s a -gets f = State $ \s -> (# f s, s #) - -put :: s -> State s () -put s' = State $ \_ -> (# (), s' #) - -modify :: (s -> s) -> State s () -modify f = State $ \s -> (# (), f s #) - - -evalState :: State s a -> s -> a -evalState s i = case runState' s i of - (# a, _ #) -> a - - -execState :: State s a -> s -> s -execState s i = case runState' s i of - (# _, s' #) -> s' - - -runState :: State s a -> s -> (a, s) -runState s i = case runState' s i of - (# a, s' #) -> (a, s') ===================================== compiler/ghc.cabal.in ===================================== @@ -795,7 +795,6 @@ Library GHC.Utils.Misc GHC.Utils.Monad GHC.Utils.Monad.State.Strict - GHC.Utils.Monad.State.Lazy GHC.Utils.Outputable GHC.Utils.Panic GHC.Utils.Panic.Plain View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc6af9ed87e619d754bfc385df931c81cba6d93a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc6af9ed87e619d754bfc385df931c81cba6d93a You're receiving 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 Sep 13 15:17:09 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 13 Sep 2022 11:17:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/lazier-loops Message-ID: <63209ef5362f7_3b59a65152c782096@gitlab.mail> Sebastian Graf pushed new branch wip/lazier-loops at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/lazier-loops You're receiving 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 Sep 13 15:35:29 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Sep 2022 11:35:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/vendor-filepath-2 Message-ID: <6320a341e670a_3b59a620aecc147859bd@gitlab.mail> Matthew Pickering pushed new branch wip/vendor-filepath-2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/vendor-filepath-2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Sep 13 16:15:54 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Sep 2022 12:15:54 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-hadrian-index Message-ID: <6320acba4f518_3b59a620aecbec7990f6@gitlab.mail> Matthew Pickering pushed new branch wip/bump-hadrian-index at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-hadrian-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 Tue Sep 13 17:03:27 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Sep 2022 13:03:27 -0400 Subject: [Git][ghc/ghc][wip/inplace-final] hadrian: Add extra implicit dependencies from DeriveLift Message-ID: <6320b7df22b5f_3b59a620aecbec824242@gitlab.mail> Matthew Pickering pushed to branch wip/inplace-final at Glasgow Haskell Compiler / GHC Commits: 112e9b37 by Matthew Pickering at 2022-09-13T18:02:11+01: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. - - - - - 2 changed files: - hadrian/src/Oracles/ModuleFiles.hs - hadrian/src/Rules/Dependencies.hs Changes: ===================================== hadrian/src/Oracles/ModuleFiles.hs ===================================== @@ -2,7 +2,7 @@ module Oracles.ModuleFiles ( decodeModule, encodeModule, findGenerator, hsSources, hsObjects, determineBuilder, - moduleFilesOracle + moduleFilesOracle, moduleSource ) where import qualified Data.HashMap.Strict as Map ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -12,15 +12,42 @@ import Rules.Generate import Settings import Target import Utilities +import Packages +import qualified Data.Map as M import qualified Text.Parsec as Parsec +-- These modules use DeriveLift which needs Language.Haskell.TH.Lib.Internal but +-- the dependency is implicit. ghc -M should emit this additional dependency but +-- until it does we need to add this dependency ourselves. +extra_dependencies :: M.Map Package (Stage -> Action [(FilePath, FilePath)]) +extra_dependencies = + M.fromList [(containers, fmap sequence (sequence + [dep (containers, "Data.IntSet.Internal") th_internal + ,dep (containers, "Data.Set.Internal") th_internal + ,dep (containers, "Data.Sequence.Internal") th_internal + ,dep (containers, "Data.Graph") th_internal + ])) + ] + + where + th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") + dep (p1, m1) (p2, m2) s = (,) <$> path s p1 m1 <*> path s p2 m2 + path stage p m = + let context = Context stage p vanilla Inplace + in objectPath context . moduleSource $ m + +formatExtra :: (FilePath, FilePath) -> String +formatExtra (fp1, fp2) = fp1 ++ ":" ++ fp2 ++ "\n" + buildPackageDependencies :: [(Resource, Int)] -> Rules () buildPackageDependencies rs = do root <- buildRootRules root -/- "**/.dependencies.mk" %> \mk -> do DepMkFile stage pkgpath <- getDepMkFile root mk - let context = Context stage (unsafeFindPackageByPath pkgpath) vanilla Inplace + let pkg = unsafeFindPackageByPath pkgpath + context = Context stage pkg vanilla Inplace + extra <- maybe (return []) ($ stage) $ M.lookup pkg extra_dependencies srcs <- hsSources context gens <- interpretInContext context generatedDependencies need (srcs ++ gens) @@ -28,6 +55,7 @@ buildPackageDependencies rs = do then writeFileChanged mk "" else buildWithResources rs $ target context (Ghc FindHsDependencies $ Context.stage context) srcs [mk] + liftIO $ mapM_ (appendFile mk . formatExtra) extra removeFile $ mk <.> "bak" root -/- "**/.dependencies" %> \deps -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/112e9b37117a7c3d7ac291bea9496b01792c8aa2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/112e9b37117a7c3d7ac291bea9496b01792c8aa2 You're receiving 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 Sep 13 22:24:37 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 13 Sep 2022 18:24:37 -0400 Subject: [Git][ghc/ghc][wip/T21623] Start work Message-ID: <632103251a607_3b59a6194ffb508637d2@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 5fbc43a5 by Simon Peyton Jones at 2022-09-13T23:24:25+01: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 - - - - - 16 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/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fbc43a597387c2df50549b48b9f720dc27e471d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fbc43a597387c2df50549b48b9f720dc27e471d You're receiving 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 Sep 14 00:34:24 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Tue, 13 Sep 2022 20:34:24 -0400 Subject: [Git][ghc/ghc][wip/bump-hadrian-index] 33 commits: Refine in-tree compiler args for --test-compiler=stage1 Message-ID: <632121909b366_3b59a6d8c860887587d@gitlab.mail> sheaf pushed to branch wip/bump-hadrian-index at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 4088e315 by Matthew Pickering at 2022-09-14T00:34:21+00: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 - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - − appveyor.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/CmmToLlvm/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/CoreToStg/Prep.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/35f9312e5c03d745b7cc42edf6250c4cda794b40...4088e315cc3e4d42b26d56d085873791d5864601 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/35f9312e5c03d745b7cc42edf6250c4cda794b40...4088e315cc3e4d42b26d56d085873791d5864601 You're receiving 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 Sep 14 00:58:13 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Tue, 13 Sep 2022 20:58:13 -0400 Subject: [Git][ghc/ghc][wip/T21623] 16 commits: Export liftA2 from Prelude Message-ID: <63212725a5021_3b59a6194ff95c8762d@gitlab.mail> sheaf pushed to branch wip/T21623 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 - - - - - f052b555 by Simon Peyton Jones at 2022-09-14T02:57:49+02: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 - - - - - 18 changed files: - − .appveyor.sh - .gitlab/ci.sh - − appveyor.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/Builtin/primops.txt.pp - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fbc43a597387c2df50549b48b9f720dc27e471d...f052b55546d8a026417e3f2f1096ef521746d712 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fbc43a597387c2df50549b48b9f720dc27e471d...f052b55546d8a026417e3f2f1096ef521746d712 You're receiving 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 Sep 14 05:03:59 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 01:03:59 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Add diagnostic codes Message-ID: <632160bf13393_3b59a6195e33148875c7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - ffe49f19 by Eric Lindblad at 2022-09-14T01:03:42-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - a2b708ad by Matthew Pickering at 2022-09-14T01:03:44-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 - - - - - 30 changed files: - − .appveyor.sh - − appveyor.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Base.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96294453342740023224c3e2f2936143992be0a6...a2b708ad73930ad8670a07f16423e37900b6b709 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96294453342740023224c3e2f2936143992be0a6...a2b708ad73930ad8670a07f16423e37900b6b709 You're receiving 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 Sep 14 07:14:12 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 03:14:12 -0400 Subject: [Git][ghc/ghc][master] Fix typos Message-ID: <63217f44ad79e_3b59a6194ff95c905465@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Base.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/646d15ad8f1119f339998ee8dd79ea96cfd1d165 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/646d15ad8f1119f339998ee8dd79ea96cfd1d165 You're receiving 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 Sep 14 07:14:50 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 03:14:50 -0400 Subject: [Git][ghc/ghc][master] hadrian: Bump index state Message-ID: <63217f6acec4_3b59a65152c9127f6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 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-09-10T18:46:55Z -- 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/7d7e71b03f4b2eb693f5ea69dadbccf491e7403f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d7e71b03f4b2eb693f5ea69dadbccf491e7403f You're receiving 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 Sep 14 09:25:49 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 14 Sep 2022 05:25:49 -0400 Subject: [Git][ghc/ghc][wip/T21623] 3 commits: Fix typos Message-ID: <63219e1dd4d08_3b59a6195e33149528db@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 770f2de9 by Simon Peyton Jones at 2022-09-14T08:27:51+01: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 - - - - - 30 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/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Base.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.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/f052b55546d8a026417e3f2f1096ef521746d712...770f2de936af9e5807af7bc2cc266a004a59de7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f052b55546d8a026417e3f2f1096ef521746d712...770f2de936af9e5807af7bc2cc266a004a59de7f You're receiving 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 Sep 14 09:32:05 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 14 Sep 2022 05:32:05 -0400 Subject: [Git][ghc/ghc][wip/js-staging] JS.Prim: add CAS and Fetch Ops Message-ID: <63219f9574d2e_3b59a619d991949554e6@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 0fda1b72 by doyougnu at 2022-09-14T05:30:41-04:00 JS.Prim: add CAS and Fetch Ops - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1139,27 +1139,73 @@ genPrim prof ty op = case op of ] WriteByteArrayOp_Word8AsWord -> \[] [a,i,e] -> PrimInline $ dv_s_u32 a i (i32 e) - CasByteArrayOp_Int8 -> unhandledPrimop op - CasByteArrayOp_Int16 -> unhandledPrimop op - CasByteArrayOp_Int32 -> unhandledPrimop op - CasByteArrayOp_Int64 -> unhandledPrimop op + CasByteArrayOp_Int8 -> \[r] [a,i,old,new] -> PrimInline $ casOp u8_ r a i old new + CasByteArrayOp_Int16 -> \[r] [a,i,old,new] -> PrimInline $ casOp u1_ r a i old new + CasByteArrayOp_Int32 -> \[r] [a,i,old,new] -> PrimInline $ casOp i32_ r a i old new + + CasByteArrayOp_Int64 -> \[r_h,r_l] [a,i,old_h,old_l,new_h,new_l] -> PrimInline $ + jVar \t_h t_l -> mconcat [ t_h |= i32_ a (Add (i .<<. one_) one_) + , t_l |= i32_ a (i .<<. one_) + , r_h |= t_h + , r_l |= t_l + , ifS (t_l .===. old_l) -- small optimization, check low bits first, fail fast + (ifBlockS (t_h .===. old_h) + -- Pre-Condition is good, do the write + [ i32_ a (Add (i .<<. one_) one_) |= new_h + , i32_ a (i .<<. one_) |= i32 new_l + ] + -- no good, don't write + mempty) + mempty + ] + InterlockedExchange_Addr -> unhandledPrimop op InterlockedExchange_Word -> unhandledPrimop op - CasAddrOp_Addr -> unhandledPrimop op - CasAddrOp_Word -> unhandledPrimop op - CasAddrOp_Word8 -> unhandledPrimop op - CasAddrOp_Word16 -> unhandledPrimop op - CasAddrOp_Word32 -> unhandledPrimop op - CasAddrOp_Word64 -> unhandledPrimop op - - FetchAddAddrOp_Word -> unhandledPrimop op - FetchSubAddrOp_Word -> unhandledPrimop op - FetchAndAddrOp_Word -> unhandledPrimop op - FetchNandAddrOp_Word -> unhandledPrimop op - FetchOrAddrOp_Word -> unhandledPrimop op - FetchXorAddrOp_Word -> unhandledPrimop op + CasAddrOp_Addr -> \[r_a,r_o] [a1,o1,a2,o2,a3,o3] -> PrimInline $ + mconcat [ ifS (app "h$comparePointer" [a1,o1,a2,o2]) + (appS "h$memcpy" [a3,o3,a1,o1,8]) + mempty + , r_a |= a1 + , r_o |= o1 + ] + CasAddrOp_Word -> \[r] [a,o,old,new] -> PrimInline $ + mconcat [ r |= u32_ a o + , ifS (r .===. old) + -- use i32_ instead of u32_, u32_ cannot be used for writing due to + -- hard coded conversion to word using (.>>>. zero_). You see we still + -- do the same convnersion but on the value to write + (i32_ a o |= (new .>>>. zero_)) + mempty + ] + + CasAddrOp_Word8 -> \[r] [a,o,old,new] -> PrimInline $ casOp u8_ r a o old new + CasAddrOp_Word16 -> \[r] [a,o,old,new] -> PrimInline $ casOp u1_ r a o old new + CasAddrOp_Word32 -> \[r] [a,o,old,new] -> PrimInline $ + mconcat [ r |= u32_ a o + , ifS (r .===. old) + (i32_ a o |= (new .>>>. zero_)) + mempty + ] + CasAddrOp_Word64 -> \[r_h,r_l] [a,o,old_h,old_l,new_h,new_l] -> PrimInline $ + mconcat [ r_h |= dv_u32 a (Add o (Int 4)) + , r_l |= dv_u32 a o + , ifS (r_l .===. old_l) + (ifBlockS (r_h .===. old_h) + [ dv_s_u32 a (Add o (Int 4)) new_h + , dv_s_u32 a o new_l + ] + mempty) + mempty + ] + + FetchAddAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr Add r a o v + FetchSubAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr Sub r a o v + FetchAndAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BAnd r a o v + FetchNandAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr ((BNot .) . BAnd) r a o v + FetchOrAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BOr r a o v + FetchXorAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BXor r a o v AtomicReadAddrOp_Word -> unhandledPrimop op AtomicWriteAddrOp_Word -> unhandledPrimop op @@ -1299,6 +1345,26 @@ fetchOpByteArray op tgt src i v = mconcat , i32_ src i |= op tgt v ] +fetchOpAddr :: (JExpr -> JExpr -> JExpr) -> JExpr -> JExpr -> JExpr -> JExpr -> JStat +fetchOpAddr op tgt src i v = mconcat + [ tgt |= src .! i + , src .! i |= op tgt v + ] + +casOp + :: (JExpr -> JExpr -> JExpr) -- view, the view of the ArrayBuffer to use + -> JExpr -- target register to store result + -> JExpr -- source arrays + -> JExpr -- index + -> JExpr -- old value to compare + -> JExpr -- new value to write + -> JStat +casOp view tgt src i old new = mconcat [ tgt |= view src i + , ifS (tgt .===. old) + (view src i |= new) + mempty + ] + -------------------------------------------------------------------------------- -- Lifted Arrays -------------------------------------------------------------------------------- @@ -1333,6 +1399,10 @@ i32 e = BOr e zero_ -- required because of JS numbers. e>>>0 converts e to a Word32 -- so (-2147483648) >>> 0 = 2147483648 -- and ((-2147483648) >>>0) | 0 = -2147483648 +-- +-- Warning: This function will throw an exception if it ends up on the left side +-- of an assignment. The reason it blows up is because of the bit shift (used +-- for coercion) is illegal on the LHS of an assignment u32 :: JExpr -> JExpr u32 e = e .>>>. zero_ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fda1b720e3278e1d5d47e8360dbbdd089d3a407 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fda1b720e3278e1d5d47e8360dbbdd089d3a407 You're receiving 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 Sep 14 12:28:19 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 14 Sep 2022 08:28:19 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/unused-imports Message-ID: <6321c8e36a47b_3b59a620aecbec1027549@gitlab.mail> Matthew Pickering pushed new branch wip/unused-imports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/unused-imports You're receiving 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 Sep 14 12:40:33 2022 From: gitlab at gitlab.haskell.org (Douglas Wilson (@duog)) Date: Wed, 14 Sep 2022 08:40:33 -0400 Subject: [Git][ghc/ghc][wip/jsem] Add GHC.Utils.IO.Semaphore Message-ID: <6321cbc1b806d_3b59a620aecc1410296f6@gitlab.mail> Douglas Wilson pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: f0faa270 by Douglas Wilson at 2022-09-14T13:39:56+01:00 Add GHC.Utils.IO.Semaphore - - - - - 3 changed files: - compiler/GHC/Driver/MakeSem.hs - + compiler/GHC/Utils/IO/Semaphore.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -1,5 +1,4 @@ {-# LANGUAGE BlockArguments #-} -{-# LANGUAGE CPP #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RecordWildCards #-} @@ -7,16 +6,13 @@ -- -- module GHC.Driver.MakeSem - ( -- * Abstract semaphores - AbstractSem(..) - , withAbstractSem - - -- * System semaphores - , Semaphore, SemaphoreName(..) - - -- * JSem: parallelism semaphore backed + ( -- * JSem: parallelism semaphore backed -- by a system semaphore (Posix/Windows) - , runJSemAbstractSem + runJSemAbstractSem + + , SemaphoreName(..) + -- * Abstract semaphores + , AbstractSem(..), withAbstractSem ) where @@ -24,6 +20,7 @@ import GHC.Prelude import GHC.Conc import GHC.Data.OrdList import GHC.IO.Exception +import GHC.Utils.IO.Semaphore import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Trace @@ -35,88 +32,10 @@ import Control.Concurrent.STM import Data.Foldable import Data.Functor -#if defined(mingw32_HOST_OS) -import qualified System.Win32.Event as Win32 - ( waitForSingleObject ) -import qualified System.Win32.Process as Win32 - ( iNFINITE ) -import qualified System.Win32.Semaphore as Win32 - ( Semaphore(..), sEMAPHORE_ALL_ACCESS - , openSemaphore, releaseSemaphore ) -#else -import qualified System.Posix.Semaphore as Posix - ( Semaphore, OpenSemFlags(..) - , semOpen, semWait, semPost, semGetValue ) -import qualified System.Posix.Files as Posix - ( stdFileMode ) -#endif - --------------------------------------- -- Abstract semaphores --- | Abstraction over the operations of a semaphore, --- allowing usage with -jN or a jobserver. -data AbstractSem = AbstractSem { acquireSem :: IO () - , releaseSem :: IO () - } - -withAbstractSem :: AbstractSem -> IO b -> IO b -withAbstractSem sem = MC.bracket_ (acquireSem sem) (releaseSem sem) - ---------------------------------------- --- System-specific semaphores - -type Semaphore = -#if defined(mingw32_HOST_OS) - Win32.Semaphore -#else - Posix.Semaphore -#endif - --- | The name of a 'Semaphore'. -newtype SemaphoreName = SemaphoreName FilePath - deriving Eq --- | Open a semaphore with the given name. --- --- If no such semaphore exists, throws an error. -openSemaphore :: String -- ^ semaphore name - -> IO Semaphore -openSemaphore sem_name = -#if defined(mingw32_HOST_OS) - Win32.openSemaphore Win32.sEMAPHORE_ALL_ACCESS True sem_name -#else - Posix.semOpen sem_name flags Posix.stdFileMode 0 - where - flags = Posix.OpenSemFlags - { Posix.semCreate = False - , Posix.semExclusive = False } -#endif - --- | Indefinitely wait on a semaphore. -waitOnSemaphore :: Semaphore -> IO () -waitOnSemaphore sem = -#if defined(mingw32_HOST_OS) - void $ Win32.waitForSingleObject (Win32.semaphoreHandle sem) Win32.iNFINITE -#else - Posix.semWait sem -#endif - --- | Release a semaphore: add @n@ to its internal counter, --- and return the semaphore's count before the operation. --- --- NB: the returned value should only be used for debugging, --- not for the main jobserver logic. -releaseSemaphore :: Semaphore -> Int -> IO Int -releaseSemaphore sem n = -#if defined(mingw32_HOST_OS) - fromIntegral <$> Win32.releaseSemaphore sem (fromIntegral n) -#else - do - res <- Posix.semGetValue sem - replicateM_ n (Posix.semPost sem) - return res -#endif --------------------------------------- -- Semaphore jobserver ===================================== compiler/GHC/Utils/IO/Semaphore.hs ===================================== @@ -0,0 +1,96 @@ +{-# LANGUAGE CPP #-} + +module GHC.Utils.IO.Semaphore + ( -- * System semaphores + Semaphore, SemaphoreName(..) + , openSemaphore, waitOnSemaphore, releaseSemaphore + + -- * Abstract semaphores + , AbstractSem(..) + , withAbstractSem + ) where + +import GHC.Prelude +import Control.Monad + +import qualified Control.Monad.Catch as MC + +#if defined(mingw32_HOST_OS) +import qualified System.Win32.Event as Win32 + ( waitForSingleObject ) +import qualified System.Win32.Process as Win32 + ( iNFINITE ) +import qualified System.Win32.Semaphore as Win32 + ( Semaphore(..), sEMAPHORE_ALL_ACCESS + , openSemaphore, releaseSemaphore ) +#else +import qualified System.Posix.Semaphore as Posix + ( Semaphore, OpenSemFlags(..) + , semOpen, semWait, semPost, semGetValue ) +import qualified System.Posix.Files as Posix + ( stdFileMode ) +#endif + +--------------------------------------- +-- System-specific semaphores + +type Semaphore = +#if defined(mingw32_HOST_OS) + Win32.Semaphore +#else + Posix.Semaphore +#endif + +-- | The name of a 'Semaphore'. +newtype SemaphoreName = SemaphoreName FilePath + deriving Eq + +-- | Open a semaphore with the given name. +-- +-- If no such semaphore exists, throws an error. +openSemaphore :: String -- ^ semaphore name + -> IO Semaphore +openSemaphore sem_name = +#if defined(mingw32_HOST_OS) + Win32.openSemaphore Win32.sEMAPHORE_ALL_ACCESS True sem_name +#else + Posix.semOpen sem_name flags Posix.stdFileMode 0 + where + flags = Posix.OpenSemFlags + { Posix.semCreate = False + , Posix.semExclusive = False } +#endif + +-- | Indefinitely wait on a semaphore. +waitOnSemaphore :: Semaphore -> IO () +waitOnSemaphore sem = +#if defined(mingw32_HOST_OS) + void $ Win32.waitForSingleObject (Win32.semaphoreHandle sem) Win32.iNFINITE +#else + Posix.semWait sem +#endif + +-- | Release a semaphore: add @n@ to its internal counter, +-- and return the semaphore's count before the operation. +-- +-- NB: the returned value should only be used for debugging, +-- not for the main jobserver logic. +releaseSemaphore :: Semaphore -> Int -> IO Int +releaseSemaphore sem n = +#if defined(mingw32_HOST_OS) + fromIntegral <$> Win32.releaseSemaphore sem (fromIntegral n) +#else + do + res <- Posix.semGetValue sem + replicateM_ n (Posix.semPost sem) + return res +#endif + +-- | Abstraction over the operations of a semaphore, +-- allowing usage with -jN or a jobserver. +data AbstractSem = AbstractSem { acquireSem :: IO () + , releaseSem :: IO () + } + +withAbstractSem :: AbstractSem -> IO b -> IO b +withAbstractSem sem = MC.bracket_ (acquireSem sem) (releaseSem sem) ===================================== compiler/ghc.cabal.in ===================================== @@ -789,6 +789,7 @@ Library GHC.Utils.FV GHC.Utils.GlobalVars GHC.Utils.IO.Unsafe + GHC.Utils.IO.Semaphore GHC.Utils.Json GHC.Utils.Lexeme GHC.Utils.Logger View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f0faa2703d87d2c97f94acab2a93ebc3bf038a78 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f0faa2703d87d2c97f94acab2a93ebc3bf038a78 You're receiving 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 Sep 14 12:46:51 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 08:46:51 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Fix typos Message-ID: <6321cd3baba75_3b59a620aecc1410323df@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 1ebe6f06 by Matthew Pickering at 2022-09-14T08:46:29-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. - - - - - d5ad9d3b by Matthew Pickering at 2022-09-14T08:46:29-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. - - - - - 8539a331 by Matthew Pickering at 2022-09-14T08:46:29-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. - - - - - 1f695b17 by Matthew Pickering at 2022-09-14T08:46:29-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 - - - - - 8e8d384a by Matthew Pickering at 2022-09-14T08:46:29-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 - - - - - a856a17a by Matthew Pickering at 2022-09-14T08:46:29-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. - - - - - 5af97d69 by Douglas Wilson at 2022-09-14T08:46:31-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Base.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2b708ad73930ad8670a07f16423e37900b6b709...5af97d69fe7fff130e013d621696c925ff853610 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2b708ad73930ad8670a07f16423e37900b6b709...5af97d69fe7fff130e013d621696c925ff853610 You're receiving 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 Sep 14 13:47:18 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Wed, 14 Sep 2022 09:47:18 -0400 Subject: [Git][ghc/ghc][wip/jsem] Add more cross-platform semaphore operations Message-ID: <6321db66386cb_3b59a620aecbec1045492@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 504045ae by sheaf at 2022-09-14T15:45:58+02:00 Add more cross-platform semaphore operations - - - - - 3 changed files: - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/MakeSem.hs - compiler/GHC/Utils/IO/Semaphore.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -662,7 +662,7 @@ createBuildPlan mod_graph maybe_top_mod = mkWorkerLimit :: DynFlags -> IO WorkerLimit mkWorkerLimit dflags = case jsemHandle dflags of - Just h -> pure (JSemLimit (SemaphoreName h)) + Just h -> pure (JSemLimit $ SemaphoreName h) Nothing -> case parMakeCount dflags of Nothing -> pure $ num_procs 1 Just ParMakeNumProcessors -> num_procs <$> getNumProcessors ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -10,9 +10,12 @@ module GHC.Driver.MakeSem -- by a system semaphore (Posix/Windows) runJSemAbstractSem - , SemaphoreName(..) + -- * System semaphores + , Semaphore, SemaphoreName(..) + -- * Abstract semaphores - , AbstractSem(..), withAbstractSem + , AbstractSem(..) + , withAbstractSem ) where @@ -32,11 +35,6 @@ import Control.Concurrent.STM import Data.Foldable import Data.Functor ---------------------------------------- --- Abstract semaphores - - - --------------------------------------- -- Semaphore jobserver @@ -46,7 +44,7 @@ import Data.Functor -- available from the semaphore. data Jobserver = Jobserver - { semaphore :: !Semaphore + { jSemaphore :: !Semaphore -- ^ The semaphore which controls available resources , jobs :: !(TVar JobResources) -- ^ The currently pending jobs, and the resources @@ -185,7 +183,7 @@ releaseJob jobs_tvar -- | Release all tokens owned from the semaphore (to clean up -- the jobserver at the end). cleanupJobserver :: Jobserver -> IO () -cleanupJobserver (Jobserver { semaphore = sem, jobs = jobs_tvar }) +cleanupJobserver (Jobserver { jSemaphore = sem, jobs = jobs_tvar }) = do Jobs { tokensOwned = owned, tokensFree = _free } <- readTVarIO jobs_tvar pprTraceM "cleanupJobserver about to release semaphore tokens:" $ @@ -239,7 +237,7 @@ modifyJobResources jobs_tvar action = do -- | Spawn a new thread that waits on the semaphore in order to acquire -- an additional token. acquireThread :: Jobserver -> IO JobserverAction -acquireThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) +acquireThread (Jobserver { jSemaphore = sem, jobs = jobs_tvar }) = do threadFinished_tmvar <- newEmptyTMVarIO tid <- forkIOWithUnmask \ unmask -> do @@ -260,7 +258,7 @@ acquireThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) -- | Spawn a thread to release ownership of one resource from the semaphore, -- provided we have spare resources and no pending jobs. releaseThread :: Jobserver -> IO JobserverAction -releaseThread (Jobserver { semaphore = sem, jobs = jobs_tvar }) = do +releaseThread (Jobserver { jSemaphore = sem, jobs = jobs_tvar }) = do threadFinished_tmvar <- newEmptyTMVarIO MC.mask_ do still_ok_to_release @@ -422,8 +420,8 @@ jobserverLoop opts sjs@(Jobserver { jobs = jobs_tvar }) -- | Create a new jobserver using the given semaphore handle. makeJobserver :: SemaphoreName -> IO (AbstractSem, IO ()) -makeJobserver (SemaphoreName sem_path) = do - semaphore <- openSemaphore sem_path +makeJobserver sem_name = do + semaphore <- openSemaphore sem_name let init_jobs = Jobs { tokensOwned = 1 @@ -433,7 +431,7 @@ makeJobserver (SemaphoreName sem_path) = do jobs_tvar <- newTVarIO init_jobs let opts = defaultJobserverOptions -- TODO: allow this to be configure - sjs = Jobserver { semaphore, jobs = jobs_tvar } + sjs = Jobserver { jSemaphore = semaphore, jobs = jobs_tvar } loop_finished_mvar <- newEmptyMVar loop_tid <- forkIOWithUnmask \ unmask -> do r <- try $ unmask $ jobserverLoop opts sjs ===================================== compiler/GHC/Utils/IO/Semaphore.hs ===================================== @@ -3,7 +3,11 @@ module GHC.Utils.IO.Semaphore ( -- * System semaphores Semaphore, SemaphoreName(..) - , openSemaphore, waitOnSemaphore, releaseSemaphore + , createSemaphore, openSemaphore + , waitOnSemaphore, tryWaitOnSemaphore + , getSemaphoreValue + , releaseSemaphore + , destroySemaphore -- * Abstract semaphores , AbstractSem(..) @@ -17,66 +21,102 @@ import qualified Control.Monad.Catch as MC #if defined(mingw32_HOST_OS) import qualified System.Win32.Event as Win32 - ( waitForSingleObject ) + ( waitForSingleObject, wAIT_OBJECT_0 ) +import qualified System.Win32.File as Win32 + ( closeHandle ) import qualified System.Win32.Process as Win32 ( iNFINITE ) import qualified System.Win32.Semaphore as Win32 ( Semaphore(..), sEMAPHORE_ALL_ACCESS - , openSemaphore, releaseSemaphore ) + , createSemaphore, openSemaphore, releaseSemaphore ) +import qualified System.Win32.Types as Win32 + ( errorWin ) #else import qualified System.Posix.Semaphore as Posix ( Semaphore, OpenSemFlags(..) - , semOpen, semWait, semPost, semGetValue ) + , semOpen, semWait, semTryWait + , semGetValue, semPost, semUnlink ) import qualified System.Posix.Files as Posix ( stdFileMode ) #endif +--------------------------------------- +-- Abstract semaphores + +-- | Abstraction over the operations of a semaphore, +-- allowing usage with -jN or a jobserver. +data AbstractSem = AbstractSem { acquireSem :: IO () + , releaseSem :: IO () + } + +withAbstractSem :: AbstractSem -> IO b -> IO b +withAbstractSem sem = MC.bracket_ (acquireSem sem) (releaseSem sem) + --------------------------------------- -- System-specific semaphores -type Semaphore = +newtype SemaphoreName = + SemaphoreName { getSemaphoreName :: String } + deriving Eq + +-- | A semaphore (POSIX or Win32). +data Semaphore = + Semaphore + { semaphoreName :: !SemaphoreName + , semaphore :: #if defined(mingw32_HOST_OS) - Win32.Semaphore + !Win32.Semaphore #else - Posix.Semaphore + !Posix.Semaphore #endif - --- | The name of a 'Semaphore'. -newtype SemaphoreName = SemaphoreName FilePath - deriving Eq + } -- | Open a semaphore with the given name. -- -- If no such semaphore exists, throws an error. -openSemaphore :: String -- ^ semaphore name - -> IO Semaphore -openSemaphore sem_name = +openSemaphore :: SemaphoreName -> IO Semaphore +openSemaphore nm@(SemaphoreName sem_name) = do #if defined(mingw32_HOST_OS) - Win32.openSemaphore Win32.sEMAPHORE_ALL_ACCESS True sem_name + sem <- Win32.openSemaphore Win32.sEMAPHORE_ALL_ACCESS True sem_name #else - Posix.semOpen sem_name flags Posix.stdFileMode 0 - where + let flags = Posix.OpenSemFlags { Posix.semCreate = False , Posix.semExclusive = False } + sem <- Posix.semOpen sem_name flags Posix.stdFileMode 0 #endif + return $ + Semaphore + { semaphore = sem + , semaphoreName = nm } -- | Indefinitely wait on a semaphore. waitOnSemaphore :: Semaphore -> IO () -waitOnSemaphore sem = +waitOnSemaphore (Semaphore { semaphore = sem }) = #if defined(mingw32_HOST_OS) void $ Win32.waitForSingleObject (Win32.semaphoreHandle sem) Win32.iNFINITE #else Posix.semWait sem #endif +-- | Try to obtain a token from the semaphore, without blocking. +-- +-- Immediately returns 'False' if no resources are available. +tryWaitOnSemaphore :: Semaphore -> IO Bool +tryWaitOnSemaphore (Semaphore { semaphore = sem }) = +#if defined(mingw32_HOST_OS) + (== Win32.wAIT_OBJECT_0) <$> Win32.waitForSingleObject (Win32.semaphoreHandle sem) 0 +#else + Posix.semTryWait sem +#endif + -- | Release a semaphore: add @n@ to its internal counter, -- and return the semaphore's count before the operation. -- -- NB: the returned value should only be used for debugging, -- not for the main jobserver logic. releaseSemaphore :: Semaphore -> Int -> IO Int -releaseSemaphore sem n = +releaseSemaphore (Semaphore { semaphore = sem }) n = #if defined(mingw32_HOST_OS) fromIntegral <$> Win32.releaseSemaphore sem (fromIntegral n) #else @@ -86,11 +126,52 @@ releaseSemaphore sem n = return res #endif --- | Abstraction over the operations of a semaphore, --- allowing usage with -jN or a jobserver. -data AbstractSem = AbstractSem { acquireSem :: IO () - , releaseSem :: IO () - } +-- | Create a new semaphore with the given name and initial amount of +-- available resources. +-- +-- Throws an error if a semaphore by this name already exists. +createSemaphore :: SemaphoreName -> Int -> IO Semaphore +createSemaphore nm@(SemaphoreName sem_name) init_toks = do +#if defined(mingw32_HOST_OS) + let toks = fromIntegral init_toks + (sem, exists) <- Win32.createSemaphore Nothing toks toks (Just sem_name) + when exists $ + Win32.errorWin ("jsem: semaphore " ++ sem_name ++ " already exists") +#else + let flags = + Posix.OpenSemFlags + { Posix.semCreate = True + , Posix.semExclusive = True } + sem <- Posix.semOpen sem_name flags Posix.stdFileMode init_toks +#endif + return $ + Semaphore + { semaphore = sem + , semaphoreName = nm } -withAbstractSem :: AbstractSem -> IO b -> IO b -withAbstractSem sem = MC.bracket_ (acquireSem sem) (releaseSem sem) +-- | Destroy the given semaphore. +destroySemaphore :: Semaphore -> IO () +destroySemaphore sem = +#if defined(mingw32_HOST_OS) + Win32.closeHandle (Win32.semaphoreHandle $ semaphore sem) +#else + Posix.semUnlink (getSemaphoreName $ semaphoreName sem) +#endif + +-- | Query the current semaphore value (how many tokens it has available). +getSemaphoreValue :: Semaphore -> IO Int +getSemaphoreValue (Semaphore { semaphore = sem }) = +#if defined(mingw32_HOST_OS) + do + wait_res <- Win32.waitForSingleObject (Win32.semaphoreHandle sem) (fromInteger 0) + if wait_res == Win32.wAIT_OBJECT_0 + -- We were able to immediately acquire a resource from the semaphore: + -- release it immediately, thus obtaining the total number of available + -- resources. + then + (+1) . fromIntegral <$> Win32.releaseSemaphore sem 1 + else + return 0 +#else + Posix.semGetValue sem +#endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/504045aeb075a70e5215b380d73e050cab832092 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/504045aeb075a70e5215b380d73e050cab832092 You're receiving 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 Sep 14 14:28:13 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 14 Sep 2022 10:28:13 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/typos2 Message-ID: <6321e4fd681f_3b59a620aecc14105323d@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/typos2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/typos2 You're receiving 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 Sep 14 15:15:00 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 14 Sep 2022 11:15:00 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hackage-bindist Message-ID: <6321eff46df5e_3b59a6194ff95c10697f8@gitlab.mail> Matthew Pickering pushed new branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hackage-bindist You're receiving 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 Sep 14 15:25:23 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 14 Sep 2022 11:25:23 -0400 Subject: [Git][ghc/ghc][wip/typos2] Fix typos Message-ID: <6321f263a1d47_3b59a620aecc141073991@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/typos2 at Glasgow Haskell Compiler / GHC Commits: b52f5936 by Krzysztof Gogolewski at 2022-09-14T17:25:11+02:00 Fix typos - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/LiberateCase.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/RoughMap.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Platform/Ways.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/BaseDir.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b52f59369a7b986e8b3389b30025a3f010b736cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b52f59369a7b986e8b3389b30025a3f010b736cb You're receiving 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 Sep 14 17:01:17 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Wed, 14 Sep 2022 13:01:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-ar-merge Message-ID: <632208dd5eb2c_3b59a620aecc14109108a@gitlab.mail> sheaf pushed new branch wip/hadrian-ar-merge at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-ar-merge You're receiving 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 Sep 14 17:17:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 13:17:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: hadrian: Use a stamp file to record when a package is built in a certain way Message-ID: <63220c993a1d6_3b59a6518381097665@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0ea18f10 by Matthew Pickering at 2022-09-14T13:16:48-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. - - - - - 85d0b2a2 by Matthew Pickering at 2022-09-14T13:16:48-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. - - - - - b1c7517b by Matthew Pickering at 2022-09-14T13:16:48-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. - - - - - f5589760 by Matthew Pickering at 2022-09-14T13:16:48-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 - - - - - cc675044 by Matthew Pickering at 2022-09-14T13:16:48-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 - - - - - 5939b560 by Matthew Pickering at 2022-09-14T13:16:48-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. - - - - - d96ef963 by Greg Steuck at 2022-09-14T13:16:54-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 ``` - - - - - b169e4a2 by Douglas Wilson at 2022-09-14T13:16:55-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - 30 changed files: - .gitlab/ci.sh - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Context/Type.hs - hadrian/src/Hadrian/Builder.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Oracles/ModuleFiles.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Nofib.hs - hadrian/src/Rules/Program.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/Rts.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Rules/Test.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Common.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Builders/GhcPkg.hs - hadrian/src/Settings/Builders/Haddock.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5af97d69fe7fff130e013d621696c925ff853610...b169e4a272479607529e995653c8c55a013146dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5af97d69fe7fff130e013d621696c925ff853610...b169e4a272479607529e995653c8c55a013146dd You're receiving 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 Sep 14 20:39:16 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Sep 2022 16:39:16 -0400 Subject: [Git][ghc/ghc][wip/T20155] Core Lint: Allow global binders when wired-in Message-ID: <63223bf458b5e_3b59a6d8c860811469d6@gitlab.mail> Ben Gamari pushed to branch wip/T20155 at Glasgow Haskell Compiler / GHC Commits: 45def1c4 by Ben Gamari at 2022-09-06T08:43:38-04:00 Core Lint: Allow global binders when wired-in - - - - - 1 changed file: - compiler/GHC/Core/Lint.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1630,7 +1630,7 @@ lintIdBndr :: TopLevelFlag -> BindingSite lintIdBndr top_lvl bind_site id thing_inside = assertPpr (isId id) (ppr id) $ do { flags <- getLintFlags - ; checkL (not (lf_check_global_ids flags) || isLocalId id) + ; checkL (not (lf_check_global_ids flags) || isLocalId id || isWiredIn id) (text "Non-local Id binder" <+> ppr id) -- See Note [Checking for global Ids] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/45def1c4cd79ff649d637e16b823d01e59f77490 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/45def1c4cd79ff649d637e16b823d01e59f77490 You're receiving 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 Sep 14 21:01:00 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Sep 2022 17:01:00 -0400 Subject: [Git][ghc/ghc][wip/bump-llvm] 2788 commits: Document the interaction between ScopedTypeVariables and StandaloneKindSignatures Message-ID: <6322410cedb30_3b59a6518381153563@gitlab.mail> Ben Gamari pushed to branch wip/bump-llvm at Glasgow Haskell Compiler / GHC Commits: 7ea7624c by Ryan Scott at 2021-03-15T00:42:27-04:00 Document the interaction between ScopedTypeVariables and StandaloneKindSignatures This documents a limitation of `StandaloneKindSignatures`—namely, that it does not bring type variables bound by an outermost `forall` into scope over a type-level declaration—in the GHC User's Guide. See #19498 for more discussion. - - - - - 92d98424 by Vladislav Zavialov at 2021-03-15T00:43:05-04:00 Fix record dot precedence (#19521) By moving the handling of TIGHT_INFIX_PROJ to the correct place, we can remove the isGetField hack and fix a bug at the same time. - - - - - 545cfefa by Vladislav Zavialov at 2021-03-15T00:43:05-04:00 Test chained record construction/update/access According to the proposal, we have the following equivalence: e{lbl1 = val1}.val2 == (e{lbl1 = val1}).val2 This is a matter of parsing. Record construction/update must have the same precedence as dot access. Add a test case to ensure this. - - - - - b5b51c54 by Moritz Angermann at 2021-03-16T10:04:23+08:00 [ci] Skip test's on windows that often fail in CI. - - - - - 58cfcc65 by Hécate Moonlight at 2021-03-17T00:57:17-04:00 Make the CI jobs interruptible closes #19362 - - - - - 43a64744 by Moritz Angermann at 2021-03-17T04:16:27-04:00 [ci] don't make marge double build. This fixes !18744 - - - - - f11954b1 by ARATA Mizuki at 2021-03-17T19:05:13-04:00 Add a test for fromInteger :: Integer -> Float/Double (#15926, #17231, #17782) - - - - - 540fa6b2 by ARATA Mizuki at 2021-03-17T19:05:13-04:00 fromInteger :: Integer -> {Float,Double} now always round to nearest even integerToFloat# and integerToDouble# were moved from ghc-bignum to base. GHC.Integer.floatFromInteger and doubleFromInteger were removed. Fixes #15926, #17231, #17782 - - - - - 84927818 by Ben Gamari at 2021-03-17T19:05:50-04:00 llvmGen: Accept range of LLVM versions Previously we would support only one LLVM major version. Here we generalize this to accept a range, taking this range to be LLVM 10 to 11, as 11 is necessary for Apple M1 support. We also accept 12, as that is what apple ships with BigSur on the M1. - - - - - d14a2068 by Sylvain Henry at 2021-03-17T19:06:33-04:00 Enhance pass result forcing When we use `withTiming` we need to force the results of each timed pass to better represent the time spent in each phase. This patch forces some results that weren't before. It also retrieve timings for the CoreToStg and WriteIface passes. - - - - - 665b757f by Ben Gamari at 2021-03-17T19:07:10-04:00 IfaceToType: Ensure that IfaceTyConInfo is shared In #19194 mpickering detailed that there are a LOT of allocations of IfaceTyConInfo: There are just two main cases: IfaceTyConInfo IsPromoted IfaceNormalTyCon and IfaceTyConInfo NotPromoted IfaceNormalTyCon. These should be made into CAFs and shared. From my analysis, the most common case is IfaceTyConInfo NotPromoted IfaceNormalTyCon (53 000) then IfaceTyConInfo IsPromoted IfaceNormalTyCon (28 000). This patch makes it so these are properly shared by using a smart constructor. Fixes #19194. - - - - - 4fbc8558 by Ben Gamari at 2021-03-17T19:07:47-04:00 Eliminate selector thunk allocations - - - - - 42049339 by Ben Gamari at 2021-03-17T19:07:47-04:00 CmmToAsm.Reg.Linear: Make linearRA body a join point Avoid top-level recursion. - - - - - fe6cad22 by Ben Gamari at 2021-03-17T19:07:47-04:00 CmmtoAsm.Reg.Linear: Rewrite process CmmToAsm.Reg.Linear: More strictness More strictness - - - - - 6b10163e by Sylvain Henry at 2021-03-17T19:08:27-04:00 Disable bogus assertion (#19489) - - - - - 26d26974 by Ryan Scott at 2021-03-17T19:09:03-04:00 Document how GADT patterns are matched from left-to-right, outside-in This adds some bullet points to the GHC User's Guide section on `GADTs` to explain some subtleties in how GHC typechecks GADT patterns. In particular, this adds examples of programs being rejected for matching on GADTs in a way that does not mesh with GHC's left-to-right, outside-in order for checking patterns, which can result in programs being rejected for seemingly counterintuitive reasons. (See #12018 for examples of confusion that arose from this.) In addition, now that we have visible type application in data constructor patterns, I mention a possible workaround of using `TypeApplications` to repair programs of this sort. Resolves #12018. - - - - - 30285415 by Vladislav Zavialov at 2021-03-17T19:09:40-04:00 Built-in type families: CharToNat, NatToChar (#19535) Co-authored-by: Daniel Rogozin <daniel.rogozin at serokell.io> Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> - - - - - 0a986685 by Ben Gamari at 2021-03-19T19:58:52-04:00 testsuite: Make --ignore-perf-tests more expressive Allow skipping of only increases/decreases. - - - - - d03d8761 by Ben Gamari at 2021-03-19T19:58:52-04:00 gitlab-ci: Ignore performance improvements in marge jobs Currently we have far too many merge failures due to cumulative performance improvements. Avoid this by accepting metric decreases in marge-bot jobs. Fixes #19562. - - - - - 7d027433 by Gaël Deest at 2021-03-20T07:48:01-04:00 [skip ci] Fix 'Ord' documentation inconsistency Current documentation for the `Ord` typeclass is inconsistent. It simultaneously mentions that: > The 'Ord' class is used for totally ordered datatypes. And: > The Haskell Report defines no laws for 'Ord'. However, '<=' is > customarily expected to implement a non-strict partial order […] The Haskell report (both 98 and 2010 versions) mentions total ordering, which implicitly does define laws. Moreover, `compare :: Ord a => a -> a -> Ordering` and `data Ordering = LT | EQ | GT` imply that the order is indeed total (there is no way to say that two elements are not comparable). This MR fixes the Haddock comment, and adds a comparability law to the list of suggested properties. - - - - - f940fd46 by Alan Zimmerman at 2021-03-20T07:48:37-04:00 Add the main types to be used for exactprint in the GHC AST The MR introducing the API Annotations, !2418 is huge. Conceptually it is two parts, the one deals with introducing the new types to be used for annotations, and outlining how they will be used. This is a small change, localised to compiler/GHC/Parser/Annotation.hs and is contained in this commit. The follow-up, larger commit deals with mechanically working this through the entire AST and updating all the parts affected by it. It is being split so the part that needs good review feedback can be seen in isolation, prior to the rest coming in. - - - - - 95275a5f by Alan Zimmerman at 2021-03-20T07:48:38-04:00 GHC Exactprint main commit Metric Increase: T10370 parsing001 Updates haddock submodule - - - - - adf93721 by GHC GitLab CI at 2021-03-20T07:48:38-04:00 check-ppr,check-exact: Write out result as binary Previously we would use `writeFile` to write the intermediate files to check for round-tripping. However, this will open the output handle as a text handle, which on Windows will change line endings. Avoid this by opening as binary. Explicitly use utf8 encoding. This is for tests only, do not need to worry about user compatibility. - - - - - ceef490b by GHC GitLab CI at 2021-03-20T07:48:38-04:00 testsuite: Normalise slashes In the `comments` and `literals` tests, since they contain file paths. - - - - - dd11f2d5 by Luite Stegeman at 2021-03-20T07:49:15-04:00 Save the type of breakpoints in the Breakpoint tick in STG GHCi needs to know the types of all breakpoints, but it's not possible to get the exprType of any expression in STG. This is preparation for the upcoming change to make GHCi bytecode from STG instead of Core. - - - - - 26328a68 by Luite Stegeman at 2021-03-20T07:49:15-04:00 remove superfluous 'id' type parameter from GenTickish The 'id' type is now determined by the pass, using the XTickishId type family. - - - - - 0107f356 by Luite Stegeman at 2021-03-20T07:49:15-04:00 rename Tickish to CoreTickish - - - - - 7de3532f by Luite Stegeman at 2021-03-20T07:49:15-04:00 Transfer tickish things to GHC.Types.Tickish Metric Increase: MultiLayerModules - - - - - 1f94e0f7 by Luite Stegeman at 2021-03-20T07:49:15-04:00 Generate GHCi bytecode from STG instead of Core and support unboxed tuples and sums. fixes #1257 - - - - - 62b0e1bc by Andreas Klebinger at 2021-03-20T07:49:50-04:00 Make the simplifier slightly stricter. This commit reduces allocations by the simplifier by 3% for the Cabal test at -O2. We do this by making a few select fields, bindings and arguments strict which reduces allocations for the simplifier by around 3% in total for the Cabal test. Which is about 2% fewer allocations in total at -O2. ------------------------- Metric Decrease: T18698a T18698b T9233 T9675 T9872a T9872b T9872c T9872d T10421 T12425 T13253 T5321FD T9961 ------------------------- - - - - - 044e5be3 by Sebastian Graf at 2021-03-20T07:50:26-04:00 Nested CPR light (#19398) While fixing #19232, it became increasingly clear that the vestigial hack described in `Note [Optimistic field binder CPR]` is complicated and causes reboxing. Rather than make the hack worse, this patch gets rid of it completely in favor of giving deeply unboxed parameters the Nested CPR property. Example: ```hs f :: (Int, Int) -> Int f p = case p of (x, y) | x == y = x | otherwise = y ``` Based on `p`'s `idDemandInfo` `1P(1P(L),1P(L))`, we can see that both fields of `p` will be available unboxed. As a result, we give `p` the nested CPR property `1(1,1)`. When analysing the `case`, the field CPRs are transferred to the binders `x` and `y`, respectively, so that we ultimately give `f` the CPR property. I took the liberty to do a bit of refactoring: - I renamed `CprResult` ("Constructed product result result") to plain `Cpr`. - I Introduced `FlatConCpr` in addition to (now nested) `ConCpr` and and according pattern synonym that rewrites flat `ConCpr` to `FlatConCpr`s, purely for compiler perf reasons. - Similarly for performance reasons, we now store binders with a Top signature in a separate `IntSet`, see `Note [Efficient Top sigs in SigEnv]`. - I moved a bit of stuff around in `GHC.Core.Opt.WorkWrap.Utils` and introduced `UnboxingDecision` to replace the `Maybe DataConPatContext` type we used to return from `wantToUnbox`. - Since the `Outputable Cpr` instance changed anyway, I removed the leading `m` which we used to emit for `ConCpr`. It's just noise, especially now that we may output nested CPRs. Fixes #19398. - - - - - 8592a246 by Simon Jakobi at 2021-03-20T07:51:01-04:00 Add compiler perf regression test for #9198 - - - - - d4605e7c by Simon Peyton Jones at 2021-03-20T07:51:36-04:00 Fix an levity-polymorphism error As #19522 points out, we did not account for visible type application when trying to reject naked levity-polymorphic functions that have no binding. This patch tidies up the code, and fixes the bug too. - - - - - 3fa3fb79 by John Ericson at 2021-03-20T07:52:12-04:00 Add more boundary checks for `rem` and `mod` It's quite backend-dependent whether we will actually handle that case right, so let's just always do this as a precaution. In particular, once we replace the native primops used here with the new sized primops, the 16-bit ones on x86 will begin to use 16-bit sized instructions where they didn't before. Though I'm not sure of any arch which has 8-bit scalar instructions, I also did those for consistency. Plus, there are *vector* 8-bit ops in the wild, so if we ever got into autovectorization or something maybe it's prudent to put this here as a reminder not to forget about catching overflows. Progress towards #19026 - - - - - 8e054ff3 by John Ericson at 2021-03-20T07:52:47-04:00 Fix literals for unregisterized backend of small types All credit to @hsyl20, who in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4717#note_338560 figured out this was a problem. To fix this, we use casts in addition to the shrinking and suffixing that is already done. It might make for more verbose code, I don't think that matters too much. In the future, perhaps some of the shrinking and suffixing can be removed for being redundant. That proved less trivial than it sounds, so this wasn't done at this time. Progress towards #19026 Metric Increase: T12707 T13379 Co-authored-by: Sylvain Henry <hsyl20 at gmail.com> - - - - - 226cefd0 by Sylvain Henry at 2021-03-20T07:53:24-04:00 Fix fake import in GHC.Exception.Type boot module It seems like I imported "GHC.Types ()" thinking that it would transitively import GHC.Num.Integer when I wrote that module; but it doesn't. This led to build failures. See https://mail.haskell.org/pipermail/ghc-devs/2021-March/019641.html - - - - - e84e2805 by Viktor Dukhovni at 2021-03-20T07:54:01-04:00 Add fold vs. mconcat test T17123 - - - - - fa499356 by Sebastian Graf at 2021-03-20T07:54:36-04:00 Remove outdated Vagrantfile - - - - - 71e609fb by Moritz Angermann at 2021-03-20T07:55:11-04:00 Add error information to osCommitMemory on failure. - - - - - fb939498 by Ben Gamari at 2021-03-20T10:20:30-04:00 gitlab-ci: Always start with fresh clone Currently we are suffering from issues that appear to be caused by non-hermetic builds. Try avoiding this by setting `GIT_STRATEGY` to `clone`. - - - - - c53faa0c by Ben Gamari at 2021-03-20T15:12:12-04:00 Clean up TBDs in changelog (cherry picked from commit 4f334120c8e9cc4aefcbf11d99f169f648af9fde) - - - - - 91ddac2f by Ryan Scott at 2021-03-20T15:12:12-04:00 Move miscategorized items in template-haskell changelog - - - - - 6a375b53 by Ryan Scott at 2021-03-20T15:12:12-04:00 Bump template-haskell version to 2.18.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #19083. - - - - - adbaa9a9 by Ryan Scott at 2021-03-21T19:40:02-04:00 Remove unnecessary extendTyVarEnvFVRn function The `extendTyVarEnvFVRn` function does the exact same thing as `bindLocalNamesFV`. I see no meaningful distinction between the two functions, so let's just remove the former (which is only used in a handful of places) in favor of the latter. Historical note: `extendTyVarEnvFVRn` and `bindLocalNamesFV` used to be distinct functions, but their implementations were synchronized in 2004 as a part of commit 20e39e0e07e4a8e9395894b2785d6675e4e3e3b3. - - - - - 0cbdba27 by Moritz Angermann at 2021-03-21T21:04:42-04:00 [ci/arm/darwin/testsuite] Forwards ports from GHC-8.10 This is a set of forward ports (cherry-picks) from 8.10 - a7d22795ed [ci] Add support for building on aarch64-darwin - 5109e87e13 [testlib/driver] denoise - 307d34945b [ci] default value for CONFIGURE_ARGS - 10a18cb4e0 [testsuite] mark ghci056 as fragile - 16c13d5acf [ci] Default value for MAKE_ARGS - ab571457b9 [ci/build] Copy config.sub around - 251892b98f [ci/darwin] bump nixpkgs rev - 5a6c36ecb4 [testsuite/darwin] fix conc059 - aae95ef0c9 [ci] add timing info - 3592d1104c [Aarch64] No div-by-zero; disable test. - 57671071ad [Darwin] mark stdc++ tests as broken - 33c4d49754 [testsuite] filter out superfluous dylib warnings - 4bea83afec [ci/nix-shell] Add Foundation and Security - 6345530062 [testsuite/json2] Fix failure with LLVM backends - c3944bc89d [ci/nix-shell] [Darwin] Stop the ld warnings about libiconv. - b821fcc714 [testsuite] static001 is not broken anymore. - f7062e1b0c [testsuite/arm64] fix section_alignment - 820b076698 [darwin] stop the DYLD_LIBRARY_PATH madness - 07b1af0362 [ci/nix-shell] uniquify NIX_LDFLAGS{_FOR_TARGET} As well as a few additional fixups needed to make this block compile: - Fixup all.T - Set CROSS_TARGET, BROKEN_TESTS, XZ, RUNTEST_ARGS, default value. - [ci] shell.nix bump happy - - - - - c46e8147 by Moritz Angermann at 2021-03-21T21:04:42-04:00 [elf/aarch64] Fall Through decoration - - - - - 069abe27 by Moritz Angermann at 2021-03-21T21:04:42-04:00 [llvm/darwin] change vortex cpu to generic For now only the apple flavoured llvm knows vortex, as we build against other toolchains, lets stay with generic for now. - - - - - 2907949c by Moritz Angermann at 2021-03-21T21:04:42-04:00 [ci] Default values for GITLAB_CI_BRANCH, and IGNORE_PERF_FAILURES - - - - - e82d32d6 by Ben Gamari at 2021-03-22T09:22:29-04:00 compiler: Introduce mutableByteArrayContents# primop As noted in #19540, a number of users within and outside of GHC rely on unsafeCoerceUnlifted to work around the fact that this was missing - - - - - eeba7a3a by Ben Gamari at 2021-03-22T09:22:29-04:00 base: Use mutableByteArrayContents - - - - - a9129f9f by Simon Peyton Jones at 2021-03-22T09:23:04-04:00 Short-circuit warning generation for partial type signatures This Note says it all: Note [Skip type holes rapidly] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose we have module with a /lot/ of partial type signatures, and we compile it while suppressing partial-type-signature warnings. Then we don't want to spend ages constructing error messages and lists of relevant bindings that we never display! This happened in #14766, in which partial type signatures in a Happy-generated parser cause a huge increase in compile time. The function ignoreThisHole short-circuits the error/warning generation machinery, in cases where it is definitely going to be a no-op. It makes a pretty big difference on the Sigs.hs example in #14766: Compile-time allocation GHC 8.10 5.6G Before this patch 937G With this patch 4.7G Yes, that's more than two orders of magnitude! - - - - - 6e437a12 by Ben Gamari at 2021-03-22T18:35:24-04:00 UniqSM: oneShot-ify Part of #18202 ------------------------- Metric Decrease: T12707 T3294 ------------------------- - - - - - 26dd1f88 by Simon Peyton Jones at 2021-03-23T08:09:05-04:00 More improvement to MonoLocalBinds documentation - - - - - 26ba86f7 by Peter Trommler at 2021-03-23T08:09:40-04:00 PPC NCG: Fix int to float conversion In commit 540fa6b2 integer to float conversions were changed to round to the nearest even. Implement a special case for 64 bit integer to single precision floating point numbers. Fixes #19563. - - - - - 7a657751 by Ben Gamari at 2021-03-23T13:00:37-04:00 rts: Use long-path-aware stat Previously `pathstat` relied on msvcrt's `stat` implementation, which was not long-path-aware. It should rather be defined in terms of the `stat` implementation provided by `utils/fs`. Fixes #19541. - - - - - 05c5c054 by Sylvain Henry at 2021-03-23T13:01:15-04:00 Move loader state into Interp The loader state was stored into HscEnv. As we need to have two interpreters and one loader state per interpreter in #14335, it's natural to make the loader state a field of the Interp type. As a side effect, many functions now only require a Interp parameter instead of HscEnv. Sadly we can't fully free GHC.Linker.Loader of HscEnv yet because the loader is initialised lazily from the HscEnv the first time it is used. This is left as future work. HscEnv may not contain an Interp value (i.e. hsc_interp :: Maybe Interp). So a side effect of the previous side effect is that callers of the modified functions now have to provide an Interp. It is satisfying as it pushes upstream the handling of the case where HscEnv doesn't contain an Interpreter. It is better than raising a panic (less partial functions, "parse, don't validate", etc.). - - - - - df895b3f by Ben Gamari at 2021-03-23T20:43:36-04:00 gitlab-ci: Rework handling of head.hackage job trigger GitLab 12.3 now has reasonable support [1] for cross-project job dependencies, allowing us to drop the awful hack of a shell script we used previously. [1] https://docs.gitlab.com/ee/ci/multi_project_pipelines.html#mirroring-status-from-triggered-pipeline - - - - - 25306ddc by GHC GitLab CI at 2021-03-23T20:44:11-04:00 EPA: Run exactprint transformation tests as part of CI EPA == exact print annotations. When !2418 landed, it did not run the tests brought over from ghc-exactprint for making sure the AST prints correctly efter being edited. This enables those tests. - - - - - 55fd158d by Ben Gamari at 2021-03-24T12:35:23+01:00 CmmToAsm.Reg.Linear: Use concat rather than repeated (++) - - - - - 23f4bc89 by Ben Gamari at 2021-03-24T12:35:23+01:00 CmmToAsm.Reg.Linear: oneShot-ify RegM ------------------------- Metric Decrease: T783 T4801 T12707 T13379 T3294 T4801 T5321FD ------------------------- - - - - - 60127035 by Andreas Klebinger at 2021-03-24T16:10:07-04:00 STG AST - Make ConstructorNumber always a field. It's used by all passes and already used as a regular field. So I figured it would be both more consistent and performant to make it a regular field for all constructors. I also added a few bangs in the process. - - - - - 5483b1a4 by Adam Sandberg Ericsson at 2021-03-24T23:31:09-04:00 hadrian: remove alex and happy from build-tools Hadrian doesn't actually depend on them as built-tools and normal usage where you want to compile GHC will pick up the tools before you run hadrian via the ./configure script. Not building an extra copy of alex and happy might also improve overall build-times when building from scratch. - - - - - aa99f516 by Simon Peyton Jones at 2021-03-24T23:31:44-04:00 Fix the binder-swap transformation in OccurAnal The binder-swap transformation needs to be iterated, as shown by #19581. The fix is pretty simple, and is explained in point (BS2) of Note [The binder-swap substitution]. Net effect: - sometimes, fewer simplifier iterations - sometimes, more case merging - - - - - 0029df2b by Hécate at 2021-03-25T04:52:41-04:00 Add compiler linting to CI This commit adds the `lint:compiler` Hadrian target to the CI runner. It does also fixes hints in the compiler/ and libraries/base/ codebases. - - - - - 1350a5cd by GHC GitLab CI at 2021-03-25T04:53:16-04:00 EPA : Remove ApiAnn from ParsedModule All the comments are now captured in the AST, there is no need for a side-channel structure for them. - - - - - c74bd3da by GHC GitLab CI at 2021-03-25T17:31:57+00:00 EPA: Tidy up some GHC.Parser.Annotation comments This is a follow up from !2418 / #19579 [skip ci] - - - - - 0d5d344d by Oleg Grenrus at 2021-03-25T17:36:50-04:00 Implement -Wmissing-kind-signatures Fixes #19564 - - - - - d930fecb by Sylvain Henry at 2021-03-26T19:00:07-04:00 Refactor interface loading In order to support several home-units and several independent unit-databases, it's easier to explicitly pass UnitState, DynFlags, etc. to interface loading functions. This patch converts some functions using monads such as IfG or TcRnIf with implicit access to HscEnv to use IO instead and to pass them specific fields of HscEnv instead of an HscEnv value. - - - - - 872a9444 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Refactor NameCache * Make NameCache the mutable one and replace NameCacheUpdater with it * Remove NameCache related code duplicated into haddock Bump haddock submodule - - - - - 599efd90 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Refactor FinderCache - - - - - 532c6a54 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Remove UniqSupply from NameCache As suggested by @alexbiehl, this patch replaces the always updated UniqSupply in NameCache with a fixed Char and use it with `uniqFromMask` to generate uniques. This required some refactoring because getting a new unique from the NameCache can't be done in pure code anymore, in particular not in an atomic update function for `atomicModifyIORef`. So we use an MVar instead to store the OrigNameCache field. For some reason, T12545 increases (+1%) on i386 while it decreases on other CI runners. T9630 ghc/peak increases only with the dwarf build on CI (+16%). Metric Decrease: T12425 T12545 T9198 T12234 Metric Increase: T12545 T9630 Update haddock submodule - - - - - 89ee9206 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Use foldGet in getSymbolTable Implement @alexbiehl suggestion of using a foldGet function to avoid the creation of an intermediate list while reading the symbol table. Do something similar for reading the Hie symbol table and the interface dictionary. Metric Decrease: T10421 - - - - - a9c0b3ca by Sylvain Henry at 2021-03-26T19:00:07-04:00 Bump haddock submodule - - - - - 628417b4 by Sylvain Henry at 2021-03-26T19:00:07-04:00 Fix lint issue - - - - - ef03fa6f by GHC GitLab CI at 2021-03-26T19:00:42-04:00 Bump Win32 to 2.13.0.0 Bumps Win32 submodule. - - - - - 5741caeb by Sylvain Henry at 2021-03-26T19:01:20-04:00 Only update config.sub when it already exists (#19574) - - - - - 57d21e6a by Sebastian Graf at 2021-03-26T23:02:15-04:00 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. - - - - - c83e4d05 by Adam Sandberg Ericsson at 2021-03-26T23:02:52-04:00 hadrian: build ghc-stageN wrapper when building the stageN:exe:ghc-bin target - - - - - 59375de1 by Viktor Dukhovni at 2021-03-27T18:09:31-04:00 bump submodule nofib - - - - - f72d4ebb by Ben Gamari at 2021-03-27T18:10:06-04:00 rts: Fix joinOSThread on Windows Previously we were treating the thread ID as a HANDLE, but it is not. We must first OpenThread. - - - - - f6960b18 by Simon Peyton Jones at 2021-03-28T00:11:46-04:00 Make RULES more robust in GHC.Float The RULES that use hand-written specialised code for overloaded class methods like floor, ceiling, truncate etc were fragile to certain transformations. This patch makes them robust. See #19582. It's all described in Note [Rules for overloaded class methods]. No test case because currently we don't do the transformation (floating out over-saturated applications) that makes this patch have an effect. But we may so so in future, and this patch makes the RULES much more robust. - - - - - b02c8ef7 by Sebastian Graf at 2021-03-28T00:12:21-04:00 Rename StrictSig to DmdSig (#19597) In #19597, we also settled on the following renamings: * `idStrictness` -> `idDmdSig`, `strictnessInfo` -> `dmdSigInfo`, `HsStrictness` -> `HsDmdSig` * `idCprInfo` -> `idCprSig`, `cprInfo` -> `cprSigInfo`, `HsCpr` -> `HsCprSig` Fixes #19597. - - - - - 29d75863 by Fendor at 2021-03-28T17:26:37-04:00 Add UnitId to Target record In the future, we want `HscEnv` to support multiple home units at the same time. This means, that there will be 'Target's that do not belong to the current 'HomeUnit'. This is an API change without changing behaviour. Update haddock submodule to incorporate API changes. - - - - - 9594f6f6 by Ben Gamari at 2021-03-28T17:27:12-04:00 gitlab-ci: Bump ci-images Upgrades bootstrap GHC to 8.10.4, hopefully avoiding #19600. - - - - - 9c9e40e5 by Oleg Grenrus at 2021-03-28T17:27:49-04:00 Replace - with negate It also failed to parse with HLint (I wonder how GHC itself handles it?) - - - - - c30af951 by Alfredo Di Napoli at 2021-03-29T07:58:00+02:00 Add `MessageClass`, rework `Severity` and add `DiagnosticReason`. Other than that: * Fix T16167,json,json2,T7478,T10637 tests to reflect the introduction of the `MessageClass` type * Remove `makeIntoWarning` * Remove `warningsToMessages` * Refactor GHC.Tc.Errors 1. Refactors GHC.Tc.Errors so that we use `DiagnosticReason` for "choices" (defer types errors, holes, etc); 2. We get rid of `reportWarning` and `reportError` in favour of a general `reportDiagnostic`. * Introduce `DiagnosticReason`, `Severity` is an enum: This big commit makes `Severity` a simple enumeration, and introduces the concept of `DiagnosticReason`, which classifies the /reason/ why we are emitting a particular diagnostic. It also adds a monomorphic `DiagnosticMessage` type which is used for generic messages. * The `Severity` is computed (for now) from the reason, statically. Later improvement will add a `diagReasonSeverity` function to compute the `Severity` taking `DynFlags` into account. * Rename `logWarnings` into `logDiagnostics` * Add note and expand description of the `mkHoleError` function - - - - - 4421fb34 by Moritz Angermann at 2021-03-29T17:25:48-04:00 [macho] improved linker with proper plt support This is a pre-requisite for making aarch64-darwin work. - - - - - e754ff7f by Moritz Angermann at 2021-03-29T17:25:49-04:00 Allocate Adjustors and mark them readable in two steps This drops allocateExec for darwin, and replaces it with a alloc, write, mark executable strategy instead. This prevents us from trying to allocate an executable range and then write to it, which X^W will prohibit on darwin. This will *only* work if we can use mmap. - - - - - 026a53e0 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] Additional FALLTHROUGH decorations. - - - - - dc6fa61c by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] SymbolExtras are only used on PPC and X86 - - - - - 710ef9d2 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] align prototype with implementation signature. - - - - - e72a2f77 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker/aarch64-elf] support section symbols for GOT relocation - - - - - 38504b6f by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testsuite] Fix SubsectionsViaSymbols test - - - - - 93b8db6b by Moritz Angermann at 2021-03-29T17:25:49-04:00 [linker] no munmap if either agument is invalid. - - - - - 095e1624 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [rts] cast return value to struct. - - - - - 09ea36cf by Moritz Angermann at 2021-03-29T17:25:49-04:00 [aarch64-darwin] be very careful of warnings. So we did *not* have the stgCallocBytes prototype, and subsequently the C compiler defaulted to `int` as a return value. Thus generating sxtw instructions for the return value of stgCalloBytes to produce the expected void *. - - - - - 4bbd1445 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testlib] ignore strip warnings - - - - - df08d548 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [armv7] arm32 needs symbols! - - - - - f3c23939 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testsuite/aarch64] disable T18623 - - - - - 142950d9 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [testsuite/aarch64-darwin] disable T12674 - - - - - 66044095 by Moritz Angermann at 2021-03-29T17:25:49-04:00 [armv7] PIC by default + [aarch64-linux] T11276 metric increase Metric Increase: T11276 - - - - - afdacc55 by Takenobu Tani at 2021-03-30T20:41:46+09:00 users-guide: Correct markdown for ghc-9.2 This patch corrects some markdown. [skip ci] - - - - - 470839c5 by Oleg Grenrus at 2021-03-30T17:39:39-04:00 Additionally export asum from Control.Applicative Fixes #19575 - - - - - 128fd85c by Simon Jakobi at 2021-03-30T17:40:14-04:00 Add regression test for #5298 Closes #5298. - - - - - 86e7aa01 by Ben Gamari at 2021-03-30T19:14:19-04:00 gitlab-ci: Trigger head.hackage jobs via pipeline ID As noted in ghc/head.hackage!152, the previous plan of using the commit didn't work when the triggering pipeline had not yet successfully finished. - - - - - 59e82fb3 by Oleg Grenrus at 2021-03-31T11:12:17-04:00 import Data.List with explicit import list - - - - - 44774dc5 by Oleg Grenrus at 2021-03-31T11:12:17-04:00 Add -Wcompat to hadrian Update submodules haskeline and hpc - - - - - dbadd672 by Simon Peyton Jones at 2021-03-31T11:12:52-04:00 The result kind of a signature can't mention quantified vars This patch fixes a small but egregious bug, which allowed a type signature like f :: forall a. blah not to fail if (blah :: a). Acutally this only showed up as a ASSERT error (#19495). The fix is very short, but took quite a bit of head scratching Hence the long Note [Escaping kind in type signatures] While I was in town, I also added a short-cut for the common case of having no quantifiers to tcImplicitTKBndrsX. Metric Decrease: T9198 Metric Increase: T9198 - - - - - 2fcebb72 by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : Rename AddApiAnn to AddEpAnn As port of the process of migrating naming from API Annotations to exact print annotations (EPA) Follow-up from !2418, see #19579 - - - - - 0fe5175a by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : Rename ApiAnn to EPAnn Follow-up from !2418, see #19579 Updates haddock submodule - - - - - d03005e6 by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : rename 'api annotations' to 'exact print annotations' In comments, and notes. Follow-up from !2418, see #19579 - - - - - 49bc1e9e by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : rename AnnAnchor to EpaAnchor Follow-up from !2418, see #19579 - - - - - 798d8f80 by Alan Zimmerman at 2021-03-31T11:13:28-04:00 EPA : Rename AnnComment to EpaComment Follow-up from !2418, see #19579 - - - - - 317295da by Simon Peyton Jones at 2021-03-31T11:14:04-04:00 Avoid fundep-caused loop in the typechecker Ticket #19415 showed a nasty typechecker loop, which can happen with fundeps that do not satisfy the coverage condition. This patch fixes the problem. It's described in GHC.Tc.Solver.Interact Note [Fundeps with instances] It's not a perfect solution, as the Note explains, but it's better than the status quo. - - - - - aaf8e293 by Ryan Scott at 2021-03-31T11:14:39-04:00 Add regression tests for #17772 and #18308 Resolves #17772. Addresses one part of #18308. - - - - - efe5fdab by Ben Gamari at 2021-03-31T11:15:14-04:00 gitlab-ci: Extend expiration time of simple perf job artifacts - - - - - 5192183f by Oleg Grenrus at 2021-04-01T00:39:28-04:00 import Data.List with explicit import list - - - - - bddecda1 by Oleg Grenrus at 2021-04-01T00:39:28-04:00 Data.List specialization to [] - Remove GHC.OldList - Remove Data.OldList - compat-unqualified-imports is no-op - update haddock submodule - - - - - 751b2144 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Encapsulate the EPS IORef in a newtype - - - - - 29326979 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Properly initialise UnitEnv - - - - - 0219297c by Sylvain Henry at 2021-04-01T00:40:07-04:00 Move unit DBs in UnitEnv Also make the HomeUnit optional to keep the field strict and prepare for UnitEnvs without a HomeUnit (e.g. in Plugins envs, cf #14335). - - - - - 7acfb617 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Move HPT in UnitEnv - - - - - 85d7056a by Sylvain Henry at 2021-04-01T00:40:07-04:00 Move the EPS into UnitEnv - - - - - 706fad60 by Sylvain Henry at 2021-04-01T00:40:07-04:00 Fix tests - - - - - b2f51099 by Ben Gamari at 2021-04-01T08:21:30-04:00 ghc-bignum: Add missing source files to cabal file - - - - - 9b05b601 by Ben Gamari at 2021-04-01T08:21:30-04:00 ghc-boot: Use cabal-version: 3.0 - - - - - 75e594d0 by Ben Gamari at 2021-04-01T08:21:30-04:00 libiserv: Add description - - - - - 2266bdae by Ben Gamari at 2021-04-01T08:21:30-04:00 configure: Update comment describing versioning policy As noted in my comment on #19058, this comment was previously a bit misleading in the case of stable branches. - - - - - 65c50d8d by Ben Gamari at 2021-04-01T08:21:30-04:00 gitlab-ci: Drop Debian 8 job - - - - - d44e42a2 by Vladislav Zavialov at 2021-04-01T08:22:06-04:00 Add missing axiom exports for CharToNat/NatToChar When the CharToNat and NatToChar type families were added, the corresponding axioms were not exported. This led to a failure much like #14934 - - - - - 15b6c9f9 by Alfredo Di Napoli at 2021-04-01T16:13:23-04:00 Compute Severity of diagnostics at birth This commit further expand on the design for #18516 by getting rid of the `defaultReasonSeverity` in favour of a function called `diagReasonSeverity` which correctly takes the `DynFlags` as input. The idea is to compute the `Severity` and the `DiagnosticReason` of each message "at birth", without doing any later re-classifications, which are potentially error prone, as the `DynFlags` might evolve during the course of the program. In preparation for a proper refactoring, now `pprWarning` from the Parser.Ppr module has been renamed to `mkParserWarn`, which now takes a `DynFlags` as input. We also get rid of the reclassification we were performing inside `printOrThrowWarnings`. Last but not least, this commit removes the need for reclassify inside GHC.Tc.Errors, and also simplifies the implementation of `maybeReportError`. Update Haddock submodule - - - - - 84b76f60 by Viktor Dukhovni at 2021-04-01T16:13:59-04:00 Chiral foldable caveats - - - - - 07393306 by Viktor Dukhovni at 2021-04-01T16:13:59-04:00 Address review feedback on chirality Also added nested foldr example for `concat`. - - - - - 8ef6eaf7 by Ben Gamari at 2021-04-02T05:15:23-04:00 sdist: Fix packaging of Windows tarballs These now live in the ghc-tarballs/mingw-w64 directory. Fixes #19316. - - - - - 82d8847e by Ben Gamari at 2021-04-02T05:15:23-04:00 gitlab-ci: CI wibbles Ensure that deb10-dwarf artifacts are preserved. - - - - - ee877571 by Ben Gamari at 2021-04-02T05:15:23-04:00 gitlab-ci: Ignore performance metrics failures in release jobs We don't want these failing merely due to performance metrics - - - - - ee55d57e by Matthew Pickering at 2021-04-02T05:15:59-04:00 Fix copy+pasto in Sanity.c - - - - - 78ca4a27 by Ben Gamari at 2021-04-02T05:16:35-04:00 testsuite: Make passFail a boolean - - - - - a9154662 by Ben Gamari at 2021-04-02T05:16:35-04:00 testsuite: Check test stats only after test correctness Ticket #19576 noted that a test that failed in correctness (e.g. due to stderr mismatch) *and* failed due to a metrics change would report misleading stats. This was due to the testsuite driver *first* checking stats, before checking for correctness. Fix this. Closes #19576. - - - - - c265d19f by Ben Gamari at 2021-04-02T05:17:11-04:00 testsuite: Add test for #7275 - - - - - ce706fae by Sebastian Graf at 2021-04-02T05:17:47-04:00 Pmc: Add regression test for #19622 It appears that the issue has already been fixed. Judging by the use of a pattern synonym with a provided constraint, my bet is on 1793ca9d. Fixes #19622. - - - - - 918d5021 by Ben Gamari at 2021-04-05T20:37:28-04:00 configure: Fix parsing of ARM triples To support proper parsing of arm64 targets, we needed to adjust the GHC_LLVM_TARGET function to allow parsing arm64-apple-darwin into aarch64. This however discared the proper os detection. To rectify this, we'll pull the os detection into separate block. Fixes #19173. - - - - - 9c9adbd0 by Oleg Grenrus at 2021-04-05T20:38:07-04:00 Implement proposal 403: Lexer cleanup This allows Other Numbers to be used in identifiers, and also documents other, already existing lexer divergence from Haskell Report - - - - - 89acbf35 by Matthew Pickering at 2021-04-05T20:38:42-04:00 Add special case to stripStgTicksTop for [] In the common case where the list of ticks is empty, building a thunk just applies 'reverse' to '[]' which is quite wasteful. - - - - - 77772bb1 by Harry Garrood harry at garrood.me at 2021-04-05T20:39:19-04:00 Add type signature for TargetContents.go These changes made it slightly easier for me to work out what was going on in this test. I've also fixed a typo in the comments. - - - - - 49528121 by Alfredo Di Napoli at 2021-04-05T20:39:54-04:00 Introduce SevIgnore Severity to suppress warnings This commit introduces a new `Severity` type constructor called `SevIgnore`, which can be used to classify diagnostic messages which are not meant to be displayed to the user, for example suppressed warnings. This extra constructor allows us to get rid of a bunch of redundant checks when emitting diagnostics, typically in the form of the pattern: ``` when (optM Opt_XXX) $ addDiagnosticTc (WarningWithFlag Opt_XXX) ... ``` Fair warning! Not all checks should be omitted/skipped, as evaluating some data structures used to produce a diagnostic might still be expensive (e.g. zonking, etc). Therefore, a case-by-case analysis must be conducted when deciding if a check can be removed or not. Last but not least, we remove the unnecessary `CmdLine.WarnReason` type, which is now redundant with `DiagnosticReason`. - - - - - 3483c3de by Alfredo Di Napoli at 2021-04-05T20:39:54-04:00 Correct warning for deprecated and unrecognised flags Fixes #19616. This commit changes the `GHC.Driver.Errors.handleFlagWarnings` function to rely on the newly introduced `DiagnosticReason`. This allows us to correctly pretty-print the flags which triggered some warnings and in turn remove the cruft around this function (like the extra filtering and the `shouldPrintWarning` function. - - - - - 54247fb1 by Joachim Breitner at 2021-04-05T20:40:30-04:00 ./configure: Indicate that GHC=… should be a full path and not just the name on the binary on the `$PATH`. - - - - - 5db116e9 by Joachim Breitner at 2021-04-05T20:40:30-04:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 2783d498 by Luite Stegeman at 2021-04-05T20:41:06-04:00 fix sub-word literals in GHCi - - - - - 33b88645 by Andreas Klebinger at 2021-04-05T20:41:41-04:00 Add regression test for T19474. In version 0.12.2.0 of vector when used with GHC-9.0 we rebox values from storeable mutable vectors. This should catch such a change in the future. - - - - - 939fa61c by Łukasz Gołębiewski at 2021-04-05T20:42:17-04:00 Fixes Monad's associativity docs It is incorrectly displayed in hackage as: `m1 <*> m2 = m1 >>= (x1 -> m2 >>= (x2 -> return (x1 x2)))` which isn't correct Haskell - - - - - 10782edf by Simon Jakobi at 2021-04-05T20:42:53-04:00 Mark p6 and T3333 as fragile See #17018. - - - - - 048af266 by Andreas Klebinger at 2021-04-05T20:43:27-04:00 One-Shotify GHC.Utils.Monad.State (#18202) - - - - - 83654240 by Matthew Pickering at 2021-04-05T20:44:02-04:00 Add (expect_broken) test for #11545 - - - - - 53cf2c04 by Ben Gamari at 2021-04-05T20:44:37-04:00 hadrian: Refactor hlint target Not only does this eliminate some code duplication but we also add a maximum core count to HLint's command-line, hopefully avoiding issue #19600. - - - - - eac9d376 by Ben Gamari at 2021-04-05T20:45:12-04:00 hadrian: Fix build-stack-nix As noted by #19589, `stack` is not stateful and therefore must be passed `--nix` on every invocation. Do so. Fixes #19589. - - - - - bfe8ef8e by Ben Gamari at 2021-04-05T20:45:46-04:00 rts: Fix usage of pthread_setname_np Previously we used this non-portable function unconditionally, breaking FreeBSD. Fixes #19637. - - - - - 403bf88c by Ben Gamari at 2021-04-05T20:46:21-04:00 Revert "[ci/arm/darwin/testsuite] Forwards ports from GHC-8.10" This reverts commit 0cbdba2768d84a0f6832ae5cf9ea1e98efd739da. - - - - - 54880c13 by Sylvain Henry at 2021-04-05T20:46:59-04:00 Bignum: fix invalid hs-boot declaration (#19638) - - - - - 247684ad by Sylvain Henry at 2021-04-05T20:47:37-04:00 Bignum: remove unused extra files - - - - - 2e3a6fba by Adam Sandberg Ericsson at 2021-04-07T12:37:11-04:00 hadrian: don't hardcode -fuse-ld=gold in hsc2hs wrapper #19514 - - - - - b06e457d by Simon Peyton Jones at 2021-04-07T12:37:47-04:00 Make specialisation a bit more aggressive The patch commit c43c981705ec33da92a9ce91eb90f2ecf00be9fe Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Fri Oct 23 16:15:51 2009 +0000 Fix Trac #3591: very tricky specialiser bug fixed a nasty specialisation bug /for DFuns/. Eight years later, this patch commit 2b74bd9d8b4c6b20f3e8d9ada12e7db645cc3c19 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 7 12:03:51 2017 +0100 Stop the specialiser generating loopy code extended it to work for /imported/ DFuns. But in the process we lost the fact that it was needed only for DFuns! As a result we started silently losing useful specialisation for non-DFuns. But there was no regression test to spot the lossage. Then, nearly four years later, Andreas filed #19599, which showed the lossage in high relief. This patch restores the DFun test, and adds Note [Avoiding loops (non-DFuns)] to explain why. This is undoubtedly a very tricky corner of the specialiser, and one where I would love to have a more solid argument, even a paper! But meanwhile I think this fixes the lost specialisations without introducing any new loops. I have two regression tests, T19599 and T19599a, so I hope we'll know if we lose them again in the future. Vanishingly small effect on nofib. A couple of compile-time benchmarks improve T9872a(normal) ghc/alloc 1660559328.0 1643827784.0 -1.0% GOOD T9872c(normal) ghc/alloc 1691359152.0 1672879384.0 -1.1% GOOD Many others wiggled around a bit. Metric Decrease: T9872a T9872c - - - - - 546f8b14 by Matthew Pickering at 2021-04-07T12:38:22-04:00 hadrian: Don't try to build iserv-prof if we don't have profiled libraries Workaround for #19624 - - - - - d014ab0d by Sylvain Henry at 2021-04-07T12:39:00-04:00 Remove dynamic-by-default (#16782) Dynamic-by-default was a mechanism to automatically select the -dynamic way for some targets. It was implemented in a convoluted way: it was defined as a flavour option, hence it couldn't be passed as a global settings (which are produced by `configure` before considering flavours), so a build system rule was used to pass -DDYNAMIC_BY_DEFAULT to the C compiler so that deriveConstants could infer it. * Make build system has it disabled for 8 years (951e28c0625ece7e0db6ac9d4a1e61e2737b10de) * It has never been implemented in Hadrian * Last time someone tried to enable it 1 year ago it didn't work (!2436) * Having this as a global constant impedes making GHC multi-target (see !5427) This commit fully removes support for dynamic-by-default. If someone wants to reimplement something like this, it would probably need to move the logic in the compiler. (Doing this would probably need some refactoring of the way the compiler handles DynFlags: DynFlags are used to store and to pass enabled ways to many parts of the compiler. It can be set by command-line flags, GHC API, global settings. In multi-target GHC, we will use DynFlags to load the target platform and its constants: but at this point with the current DynFlags implementation we can't easily update the existing DynFlags with target-specific options such as dynamic-by-default without overriding ways previously set by the user.) - - - - - 88d8a0ed by James Foster at 2021-04-07T14:17:31-04:00 Change foldl' to inline when partially applied (#19534) And though partially applied foldl' is now again inlined, #4301 has not resurfaced, and appears to be resolved. - - - - - 898afe90 by Matthew Pickering at 2021-04-08T08:07:10-04:00 Stop retaining SimplEnvs in unforced Unfoldings Related to #15455 - - - - - 8417e866 by Matthew Pickering at 2021-04-08T08:07:10-04:00 Don't retain reference to whole TcLclEnv in SkolemTV - - - - - 352a463b by Matthew Pickering at 2021-04-08T08:07:10-04:00 Use DmdEnv rather than VarEnv DmdEnv - - - - - adc52bc8 by Matthew Pickering at 2021-04-08T08:07:10-04:00 Make updTcRef force the result This can lead to a classic thunk build-up in a TcRef Fixes #19596 - - - - - eaa1461a by Matthew Pickering at 2021-04-08T08:07:11-04:00 Make sure mergeWithKey is inlined and applied strictly In the particular case of `DmdEnv`, not applying this function strictly meant 500MB of thunks were accumulated before the values were forced at the end of demand analysis. - - - - - 629a5e98 by Matthew Pickering at 2021-04-08T08:07:11-04:00 Some extra strictness in Demand.hs It seems that these places were supposed to be forced anyway but the forcing has no effect because the result was immediately placed in a lazy box. - - - - - 42d88003 by Matthew Pickering at 2021-04-08T08:07:11-04:00 Make sure result of demand analysis is forced promptly This avoids a big spike in memory usage during demand analysis. Part of fixing #15455 ------------------------- Metric Decrease: T18698a T18698b T9233 T9675 T9961 ------------------------- - - - - - e0d861d4 by Matthew Pickering at 2021-04-08T08:07:11-04:00 T11545 now also passes due to modifications in demand analysis Fixes #11545 - - - - - a3cc9a29 by Ryan Scott at 2021-04-08T08:07:45-04:00 Fix #19649 by using filterInScopeM in rnFamEqn Previously, associated type family instances would incorrectly claim to implicitly quantify over type variables bound by the instance head in the `HsOuterImplicit`s that `rnFamEqn` returned. This is fixed by using `filterInScopeM` to filter out any type variables that the instance head binds. Fixes #19649. - - - - - 6e8e2e08 by Alfredo Di Napoli at 2021-04-08T08:08:20-04:00 Move Iface.Load errors into Iface.Errors module This commit moves the error-related functions in `GHC.Iface.Load` into a brand new module called `GHC.Iface.Errors`. This will avoid boot files and circular dependencies in the context of #18516, in the pretty-printing modules. - - - - - 8a099701 by Ben Gamari at 2021-04-09T03:30:26-04:00 CoreTidy: enhance strictness note - - - - - 0bdb867e by Sylvain Henry at 2021-04-09T03:30:26-04:00 CoreTidy: handle special cases to preserve more sharing. Metric Decrease: T16577 - - - - - c02ac1bb by Andreas Klebinger at 2021-04-09T03:31:02-04:00 Re-export GHC.Bits from GHC.Prelude with custom shift implementation. This allows us to use the unsafe shifts in non-debug builds for performance. For older versions of base we instead export Data.Bits See also #19618 - - - - - 35407d67 by Peter Trommler at 2021-04-09T03:31:37-04:00 testsuite: Skip T18623 on powerpc64le In commit f3c23939 T18623 is disabled for aarch64. The limit seems to be too low for powerpc64le, too. This could be because tables next to code is not supported and our code generator produces larger code on PowerPC. - - - - - d8f04425 by Peter Trommler at 2021-04-09T03:31:37-04:00 Fix typo - - - - - fd5ca9c3 by Peter Trommler at 2021-04-09T03:31:37-04:00 testsuite/ppc64le: Mark UnboxedTuples test broken - - - - - d4a71b0c by Matthew Pickering at 2021-04-09T03:32:12-04:00 Avoid repeated zonking and tidying of types in `relevant_bindings` The approach taking in this patch is that the tcl_bndrs in TcLclEnv are zonked and tidied eagerly, so that work can be shared across multiple calls to `relevant_bindings`. To test this patch I tried without the `keepThisHole` filter and the test finished quickly. Fixes #14766 - - - - - 28d2d646 by Matthew Pickering at 2021-04-09T03:32:47-04:00 Don't tidy type in pprTypeForUser There used to be some cases were kinds were not generalised properly before being printed in GHCi. This seems to have changed in the past so now it's uncessary to tidy before printing out the test case. ``` > :set -XPolyKinds > data A x y > :k A k1 -> k2 -> A ``` This tidying was causing issues with an attempt to increase sharing by making `mkTyConApp` (see !4762) - - - - - 6d29e635 by Matthew Pickering at 2021-04-09T03:33:22-04:00 Add perf test for #15304 The test max memory usage improves dramatically with the fixes to memory usage in demand analyser from #15455 - - - - - 70c39e22 by Douglas Wilson at 2021-04-09T03:33:56-04:00 [docs] release notes for !4729 + !3678 Also includes small unrelated type fix - - - - - c1d6daab by Matthew Pickering at 2021-04-09T03:34:31-04:00 Update HACKING.md - - - - - a951e069 by Sylvain Henry at 2021-04-09T03:35:08-04:00 Bignum: add BigNat Eq/Ord instances (#19647) - - - - - cd391756 by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Tweak kick-out condition K2b to deal with LHSs Kick out condition K2b really only makes sense for inerts with a type variable on the left. This updates the commentary and the code to skip this check for inerts with type families on the left. Also cleans up some commentary around solver invariants and adds Note [K2b]. Close #19042. test case: typecheck/should_compile/T19042 - - - - - 7536126e by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Kick out fewer equalities by thinking harder Close #17672. By scratching our heads quite hard, we realized that we should never kick out Given/Nominal equalities. This commit tweaks the kick-out conditions accordingly. See also Note [K4] which describes what is going on. This does not fix a known misbehavior, but it should be a small improvement in both practice (kicking out is bad, and we now do less of it) and theory (a Given/Nominal should behave just like a filled-in metavariable, which has no notion of kicking out). - - - - - 449be647 by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Clarify commentary around the constraint solver No changes to code; no changes to theory. Just better explanation. - - - - - 3c98dda6 by Richard Eisenberg at 2021-04-10T05:29:21-04:00 Test #19665 as expect_broken, with commentary - - - - - 6b1d0b9c by Koz Ross at 2021-04-10T05:29:59-04:00 Implement list `fold` and `foldMap` via mconcat - This allows specialized mconcat implementations an opportunity to combine elements efficiently in a single pass. - Inline the default implementation of `mconcat`, this may result in list fusion. - In Monoids with strict `mappend`, implement `mconcat` as a strict left fold: * And (FiniteBits) * Ior (FiniteBits) * Xor (FiniteBits) * Iff (FiniteBits) * Max (Ord) * Min (Ord) * Sum (Num) * Product (Num) * (a -> m) (Monoid m) - Delegate mconcat for WrappedMonoid to the underlying monoid. Resolves: #17123 Per the discussion in !4890, we expect some stat changes: * T17123(normal) run/alloc 403143160.0 4954736.0 -98.8% GOOD This is the expected improvement in `fold` for a long list of `Text` elements. * T13056(optasm) ghc/alloc 381013328.0 447700520.0 +17.5% BAD Here there's an extra simplifier run as a result of the new methods of the Foldable instance for List. It looks benign. The test is a micro benchmark that compiles just the derived foldable instances for a pair of structures, a cost of this magnitude is not expected to extend to more realistic programs. * T9198(normal) ghc/alloc 504661992.0 541334168.0 +7.3% BAD This test regressed from 8.10 and 9.0 back to exponential blowup. This metric also fluctuates, for reasons not yet clear. The issue here is the exponetial blowup, not this MR. Metric Decrease: T17123 Metric Increase: T9198 T13056 - - - - - 3f851bbd by Sylvain Henry at 2021-04-10T05:30:37-04:00 Enhance pretty-printing perf A few refactorings made after looking at Core/STG * Use Doc instead of SDoc in pprASCII to avoid passing the SDocContext that is never used. * Inline every SDoc wrappers in GHC.Utils.Outputable to expose Doc constructs * Add text/[] rule for empty strings (i.e., text "") * Use a single occurrence of pprGNUSectionHeader * Use bangs on Platform parameters and some others Metric Decrease: ManyAlternatives ManyConstructors T12707 T13035 T13379 T18698a T18698b T1969 T3294 T4801 T5321FD T783 - - - - - 9c762f27 by Sylvain Henry at 2021-04-10T05:31:14-04:00 Generate parser for DerivedConstants.h deriveConstants utility now generates a Haskell parser for DerivedConstants.h. It can be used to replace the one used to read platformConstants file. - - - - - 085983e6 by Sylvain Henry at 2021-04-10T05:31:14-04:00 Read constants header instead of global platformConstants With this patch we switch from reading the globally installed platformConstants file to reading the DerivedConstants.h header file that is bundled in the RTS unit. When we build the RTS unit itself, we get it from its includes directories. The new parser is more efficient and strict than the Read instance for PlatformConstants and we get about 2.2MB less allocations in every cases. However it only really shows in tests that don't allocate much, hence the following metric decreases. Metric Decrease: Naperian T10421 T10547 T12150 T12234 T12425 T13035 T18304 T18923 T5837 T6048 T18140 - - - - - 2cdc95f9 by Sylvain Henry at 2021-04-10T05:31:14-04:00 Don't produce platformConstants file It isn't used for anything anymore - - - - - b699c4fb by Sylvain Henry at 2021-04-10T05:31:14-04:00 Constants: add a note and fix minor doc glitches - - - - - eb1a86bb by John Ericson at 2021-04-10T05:31:49-04:00 Allow C-- to scrutinize non-native-size words - - - - - c363108e by John Ericson at 2021-04-10T05:31:49-04:00 Add missing relational constant folding for sized numeric types - - - - - b39dec86 by Facundo Domínguez at 2021-04-10T05:32:28-04:00 Report actual port in libiserv:Remote.Slave.startSlave This allows to start iserv by passing port 0 to startSlave, which in turns allows to get an available port when no port is known to be free a priori. - - - - - 94d48ec9 by Matthew Pickering at 2021-04-10T05:33:03-04:00 Use CI_MERGE_REQUEST_SOURCE_BRANCH_NAME rather than undefined GITLAB_CI_BRANCH env var See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html - - - - - d39a2b24 by Matthew Pickering at 2021-04-10T05:33:03-04:00 tests: Allow --skip-perf-tests/--only-perf-tests to be used with --ignore-perf-failures - - - - - 6974c9e4 by Matthew Pickering at 2021-04-10T05:33:38-04:00 Fix magicDict in ghci (and in the presence of other ticks) The problem was that ghci inserts some ticks around the crucial bit of the expression. Just like in some of the other rules we now strip the ticks so that the rule fires more reliably. It was possible to defeat magicDict by using -fhpc as well, so not just an issue in ghci. Fixes #19667 and related to #19673 - - - - - 792d9289 by Simon Peyton Jones at 2021-04-12T13:50:49-04:00 More accurate SrcSpan when reporting redundant constraints We want an accurate SrcSpan for redundant constraints: • Redundant constraint: Eq a • In the type signature for: f :: forall a. Eq a => a -> () | 5 | f :: Eq a => a -> () | ^^^^ This patch adds some plumbing to achieve this * New data type GHC.Tc.Types.Origin.ReportRedundantConstraints (RRC) * This RRC value is kept inside - FunSigCtxt - ExprSigCtxt * Then, when reporting the error in GHC.Tc.Errors, use this SrcSpan to control the error message: GHC.Tc.Errors.warnRedundantConstraints Quite a lot of files are touched in a boring way. - - - - - 18cbff86 by Matthew Pickering at 2021-04-12T13:51:23-04:00 template-haskell: Run TH splices with err_vars from current context Otherwise, errors can go missing which arise when running the splices. Fixes #19470 - - - - - 89ff1230 by Matthew Pickering at 2021-04-12T13:51:58-04:00 Add regression test for T19615 Fixes #19615 - - - - - 9588f3fa by Matthew Pickering at 2021-04-12T13:52:33-04:00 Turn T11545 into a normal performance test This makes it more robust to people running it with `quick` flavour and so on. - - - - - d1acda98 by Matthew Pickering at 2021-04-12T17:07:01-04:00 CI: Also ignore metric decreases on master Otherwise, if the marge batch has decreased metrics, they will fail on master which will result in the pipeline being cut short and the expected metric values for the other jobs will not be updated. - - - - - 6124d172 by Stefan Schulze Frielinghaus at 2021-04-13T18:42:40-04:00 hadrian: Provide build rule for ghc-stage3 wrapper - - - - - ef013593 by Simon Peyton Jones at 2021-04-13T18:43:15-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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - 8d87975e by Sylvain Henry at 2021-04-13T18:43:53-04:00 Produce constant file atomically (#19684) - - - - - 1e2e62a4 by Ryan Scott at 2021-04-13T18:44:28-04:00 Add {lifted,unlifted}DataConKey to pretendNameIsInScope's list of Names Fixes #19688. - - - - - b665d983 by Ben Gamari at 2021-04-13T20:04:53-04:00 configure: Bump version to 9.3 Bumps the `haddock` submodule. - - - - - 726da09e by Matthew Pickering at 2021-04-14T05:07:45-04:00 Always generate ModDetails from ModIface This vastly reduces memory usage when compiling with `--make` mode, from about 900M when compiling Cabal to about 300M. As a matter of uniformity, it also ensures that reading from an interface performs the same as using the in-memory cache. We can also delete all the horrible knot-tying in updateIdInfos. Goes some way to fixing #13586 Accept new output of tests fixing some bugs along the way ------------------------- Metric Decrease: T12545 ------------------------- - - - - - 78ed7adf by Hécate Moonlight at 2021-04-14T14:40:46-04:00 Data.List strictness optimisations for maximumBy and minimumBy follow-up from !4675 - - - - - 79e5c867 by Peter Trommler at 2021-04-14T14:41:21-04:00 Prelude: Fix version bound on Bits import Fixes #19683 - - - - - 5f172299 by Adam Gundry at 2021-04-14T19:42:18-04:00 Add isInjectiveTyCon check to opt_univ (fixes #19509) - - - - - cc1ba576 by Matthew Pickering at 2021-04-14T19:42:53-04:00 Fix some negation issues when creating FractionalLit There were two different issues: 1. integralFractionalLit needed to be passed an already negated value. (T19680) 2. negateFractionalLit did not actually negate the argument, only flipped the negation flag. (T19680A) Fixes #19680 - - - - - da92e728 by Matthew Pickering at 2021-04-15T12:27:44-04:00 hie: Initialise the proper environment for calling dsExpr We now use DsM as the base monad for writing hie files and properly initialise it from the TcGblEnv. Before, we would end up reading the interface file from disk for the module we were currently compiling. The modules iface then ended up in the EPS causing all sorts of subtle carnage, including difference in the generated core and haddock emitting a lot of warnings. With the fix, the module in the TcGblEnv is set correctly so the lookups happen in the local name env rather than thinking the identifier comes from an external package. Fixes #19693 and #19334 - - - - - 0a8c14bd by Simon Peyton Jones at 2021-04-15T12:28:18-04:00 Fix handling ze_meta_tv_env in GHC.Tc.Utils.Zonk As #19668 showed, there was an /asymptotic/ slow-down in zonking in GHC 9.0, exposed in test T9198. The bug was actually present in earlier compilers, but by a fluke didn't actually show up in any of our tests; but adding Quick Look exposed it. The bug was that in zonkTyVarOcc we 1. read the meta-tyvar-env variable 2. looked up the variable in the env 3. found a 'miss' 4. looked in the variable, found `Indirect ty` 5. zonked `ty` 6. update the env *gotten from step 1* to map the variable to its zonked type. The bug is that we thereby threw away all teh work done in step 4. In T9198 that made an enormous, indeed asymptotic difference. The fix is easy: use updTcRef. I commented in `Note [Sharing when zonking to Type]` ------------------------- Metric Decrease: T9198 ------------------------- - - - - - 7bd12940 by Simon Peyton Jones at 2021-04-17T22:56:32+01:00 Improve CSE in STG-land This patch fixes #19717, a long-standing bug in CSE for STG, which led to a stupid loss of CSE in some situations. It's explained in Note [Trivial case scrutinee], which I have substantially extended. - - - - - c71b2204 by Simon Peyton Jones at 2021-04-17T23:03:56+01:00 Improvements in SpecConstr * Allow under-saturated calls to specialise See Note [SpecConstr call patterns] This just allows a bit more specialisation to take place. * Don't discard calls from un-specialised RHSs. This was a plain bug in `specialise`, again leading to loss of specialisation. Refactoring yields an `otherwise` case that is easier to grok. * I refactored CallPat to become a proper data type, not a tuple. All this came up when I was working on eta-reduction. The ticket is #19672. The nofib results are mostly zero, with a couple of big wins: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- awards +0.2% -0.1% -18.7% -18.8% 0.0% comp_lab_zift +0.2% -0.2% -23.9% -23.9% 0.0% fft2 +0.2% -1.0% -34.9% -36.6% 0.0% hpg +0.2% -0.3% -18.4% -18.4% 0.0% mate +0.2% -15.7% -19.3% -19.3% +11.1% parser +0.2% +0.6% -16.3% -16.3% 0.0% puzzle +0.4% -19.7% -33.7% -34.0% 0.0% rewrite +0.2% -0.5% -20.7% -20.7% 0.0% -------------------------------------------------------------------------------- Min +0.2% -19.7% -48.1% -48.9% 0.0% Max +0.4% +0.6% -1.2% -1.1% +11.1% Geometric Mean +0.2% -0.4% -21.0% -21.1% +0.1% I investigated the 0.6% increase on 'parser'. It comes because SpecConstr has a limit of 3 specialisations. With HEAD, hsDoExpr has 2 specialisations, and then a further several from the specialised bodies, of which 1 is picked. With this patch we get 3 specialisations right off the bat, so we discard all from the recursive calls. Turns out that that's not the best choice, but there is no way to tell that. I'm accepting it. NB: these figures actually come from this patch plus the preceding one for StgCSE, but I think the gains come from SpecConstr. - - - - - 40d28436 by Matthew Pickering at 2021-04-18T11:09:32-04:00 Only load package environment file once when starting GHCi Since d880d6b2e48268f5ed4d3eb751fe24cc833e9221 the parsing of the environment files was moved to `parseDynamicFlags`, under the assumption it was typically only called once. It turns out not to be true in GHCi and this led to continually reparsing the environment file whenever a new option was set, the options were appended to the package state and hence all packages reloaded, as it looked like the options were changed. The simplest fix seems to be a clearer specification: > Package environment files are only loaded in GHCi during initialisation. Fixes #19650 - - - - - a4234697 by Ben Gamari at 2021-04-18T20:12:26-04:00 Fix Haddock reference - - - - - 78288b97 by Ben Gamari at 2021-04-18T20:12:26-04:00 users-guide: Clarify GHC2021 documentation Point out that GHC2021 doesn't offer the same degree of stability that Haskell2010 does, as noted by @phadej. - - - - - b5189749 by Ben Gamari at 2021-04-18T20:12:26-04:00 users guide: Sort lists of implied language extensions - - - - - 0165b029 by Ben Gamari at 2021-04-18T20:12:26-04:00 users-guide: Add missing FieldSelectors to GHC2021 list - - - - - 0b398d55 by Ryan Scott at 2021-04-18T20:13:01-04:00 Use correct precedence in Complex's Read1/Show1 instances Fixes #19719. - - - - - 8b5e5b05 by Andreas Schwab at 2021-04-19T15:40:25-04:00 Enable tables next to code for riscv64 This requires adding another rewrite to the mangler, to avoid generating PLT entries. - - - - - 0619fb0f by Alan Zimmerman at 2021-04-19T15:41:00-04:00 EPA: cleanups after the merge Remove EpaAnn type synonym, rename EpaAnn' to EpaAnn. Closes #19705 Updates haddock submodule -- Change data EpaAnchor = AR RealSrcSpan | AD DeltaPos To instead be data EpaAnchor = AnchorReal RealSrcSpan | AnchorDelta DeltaPos Closes #19699 -- Change data DeltaPos = DP { deltaLine :: !Int, deltaColumn :: !Int } To instead be data DeltaPos = SameLine { deltaColumn :: !Int } | DifferentLine { deltaLine :: !Int, startColumn :: !Int } Closes #19698 -- Also some clean-ups of unused parts of check-exact. - - - - - 99bd4ae6 by Sebastian Graf at 2021-04-20T10:17:52+02:00 Factor out DynFlags from WorkWrap.Utils Plus a few minor refactorings: * Introduce `normSplitTyConApp_maybe` to Core.Utils * Reduce boolean blindness in the Bool argument to `wantToUnbox` * Let `wantToUnbox` also decide when to drop an argument, cleaning up `mkWWstr_one` - - - - - ee5dadad by Sebastian Graf at 2021-04-20T10:17:55+02:00 Refactor around `wantToUnbox` I renamed `wantToUnbox` to `wantToUnboxArg` and then introduced `wantToUnboxResult`, which we call in `mkWWcpr_one` now. I also deleted `splitArgType_maybe` (the single call site outside of `wantToUnboxArg` actually cared about the result type of a function, not an argument) and `splitResultType_maybe` (which is entirely superceded by `wantToUnboxResult`. - - - - - 0e541137 by Sebastian Graf at 2021-04-20T10:17:55+02:00 Worker/wrapper: Consistent names - - - - - fdbead70 by Sebastian Graf at 2021-04-20T14:55:16+02:00 Worker/wrapper: Refactor CPR WW to work for nested CPR (#18174) In another small step towards bringing a manageable variant of Nested CPR into GHC, this patch refactors worker/wrapper to be able to exploit Nested CPR signatures. See the new Note [Worker/wrapper for CPR]. The nested code path is currently not triggered, though, because all signatures that we annotate are still flat. So purely a refactoring. I am very confident that it works, because I ripped it off !1866 95% unchanged. A few test case outputs changed, but only it's auxiliary names only. I also added test cases for #18109 and #18401. There's a 2.6% metric increase in T13056 after a rebase, caused by an additional Simplifier run. It appears b1d0b9c saw a similar additional iteration. I think it's just a fluke. Metric Increase: T13056 - - - - - b7980b5d by Simon Peyton Jones at 2021-04-20T21:33:09-04:00 Fix occAnalApp In OccurAnal the function occAnalApp was failing to reset occ_encl to OccVanilla. This omission sometimes resulted in over-pessimistic occurrence information. I tripped over this when analysing eta-expansions. Compile times in perf/compiler fell slightly (no increases) PmSeriesG(normal) ghc/alloc 50738104.0 50580440.0 -0.3% PmSeriesS(normal) ghc/alloc 64045284.0 63739384.0 -0.5% PmSeriesT(normal) ghc/alloc 94430324.0 93800688.0 -0.7% PmSeriesV(normal) ghc/alloc 63051056.0 62758240.0 -0.5% T10547(normal) ghc/alloc 29322840.0 29307784.0 -0.1% T10858(normal) ghc/alloc 191988716.0 189801744.0 -1.1% T11195(normal) ghc/alloc 282654016.0 281839440.0 -0.3% T11276(normal) ghc/alloc 142994648.0 142338688.0 -0.5% T11303b(normal) ghc/alloc 46435532.0 46343376.0 -0.2% T11374(normal) ghc/alloc 256866536.0 255653056.0 -0.5% T11822(normal) ghc/alloc 140210356.0 138935296.0 -0.9% T12234(optasm) ghc/alloc 60753880.0 60720648.0 -0.1% T14052(ghci) ghc/alloc 2235105796.0 2230906584.0 -0.2% T17096(normal) ghc/alloc 297725396.0 296237112.0 -0.5% T17836(normal) ghc/alloc 1127785292.0 1125316160.0 -0.2% T17836b(normal) ghc/alloc 54761928.0 54637592.0 -0.2% T17977(normal) ghc/alloc 47529464.0 47397048.0 -0.3% T17977b(normal) ghc/alloc 42906972.0 42809824.0 -0.2% T18478(normal) ghc/alloc 777385708.0 774219280.0 -0.4% T18698a(normal) ghc/alloc 415097664.0 409009120.0 -1.5% GOOD T18698b(normal) ghc/alloc 500082104.0 493124016.0 -1.4% GOOD T18923(normal) ghc/alloc 72252364.0 72216016.0 -0.1% T1969(normal) ghc/alloc 811581860.0 804883136.0 -0.8% T5837(normal) ghc/alloc 37688048.0 37666288.0 -0.1% Nice! Metric Decrease: T18698a T18698b - - - - - 7f4d06e6 by Matthew Pickering at 2021-04-22T16:59:42-04:00 driver: Consider dyn_o files when checking recompilation in -c When -dynamic-too is enabled, there are two result files, .o and .dyn_o, therefore we should check both to decide whether to set SourceModified or not. The whole recompilation logic is very messy, a more thorough refactor would be beneficial in this area but this is the minimal patch to fix this more high priority problem. Fixes #17968 and hopefully #17534 - - - - - 4723652a by Fendor at 2021-04-22T17:00:19-04:00 Move 'nextWrapperNum' into 'DsM' and 'TcM' Previously existing in 'DynFlags', 'nextWrapperNum' is a global variable mapping a Module to a number for name generation for FFI calls. This is not the right location for 'nextWrapperNum', as 'DynFlags' should not contain just about any global variable. - - - - - 350f4f61 by Viktor Dukhovni at 2021-04-22T17:00:54-04:00 Support R_X86_64_TLSGD relocation on FreeBSD The FreeBSD C <ctype.h> header supports per-thread locales by exporting a static inline function that references the `_ThreadRuneLocale` thread-local variable. This means that object files that use e.g. isdigit(3) end up with TLSGD(19) relocations, and would not load into ghci or the language server. Here we add support for this type of relocation, for now just on FreeBSD, and only for external references to thread-specifics defined in already loaded dynamic modules (primarily libc.so). This is sufficient to resolve the <ctype.h> issues. Runtime linking of ".o" files which *define* new thread-specific variables would be noticeably more difficult, as this would likely require new rtld APIs. - - - - - aa685c50 by Viktor Dukhovni at 2021-04-22T17:00:55-04:00 Add background note in elf_tlsgd.c. Also some code cleanup, and a fix for an (extant unrelated) missing <pthread_np.h> include that should hopefully resolve a failure in the FreeBSD CI build, since it is best to make sure that this MR actually builds on FreeBSD systems other than mine. Some unexpected metric changes on FreeBSD (perhaps because CI had been failing for a while???): Metric Decrease: T3064 T5321Fun T5642 T9020 T12227 T13253-spj T15164 T18282 WWRec Metric Increase: haddock.compiler - - - - - 72b48c44 by Viktor Dukhovni at 2021-04-22T17:00:55-04:00 Block signals in the ticker thread This avoids surprises in the non-threaded runtime with blocked signals killing the process because they're only blocked in the main thread and not in the ticker thread. - - - - - 7bc7eea3 by Viktor Dukhovni at 2021-04-22T17:00:55-04:00 Make tests more portable on FreeBSD - - - - - 0015f019 by Adam Gundry at 2021-04-23T23:05:04+01:00 Rename references to Note [Trees That Grow] consistently [skip ci] I tend to find Notes by (case-sensitive) grep, and I spent a surprisingly long time looking for this Note, because it was referenced inconsistently with different cases, and without the module name. - - - - - d38397fa by Sebastian Graf at 2021-04-26T23:53:56-04:00 Parser: Unbox `ParseResult` Using `UnliftedNewtypes`, unboxed tuples and sums and a few pattern synonyms, we can make `ParseResult` completely allocation-free. Part of #19263. - - - - - 045e5f49 by Oleg Grenrus at 2021-04-26T23:54:34-04:00 Add Eq1 and Ord1 Fixed instances - - - - - 721ea018 by Ben Gamari at 2021-04-26T23:55:09-04:00 codeGen: Teach unboxed sum rep logic about levity Previously Unarise would happily project lifted and unlifted fields to lifted slots. This broke horribly in #19645, where a ByteArray# was passed in a lifted slot and consequently entered. The simplest way to fix this is what I've done here, distinguishing between lifted and unlifted slots in unarise. However, one can imagine more clever solutions, where we coerce the binder to the correct levity with respect to the sum's tag. I doubt that this would be worth the effort. Fixes #19645. - - - - - 9f9fab15 by Ben Gamari at 2021-04-26T23:55:09-04:00 testsuite: Add test for #19645 - - - - - 3339ed49 by Ben Gamari at 2021-04-26T23:55:44-04:00 users-guide: Document deprecation of -funfolding-keeness-factor See #15304. - - - - - 9d34f454 by Ben Gamari at 2021-04-26T23:55:44-04:00 users guide: Various other cleanups - - - - - 06654a6e by Matthew Pickering at 2021-04-26T23:56:18-04:00 Correct treatment of rexported modules in mkModuleNameProvidersMap Before we would get the incorrect error message saying that the rexporting package was the same as the defining package. I think this only affects error messages for now. ``` - it is bound as p-0.1.0.0:P2 by a reexport in package p-0.1.0.0 - it is bound as P by a reexport in package p-0.1.0.0 + it is bound as p-0.1.0.0:P2 by a reexport in package q-0.1.0.0 + it is bound as P by a reexport in package r-0.1.0.0 ``` and the output of `-ddump-mod-map` claimed.. ``` Moo moo-0.0.0.1 (hidden package, reexport by moo-0.0.0.1) ``` - - - - - 6c7fff0b by Simon Peyton Jones at 2021-04-26T23:56:53-04:00 Eliminate unsafeEqualityProof in CorePrep The main idea here is to avoid treating * case e of {} * case unsafeEqualityProof of UnsafeRefl co -> blah specially in CoreToStg. Instead, nail them in CorePrep, by converting case e of {} ==> e |> unsafe-co case unsafeEqualityProof of UnsafeRefl cv -> blah ==> blah[unsafe-co/cv] in GHC.Core.Prep. Now expressions that we want to treat as trivial really are trivial. We can get rid of cpExprIsTrivial. And we fix #19700. A downside is that, at least under unsafeEqualityProof, we substitute in types and coercions, which is more work. But a big advantage is that it's all very simple and principled: CorePrep really gets rid of the unsafeCoerce stuff, as it does empty case, runRW#, lazyId etc. I've updated the overview in GHC.Core.Prep, and added Note [Unsafe coercions] in GHC.Core.Prep Note [Implementing unsafeCoerce] in base:Unsafe.Coerce We get 3% fewer bytes allocated when compiling perf/compiler/T5631, which uses a lot of unsafeCoerces. (It's a happy-generated parser.) Metric Decrease: T5631 - - - - - b9e2491d by Rafal Gwozdzinski at 2021-04-26T23:57:29-04:00 Add GHC.Utils.Error.pprMessages - - - - - 72c1812f by Ben Gamari at 2021-04-26T23:58:16-04:00 rts/m32: Fix bounds check Previously we would check only that the *start* of the mapping was in the bottom 32-bits of address space. However, we need the *entire* mapping to be in low memory. Fix this. Noticed by @Phyx. - - - - - dd0a95a3 by Sasha Bogicevic at 2021-04-26T23:58:56-04:00 18000 Use GHC.IO.catchException in favor of Exception.catch fix #18000 - - - - - c1549069 by Adam Sandberg Ericsson at 2021-04-26T23:59:32-04:00 docs: add a short up-front description for -O, -n, -qn, -I and -Iw - - - - - d9ceb2fb by iori tsu at 2021-04-27T00:00:08-04:00 Add documentation for GHC.Exts.sortWith sortWith has the same type definition as `Data.List.sortOn` (eg: `Ord b => (a -> b) -> [a] -> [a]`). Nonetheless, they behave differently, sortOn being more efficient. This merge request add documentation to reflect on this differences - - - - - dd121fa1 by Ryan Scott at 2021-04-27T00:00:43-04:00 Pretty-print HsArgPar applications correctly (#19737) Previously, the `Outputable` instance for `HsArg` was being used to pretty-print each `HsArgPar` in a list of `HsArg`s individually, which simply doesn't work. In lieu of the `Outputable` instance, we now use a dedicated `pprHsArgsApp` function to print a list of `HsArg`s as a single unit. I have also added documentation to the `Outputable` instance for `HsArg` to more clearly signpost that it is only suitable for debug pretty-printing. Fixes #19737. - - - - - 484a8b2d by Ben Gamari at 2021-04-27T21:57:56-04:00 Introduce -ddump-verbose-inlinings Previously -ddump-inlinings and -dverbose-core2core used in conjunction would have the side-effect of dumping additional information about all inlinings considered by the simplifier. However, I have sometimes wanted this inlining information without the firehose of information produced by -dverbose-core2core. Introduce a new dump flag for this purpose. - - - - - 9ead1b35 by Daniel Rogozin at 2021-04-27T21:58:32-04:00 fix #19736 - - - - - d2399a46 by Sasha Bogicevic at 2021-04-27T21:59:08-04:00 19079 DerivingVia: incorrectly accepts deriving via types with differing runtime representations - - - - - 59cf287d by Sylvain Henry at 2021-04-29T17:26:43-04:00 Refactor divInt# to make it branchless (#18067, #19636) - - - - - 8d069477 by Sylvain Henry at 2021-04-29T17:26:43-04:00 Refactor modInt# to make it branchless - - - - - e50d0675 by Sylvain Henry at 2021-04-29T17:26:43-04:00 Allow divInt#/modInt# to inline (#18067) - - - - - c308c9af by Sylvain Henry at 2021-04-29T17:26:43-04:00 Make divModInt# branchless - - - - - 7bb3443a by Sylvain Henry at 2021-04-29T17:26:43-04:00 Fix inlining of division wrappers - - - - - 7d18e1ba by Alfredo Di Napoli at 2021-04-29T17:27:19-04:00 Add GhcMessage and ancillary types This commit adds GhcMessage and ancillary (PsMessage, TcRnMessage, ..) types. These types will be expanded to represent more errors generated by different subsystems within GHC. Right now, they are underused, but more will come in the glorious future. See https://gitlab.haskell.org/ghc/ghc/-/wikis/Errors-as-(structured)-values for a design overview. Along the way, lots of other things had to happen: * Adds Semigroup and Monoid instance for Bag * Fixes #19746 by parsing OPTIONS_GHC pragmas into Located Strings. See GHC.Parser.Header.toArgs (moved from GHC.Utils.Misc, where it didn't belong anyway). * Addresses (but does not completely fix) #19709, now reporting desugarer warnings and errors appropriately for TH splices. Not done: reporting type-checker warnings for TH splices. * Some small refactoring around Safe Haskell inference, in order to keep separate classes of messages separate. * Some small refactoring around initDsTc, in order to keep separate classes of messages separate. * Separate out the generation of messages (that is, the construction of the text block) from the wrapping of messages (that is, assigning a SrcSpan). This is more modular than the previous design, which mixed the two. Close #19746. This was a collaborative effort by Alfredo di Napoli and Richard Eisenberg, with a key assist on #19746 by Iavor Diatchki. Metric Increase: MultiLayerModules - - - - - 5981ac7d by Ryan Scott at 2021-04-29T17:27:54-04:00 Redesign withDict (formerly magicDict) This gives a more precise type signature to `magicDict` as proposed in #16646. In addition, this replaces the constant-folding rule for `magicDict` in `GHC.Core.Opt.ConstantFold` with a special case in the desugarer in `GHC.HsToCore.Expr.dsHsWrapped`. I have also renamed `magicDict` to `withDict` in light of the discussion in https://mail.haskell.org/pipermail/ghc-devs/2021-April/019833.html. All of this has the following benefits: * `withDict` is now more type safe than before. Moreover, if a user applies `withDict` at an incorrect type, the special-casing in `dsHsWrapped` will now throw an error message indicating what the user did incorrectly. * `withDict` can now work with classes that have multiple type arguments, such as `Typeable @k a`. This means that `Data.Typeable.Internal.withTypeable` can now be implemented in terms of `withDict`. * Since the special-casing for `withDict` no longer needs to match on the structure of the expression passed as an argument to `withDict`, it no longer cares about the presence or absence of `Tick`s. In effect, this obsoletes the fix for #19667. The new `T16646` test case demonstrates the new version of `withDict` in action, both in terms of `base` functions defined in terms of `withDict` as well as in terms of functions from the `reflection` and `singletons` libraries. The `T16646Fail` test case demonstrates the error message that GHC throws when `withDict` is applied incorrectly. This fixes #16646. By adding more tests for `withDict`, this also fixes #19673 as a side effect. - - - - - 51470000 by Ryan Scott at 2021-04-29T17:28:30-04:00 Expand synonyms in mkCastTy when necessary Doing so is important to maintain invariants (EQ3) and (EQ4) from `Note [Respecting definitional equality]` in `GHC.Core.TyCo.Rep`. For the details, see the new `Note [Using coreView in mk_cast_ty]`. Fixes #19742. - - - - - c2541c49 by Ryan Scott at 2021-04-29T17:29:05-04:00 Propagate free variables in extract_lctxt correctly This fixes an oversight in the implementation of `extract_lctxt` which was introduced in commit ce85cffc. Fixes #19759. - - - - - 1d03d8be by Sylvain Henry at 2021-04-29T17:29:44-04:00 Replace (ptext .. sLit) with `text` 1. `text` is as efficient as `ptext . sLit` thanks to the rewrite rules 2. `text` is visually nicer than `ptext . sLit` 3. `ptext . sLit` encourages using one `ptext` for several `sLit` as in: ptext $ case xy of ... -> sLit ... ... -> sLit ... which may allocate SDoc's TextBeside constructors at runtime instead of sharing them into CAFs. - - - - - 2d2985a7 by Adam Sandberg Ericsson at 2021-04-29T17:30:20-04:00 rts: export allocateWrite, freeWrite and markExec #19763 - - - - - c0c0b4e0 by Viktor Dukhovni at 2021-04-30T23:21:34-04:00 Tighten scope of non-POSIX visibility macros The __BSD_VISIBLE and _DARWIN_C_SOURCE macros expose non-POSIX prototypes in system header files. We should scope these to just the ".c" modules that actually need them, and avoid defining them in header files used in other C modules. - - - - - c7ca3619 by Sylvain Henry at 2021-04-30T23:22:13-04:00 Interpreter: replace DynFlags with EvalOpts/BCOOpts - - - - - 491266ee by Sylvain Henry at 2021-04-30T23:22:13-04:00 Make GHC.Runtime.Interpreter independent of GHC.Driver - - - - - 48c2c2af by Sylvain Henry at 2021-04-30T23:22:13-04:00 Fix genprimopcode warning - - - - - 6623790d by Sylvain Henry at 2021-04-30T23:22:13-04:00 Hadrian: build check-* with -Wall/-Werror Otherwise CI fails only with make build system. - - - - - 460afbe6 by Ryan Scott at 2021-04-30T23:22:48-04:00 Bring tcTyConScopedTyVars into scope in tcClassDecl2 It is possible that the type variables bound by a class header will map to something different in the typechecker in the presence of `StandaloneKindSignatures`. `tcClassDecl2` was not aware of this, however, leading to #19738. To fix it, in `tcTyClDecls` we map each class `TcTyCon` to its `tcTyConScopedTyVars` as a `ClassScopedTVEnv`. We then plumb that `ClassScopedTVEnv` to `tcClassDecl2` where it can be used. Fixes #19738. - - - - - e61d2d47 by Sylvain Henry at 2021-04-30T23:23:26-04:00 Make sized division primops ok-for-spec (#19026) - - - - - 1b9df111 by Harry Garrood harry at garrood.me at 2021-05-03T19:48:21-04:00 Add test case for #8144 Fixes #8144 - - - - - 4512ad2d by John Ericson at 2021-05-03T19:48:56-04:00 Use fix-sized bit-fiddling primops for fixed size boxed types Like !5572, this is switching over a portion of the primops which seems safe to use. - - - - - 8d6b2525 by Sylvain Henry at 2021-05-03T19:48:56-04:00 Move shift ops out of GHC.Base With a quick flavour I get: before T12545(normal) ghc/alloc 8628109152 after T12545(normal) ghc/alloc 8559741088 - - - - - 3a2f2475 by bit at 2021-05-03T19:49:32-04:00 Update documentation of 'Weak' - - - - - 4e546834 by Tamar Christina at 2021-05-03T19:50:10-04:00 pe: enable code unloading for Windows - - - - - 5126a07e by Philipp Dargel at 2021-05-03T19:50:46-04:00 Remove duplicate modules in GHCi %s prompt fixes #19757 - - - - - 0680e9a5 by Hécate Moonlight at 2021-05-03T19:51:22-04:00 Disable HLint colours closes #19776 - - - - - 7f5ee719 by iori tsu at 2021-05-03T19:51:58-04:00 visually align expected and actual modules name before: > /home/matt/Projects/persistent/persistent/Database/Persist/ImplicitIdDef.hs:1:8: error: > File name does not match module name: > Saw: ‘A.B.Module’ > Expected: ‘A.B.Motule’ > | > 1 | module A.B.Motule > | ^^^^^^^^^^> after: > /home/matt/Projects/persistent/persistent/Database/Persist/ImplicitIdDef.hs:1:8: error: > File name does not match module name: > Saw: ‘A.B.Module’ > Expected: ‘A.B.Motule’ > | > 1 | module A.B.Motule > | ^^^^^^^^^^> - - - - - 24a9b170 by sheaf at 2021-05-03T19:52:34-04:00 Improve hs-boot binds error (#19781) - - - - - 39020600 by Roland Senn at 2021-05-04T16:00:13-04:00 Tweak function `quantifyType` to fix #12449 In function `compiler/GHC/Runtime/Heap/Inspect.hs:quantifyType` replace `tcSplitForAllInvisTyVars` by `tcSplitNestedSigmaTys`. This will properly split off the nested foralls in examples like `:print fmap`. Do not remove the `forall`s from the `snd` part of the tuple returned by `quantifyType`. It's not necessary and the reason for the bug in #12449. Some code simplifications at the calling sites of `quantifyTypes`. - - - - - 6acadb79 by Simon Peyton Jones at 2021-05-04T16:00:48-04:00 Persist CorePrepProv into IfaceUnivCoProv CorePrepProv is only created in CorePrep, so I thought it wouldn't be needed in IfaceUnivCoProv. But actually IfaceSyn is used during pretty-printing, and we can certainly pretty-print things after CorePrep as #19768 showed. So the simplest thing is to represent CorePrepProv in IfaceSyn. To improve what Lint can do I also added a boolean to CorePrepProv, to record whether it is homogeneously kinded or not. It is introduced in two distinct ways (see Note [Unsafe coercions] in GHC.CoreToStg.Prep), one of which may be hetero-kinded (e.g. Int ~ Int#) beause it is casting a divergent expression; but the other is not. The boolean keeps track. - - - - - 7ffbdc3f by Ben Gamari at 2021-05-05T05:42:38-04:00 Break up aclocal.m4 - - - - - 34452fbd by Ben Gamari at 2021-05-05T05:42:38-04:00 configure: Move pthreads checks to macro - - - - - 0de2012c by Ben Gamari at 2021-05-05T05:42:38-04:00 configure: Move libnuma check to macro - - - - - 958c6fbd by Ben Gamari at 2021-05-05T05:42:38-04:00 configure: Move libdw search logic to macro - - - - - 101d25fc by Alfredo Di Napoli at 2021-05-05T05:43:14-04:00 Add some DriverMessage type constructors This commit expands the DriverMessage type with new type constructors, making the number of diagnostics GHC can emit richer. In particular: * Add DriverMissingHomeModules message * Add DriverUnusedPackage message * Add DriverUnnecessarySourceImports message This commit adds the `DriverUnnecessarySourceImports` message and fixes a small bug in its reporting: inside `warnUnnecessarySourceImports` we were checking for `Opt_WarnUnusedSourceImports` to be set, but we were emitting the diagnostic with `WarningWithoutFlag`. This also adjusts the T10637 test to reflect that. * Add DriverDuplicatedModuleDeclaration message * Add DriverModuleNotFound message * Add DriverFileModuleNameMismatch message * Add DriverUnexpectedSignature message * Add DriverFileNotFound message * Add DriverStaticPointersNotSupported message * Add DriverBackpackModuleNotFound message - - - - - e9617fba by Matthew Pickering at 2021-05-05T05:43:49-04:00 test driver: Make sure RESIDENCY_OPTS is passed for 'all' perf tests Fixes #19731 ------------------------- Metric Decrease: T11545 Metric Increase: T12545 T15304 ------------------------- - - - - - f464e477 by Jaro Reinders at 2021-05-05T05:44:26-04:00 More specific error messages for annotations (fixes #19740) - - - - - 3280eb22 by Luite Stegeman at 2021-05-05T05:45:03-04:00 support LiftedRep and UnliftedRep in GHCi FFI fixes #19733 - - - - - 049c3a83 by Hécate Moonlight at 2021-05-05T05:45:39-04:00 Add an .editorconfig file closes #19793 - - - - - a5e9e5b6 by Ben Gamari at 2021-05-06T02:30:18-04:00 Re-introduce Note [keepAlive# magic] Somewhere in the course of forward- and back-porting the keepAlive# branch the Note which described the mechanism was dropped. Reintroduce it. Closes #19712. - - - - - c4f4193a by John Ericson at 2021-05-06T02:30:54-04:00 Use fix-sized arithmetic primops for fixed size boxed types We think the compiler is ready, so we can do this for all over the 8-, 16-, and 32-bit boxed types. We are holding off on doing all the primops at once so things are easier to investigate. Metric Decrease: T12545 - - - - - 418295ea by Sasha Bogicevic at 2021-05-06T02:31:31-04:00 19486 Nearly all uses of `uniqCompareFS` are dubious and lack a non-determinism justification - - - - - 1635d5c2 by Alan Zimmerman at 2021-05-06T02:32:06-04:00 EPA: properly capture semicolons between Matches in a FunBind For the source module MatchSemis where { a 0 = 1; a _ = 2; } Make sure that the AddSemiAnn entries for the two trailing semicolons are attached to the component Match elements. Closes #19784 - - - - - e5778365 by PHO at 2021-05-06T02:32:44-04:00 rts/posix/GetTime.c: Use Solaris-specific gethrvtime(3) on OpenSolaris derivatives The constant CLOCK_THREAD_CPUTIME_ID is defined in a system header but it isn't acutally usable. clock_gettime(2) always returns EINVAL. - - - - - 87d8c008 by Ben Gamari at 2021-05-06T12:44:06-04:00 Bump binary submodule Fixes #19631. - - - - - 0281dae8 by Aaron Allen at 2021-05-06T12:44:43-04:00 Disallow -XDerivingVia when -XSafe is on (#19786) Since `GeneralizedNewtypeDeriving` is considered unsafe, `DerivingVia` should be as well. - - - - - 30f6923a by Ben Gamari at 2021-05-06T12:45:19-04:00 hadrian: Don't depend upon bash from PATH Previously Hadrian depended implicitly upon whatever `bash` it found in `PATH`, offerring no way for the user to override. Fix this by detecting `sh` in `configure` and passing the result to Hadrian. Fixes #19797. - - - - - c5454dc7 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [ci] Add support for building on aarch64-darwin This will fail for now. But allows us to add aarch64-darwin machines to CI. (cherry picked from commit a7d22795ed118abfe64f4fc55d96d8561007ce1e) - - - - - 41b0c288 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [testlib/driver] denoise this prevents the testlib/driver to be overly noisy, and will also kill some noise produiced by the aarch64-darwin cc (for now). Fixing sysctl, will allow us to run the test's properly in a nix-shell on aarch64-darwin (cherry picked from commit 5109e87e13ab45d799db2013535f54ca35f1f4dc) - - - - - bb78df78 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [ci] default value for CONFIGURE_ARGS (cherry picked from commit 307d34945b7d932156e533736c91097493e6181b) - - - - - 5f5b02c2 by Moritz Angermann at 2021-05-07T09:17:22+08:00 [ci] Default value for MAKE_ARGS We don't pass MAKE_ARGS for windows builds, so this should unbreak them. (cherry picked from commit 16c13d5acfdc8053f7de9e908cc9d845e9bd34bb) - - - - - 79019dd6 by Moritz Angermann at 2021-05-07T09:17:23+08:00 [testsuite/darwin] fix conc059 This resolves the following: Compile failed (exit code 1) errors were: conc059_c.c:27:5: error: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration] exit(0); ^ conc059_c.c:27:5: error: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit' (cherry picked from commit 5a6c36ecb41fccc07c1b01fe0f330cd38c2a0c76) - - - - - 8a36ebfa by Moritz Angermann at 2021-05-07T09:17:23+08:00 [Aarch64] No div-by-zero; disable test. (cherry picked from commit 3592d1104c47b006fd9f4127d93916f477a6e010) - - - - - 10b5dc88 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [Darwin] mark stdc++ tests as broken There is no libstdc++, only libc++ (cherry picked from commit 57671071adeaf0b45e86bb0ee050e007e3b161fb) - - - - - 035f4bb1 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [testsuite] filter out superfluous dylib warnings (cherry picked from commit 33c4d497545559a38bd8d1caf6c94e5e2a77647b) - - - - - 3f09c6f8 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [ci/nix-shell] Add Foundation and Security (cherry picked from commit 4bea83afec009dfd3c6313cac4610d00ba1f9a3d) - - - - - 65440597 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [testsuite/json2] Fix failure with LLVM backends -Wno-unsupported-llvm-version should suppress the LLVM version missmatch warning that messes up the output. (cherry picked from commit 63455300625fc12b2aafc3e339eb307510a6e8bd) - - - - - 582fc583 by Moritz Angermann at 2021-05-07T09:19:47+08:00 [ci/nix-shell] [Darwin] Stop the ld warnings about libiconv. (cherry picked from commit c3944bc89d062a4850946904133c7a1464d59012) - - - - - 7df44e43 by Moritz Angermann at 2021-05-07T09:19:48+08:00 [testsuite] static001 is not broken anymore. (cherry picked from commit b821fcc7142edff69aa4c47dc1a5bd30b13c1ceb) - - - - - 49839322 by Moritz Angermann at 2021-05-07T09:19:48+08:00 [testsuite/arm64] fix section_alignment (cherry picked from commit f7062e1b0c91e8aa78e245a3dab9571206fce16d) - - - - - ccea6117 by Moritz Angermann at 2021-05-07T09:19:48+08:00 [ci/nix-shell] uniquify NIX_LDFLAGS{_FOR_TARGET} (cherry picked from commit 07b1af0362beaaf221cbee7b17bbe0a5606fd87d) - - - - - cceb461a by Moritz Angermann at 2021-05-07T09:19:48+08:00 [darwin] stop the DYLD_LIBRARY_PATH madness this causes *significant* slowdown on macOS as the linker ends up looking through all the paths. Slowdown can be as bad as 100% or more. (cherry picked from commit 820b0766984d42c06c977a6c32da75c429106f7f) - - - - - a664a2ad by Moritz Angermann at 2021-05-07T09:19:48+08:00 [ci] Default values for CI_COMMIT_BRANCH, CI_PROJECT_PATH - - - - - 8e0f48bd by Simon Peyton Jones at 2021-05-07T09:43:57-04:00 Allow visible type application for levity-poly data cons This patch was driven by #18481, to allow visible type application for levity-polymorphic newtypes. As so often, it started simple but grew: * Significant refactor: I removed HsConLikeOut from the client-independent Language.Haskell.Syntax.Expr, and put it where it belongs, as a new constructor `ConLikeTc` in the GHC-specific extension data type for expressions, `GHC.Hs.Expr.XXExprGhcTc`. That changed touched a lot of files in a very superficial way. * Note [Typechecking data constructors] explains the main payload. The eta-expansion part is no longer done by the typechecker, but instead deferred to the desugarer, via `ConLikeTc` * A little side benefit is that I was able to restore VTA for data types with a "stupid theta": #19775. Not very important, but the code in GHC.Tc.Gen.Head.tcInferDataCon is is much, much more elegant now. * I had to refactor the levity-polymorphism checking code in GHC.HsToCore.Expr, see Note [Checking for levity-polymorphic functions] Note [Checking levity-polymorphic data constructors] - - - - - 740103c5 by PHO at 2021-05-07T20:06:43-04:00 rts/posix/OSThreads.c: Implement getNumberOfProcessors() for NetBSD - - - - - 39be3283 by PHO at 2021-05-07T20:06:43-04:00 rts: Correctly call pthread_setname_np() on NetBSD NetBSD supports pthread_setname_np() but it expects a printf-style format string and a string argument. Also use pthread for itimer on this platform. - - - - - a32eb0f3 by Simon Peyton Jones at 2021-05-07T20:07:19-04:00 Fix newtype eta-reduction The eta-reduction we do for newype axioms was generating an inhomogeneous axiom: see #19739. This patch fixes it in a simple way; see GHC.Tc.TyCl.Build Note [Newtype eta and homogeneous axioms] - - - - - ad5a3aeb by Alan Zimmerman at 2021-05-08T11:19:26+01:00 EPA: update some comments in Annotations. Follow-up from !2418, see #19579 - - - - - 736d47ff by Alan Zimmerman at 2021-05-09T18:13:40-04:00 EPA: properly capture leading semicolons in statement lists For the fragment blah = do { ; print "a" ; print "b" } capture the leading semicolon before 'print "a"' in 'al_rest' in AnnList instead of in 'al_trailing'. Closes #19798 - - - - - c4a85e3b by Andreas Klebinger at 2021-05-11T05:34:52-04:00 Expand Note [Data con representation]. Not perfect. But I consider this to be a documentation fix for #19789. - - - - - 087ac4eb by Simon Peyton Jones at 2021-05-11T05:35:27-04:00 Minor refactoring in WorkWrap This patch just does the tidying up from #19805. No change in behaviour. - - - - - 32367cac by Alan Zimmerman at 2021-05-11T05:36:02-04:00 EPA: Use custom AnnsIf structure for HsIf and HsCmdIf This clearly identifies the presence and location of optional semicolons in an if statement. Closes #19813 - - - - - 09918343 by Andreas Klebinger at 2021-05-11T16:58:38-04:00 Don't warn about ClassOp bindings not specialising. Fixes #19586 - - - - - 5daf1aa9 by Andreas Klebinger at 2021-05-11T16:59:17-04:00 Document unfolding treatment of simplLamBndr. Fixes #19817 - - - - - c7717949 by Simon Peyton Jones at 2021-05-11T23:00:27-04:00 Fix strictness and arity info in SpecConstr In GHC.Core.Opt.SpecConstr.spec_one we were giving join-points an incorrect join-arity -- this was fallout from commit c71b220491a6ae46924cc5011b80182bcc773a58 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu Apr 8 23:36:24 2021 +0100 Improvements in SpecConstr * Allow under-saturated calls to specialise See Note [SpecConstr call patterns] This just allows a bit more specialisation to take place. and showed up in #19780. I refactored the code to make the new function calcSpecInfo which treats join points separately. In doing this I discovered two other small bugs: * In the Var case of argToPat we were treating UnkOcc as uninteresting, but (by omission) NoOcc as interesting. As a result we were generating SpecConstr specialisations for functions with unused arguments. But the absence anlyser does that much better; doing it here just generates more code. Easily fixed. * The lifted/unlifted test in GHC.Core.Opt.WorkWrap.Utils.mkWorkerArgs was back to front (#19794). Easily fixed. * In the same function, mkWorkerArgs, we were adding an extra argument nullary join points, which isn't necessary. I added a test for this. That in turn meant I had to remove an ASSERT in CoreToStg.mkStgRhs for nullary join points, which was always bogus but now trips; I added a comment to explain. - - - - - c3868451 by Alan Zimmerman at 2021-05-11T23:01:03-04:00 EPA: record annotations for braces in LetStmt Closes #19814 - - - - - 6967088d by Ben Gamari at 2021-05-11T23:01:38-04:00 base: Update Unicode data to 13.0.0 (cherry picked from commit d22e087f7bf74341c4468f11b4eb0273033ca931) - - - - - 673ff667 by Matthew Pickering at 2021-05-11T23:02:14-04:00 hadrian: Don't always links against libffi The RTS flag `ffi` is set to either True or False depending on whether we want to link against `libffi`, therefore in order to work out whether to add the build tree to the arguments we check whether `ffi` is in the extraLibs or not before adding the argument. Fixes #16022 - - - - - d22e8d89 by Matthew Pickering at 2021-05-11T23:02:50-04:00 rts: Remove trailing whitespace from Adjustor.c - - - - - f0b73ddd by Sylvain Henry at 2021-05-11T23:03:28-04:00 Hadrian: add comment to avoid surprises - - - - - 55223780 by Andreas Klebinger at 2021-05-12T14:49:23-04:00 W/W: Always zap useless idInfos. tryWW used to always returns an Id with a zapped: * DmdEnv * Used Once info except in the case where the ID was guaranteed to be inlined. We now also zap the info in that case. Fixes #19818. - - - - - 541665b7 by Matthew Pickering at 2021-05-12T14:49:58-04:00 hadrian: Fix dynamic+debug flag combination for check-ppr executable - - - - - a7473e03 by Peter Trommler at 2021-05-12T14:50:33-04:00 Hadrian: Enable SMP on powerpc64{le} Fixes #19825 - - - - - f78c25da by Sylvain Henry at 2021-05-12T21:41:43-04:00 Move GlobalVar macros into GHC.Utils.GlobalVars That's the only place where they are used and they shouldn't be used elsewhere. - - - - - da56ed41 by Sylvain Henry at 2021-05-12T21:41:43-04:00 Ensure assert from Control.Exception isn't used - - - - - bfabf94f by Sylvain Henry at 2021-05-12T21:41:43-04:00 Replace CPP assertions with Haskell functions There is no reason to use CPP. __LINE__ and __FILE__ macros are now better replaced with GHC's CallStack. As a bonus, assert error messages now contain more information (function name, column). Here is the mapping table (HasCallStack omitted): * ASSERT: assert :: Bool -> a -> a * MASSERT: massert :: Bool -> m () * ASSERTM: assertM :: m Bool -> m () * ASSERT2: assertPpr :: Bool -> SDoc -> a -> a * MASSERT2: massertPpr :: Bool -> SDoc -> m () * ASSERTM2: assertPprM :: m Bool -> SDoc -> m () - - - - - 0ef11907 by Sylvain Henry at 2021-05-12T21:41:44-04:00 Fully remove HsVersions.h Replace uses of WARN macro with calls to: warnPprTrace :: Bool -> SDoc -> a -> a Remove the now unused HsVersions.h Bump haddock submodule - - - - - 67a5a91e by Sylvain Henry at 2021-05-12T21:41:44-04:00 Remove useless {-# LANGUAGE CPP #-} pragmas - - - - - c34f4c0c by Alan Zimmerman at 2021-05-12T21:42:21-04:00 EPA: Fix incorrect SrcSpan for FamDecl The SrcSpan for a type family declaration did not include the family equations. Closes #19821 - - - - - e0ded198 by Matthew Pickering at 2021-05-12T21:42:57-04:00 ci: Fix unbound CI_MERGE_REQUEST_SOURCE_BRANCH_NAME variable Fixes #19831 - - - - - c6de5805 by John Ericson at 2021-05-13T16:44:23-04:00 Use fix-sized order primops for fixed size boxed types Progress towards #19026 - - - - - fc9546ca by Sylvain Henry at 2021-05-13T16:45:03-04:00 genprimopcode: fix bootstrap errors * Fix for unqualified Data.List import * Fix monad instance - - - - - 60f088b3 by Matthew Pickering at 2021-05-19T09:10:16+01:00 CI: Disable darwin builds They are taking over 4 hours to complete which is stalling the rest of the merge pipeline. - - - - - baa969c3 by Koz Ross at 2021-05-19T23:31:51-04:00 Implement bitwise infix ops - - - - - c8564c63 by Alfredo Di Napoli at 2021-05-19T23:32:27-04:00 Add some TcRn diagnostic messages This commit converts some TcRn diagnostic into proper structured errors. Ported by this commit: * Add TcRnImplicitLift This commit adds the TcRnImplicitLift diagnostic message and a prototype API to be able to log messages which requires additional err info. * Add TcRnUnusedPatternBinds * Add TcRnDodgyExports * Add TcRnDodgyImports message * Add TcRnMissingImportList - - - - - 38faeea1 by Matthew Pickering at 2021-05-19T23:33:02-04:00 Remove transitive information about modules and packages from interface files This commit modifies interface files so that *only* direct information about modules and packages is stored in the interface file. * Only direct module and direct package dependencies are stored in the interface files. * Trusted packages are now stored separately as they need to be checked transitively. * hs-boot files below the compiled module in the home module are stored so that eps_is_boot can be calculated in one-shot mode without loading all interface files in the home package. * The transitive closure of signatures is stored separately This is important for two reasons * Less recompilation is needed, as motivated by #16885, a lot of redundant compilation was triggered when adding new imports deep in the module tree as all the parent interface files had to be redundantly updated. * Checking an interface file is cheaper because you don't have to perform a transitive traversal to check the dependencies are up-to-date. In the code, places where we would have used the transitive closure, we instead compute the necessary transitive closure. The closure is not computed very often, was already happening in checkDependencies, and was already happening in getLinkDeps. Fixes #16885 ------------------------- Metric Decrease: MultiLayerModules T13701 T13719 ------------------------- - - - - - 29d104c6 by nineonine at 2021-05-19T23:33:40-04:00 Implement :info for record pattern synonyms (#19462) - - - - - d45e3cda by Matthew Pickering at 2021-05-19T23:34:15-04:00 hadrian: Make copyFileLinked a bit more robust Previously it only worked if the two files you were trying to symlink were already in the same directory. - - - - - 176b1305 by Matthew Pickering at 2021-05-19T23:34:15-04:00 hadrian: Build check-ppr and check-exact using normal hadrian rules when in-tree Fixes #19606 #19607 - - - - - 3c04e7ac by Andreas Klebinger at 2021-05-19T23:34:49-04:00 Fix LitRubbish being applied to values. This fixes #19824 - - - - - 32725617 by Matthew Pickering at 2021-05-19T23:35:24-04:00 Tidy: Ignore rules (more) when -fomit-interface-pragmas is on Before this commit, the RHS of a rule would expose additional definitions, despite the fact that the rule wouldn't get exposed so it wouldn't be possible to ever use these definitions. The net-result is slightly less recompilation when specialisation introduces rules. Related to #19836 - - - - - 10ae305e by Alan Zimmerman at 2021-05-19T23:35:59-04:00 EPA: Remove duplicate annotations from HsDataDefn They are repeated in the surrounding DataDecl and FamEqn. Updates haddock submodule Closes #19834 - - - - - 8e7f02ea by Richard Eisenberg at 2021-05-19T23:36:35-04:00 Point posters to ghc-proposals - - - - - 6844ead4 by Matthew Pickering at 2021-05-19T23:37:09-04:00 testsuite: Don't copy .hi-boot and .o-boot files into temp dir - - - - - e87b8e10 by Sebastian Graf at 2021-05-19T23:37:44-04:00 CPR: Detect constructed products in `runRW#` apps (#19822) In #19822, we realised that the Simplifier's new habit of floating cases into `runRW#` continuations inhibits CPR analysis from giving key functions of `text` the CPR property, such as `singleton`. This patch fixes that by anticipating part of !5667 (Nested CPR) to give `runRW#` the proper CPR transformer it now deserves: Namely, `runRW# (\s -> e)` should have the CPR property iff `e` has it. The details are in `Note [Simplification of runRW#]` in GHC.CoreToStg.Prep. The output of T18086 changed a bit: `panic` (which calls `runRW#`) now has `botCpr`. As outlined in Note [Bottom CPR iff Dead-Ending Divergence], that's OK. Fixes #19822. Metric Decrease: T9872d - - - - - d3ef2dc2 by Baldur Blöndal at 2021-05-19T23:38:20-04:00 Add pattern TypeRep (#19691), exported by Type.Reflection. - - - - - f192e623 by Sylvain Henry at 2021-05-19T23:38:58-04:00 Cmm: fix sinking after suspendThread Suppose a safe call: myCall(x,y,z) It is lowered into three unsafe calls in Cmm: r = suspendThread(...); myCall(x,y,z); resumeThread(r); Consider the following situation for myCall arguments: x = Sp[..] -- stack y = Hp[..] -- heap z = R1 -- global register r = suspendThread(...); myCall(x,y,z); resumeThread(r); The sink pass assumes that unsafe calls clobber memory (heap and stack), hence x and y assignments are not sunk after `suspendThread`. The sink pass also correctly handles global register clobbering for all unsafe calls, except `suspendThread`! `suspendThread` is special because it releases the capability the thread is running on. Hence the sink pass must also take into account global registers that are mapped into memory (in the capability). In the example above, we could get: r = suspendThread(...); z = R1 myCall(x,y,z); resumeThread(r); But this transformation isn't valid if R1 is (BaseReg->rR1) as BaseReg is invalid between suspendThread and resumeThread. This caused argument corruption at least with the C backend ("unregisterised") in #19237. Fix #19237 - - - - - df4a0a53 by Sylvain Henry at 2021-05-19T23:39:37-04:00 Bignum: bump to version 1.1 (#19846) - - - - - d48b7e5c by Shayne Fletcher at 2021-05-19T23:40:12-04:00 Changes to HsRecField' - - - - - 441fdd6c by Adam Sandberg Ericsson at 2021-05-19T23:40:47-04:00 driver: check if clang is the assembler when passing clang specific arguments (#19827) Previously we assumed that the assembler was the same as the c compiler, but we allow setting them to different programs with -pgmc and -pgma. - - - - - 6a577cf0 by Peter Trommler at 2021-05-19T23:41:22-04:00 PPC NCG: Fix unsigned compare with 16-bit constants Fixes #19852 and #19609 - - - - - c4099b09 by Matthew Pickering at 2021-05-19T23:41:57-04:00 Make setBndrsDemandInfo work with only type variables Fixes #19849 Co-authored-by: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> - - - - - 4b5de954 by Matthew Pickering at 2021-05-19T23:42:32-04:00 constant folding: Make shiftRule for Word8/16/32# types return correct type Fixes #19851 - - - - - 82b097b3 by Sylvain Henry at 2021-05-19T23:43:09-04:00 Remove wired-in names hs-boot check bypass (#19855) The check bypass is no longer necessary and the check would have avoided #19638. - - - - - 939a56e7 by Baldur Blöndal at 2021-05-19T23:43:46-04:00 Added new regresion test for #18036 from ticket #19865. - - - - - 43139064 by Ben Gamari at 2021-05-20T11:36:55-04:00 gitlab-ci: Add Alpine job linking against gmp integer backend As requested by Michael Snoyman. - - - - - 7c066734 by Roland Senn at 2021-05-20T11:37:32-04:00 Use pprSigmaType to print GHCi debugger Suspension Terms (Fix #19355) In the GHCi debugger use the function `pprSigmaType` to print out Suspension Terms. The function `pprSigmaType` respect the flag `-f(no-)print-explicit-foralls` and so it fixes #19355. Switch back output of existing tests to default mode (no explicit foralls). - - - - - aac87bd3 by Alfredo Di Napoli at 2021-05-20T18:08:37-04:00 Extensible Hints for diagnostic messages This commit extends the GHC diagnostic hierarchy with a `GhcHint` type, modelling helpful suggestions emitted by GHC which can be used to deal with a particular warning or error. As a direct consequence of this, the `Diagnostic` typeclass has been extended with a `diagnosticHints` method, which returns a `[GhcHint]`. This means that now we can clearly separate out the printing of the diagnostic message with the suggested fixes. This is done by extending the `printMessages` function in `GHC.Driver.Errors`. On top of that, the old `PsHint` type has been superseded by the new `GhcHint` type, which de-duplicates some hints in favour of a general `SuggestExtension` constructor that takes a `GHC.LanguageExtensions.Extension`. - - - - - 649d63db by Divam at 2021-05-20T18:09:13-04:00 Add tests for code generation options specified via OPTIONS_GHC in multi module compilation - - - - - 5dcb8619 by Matthías Páll Gissurarson at 2021-05-20T18:09:50-04:00 Add exports to GHC.Tc.Errors.Hole (fixes #19864) - - - - - 703c0c3c by Sylvain Henry at 2021-05-20T18:10:31-04:00 Bump libffi submodule to libffi-3.3 (#16940) - - - - - d9eb8bbf by Jakob Brünker at 2021-05-21T06:22:47-04:00 Only suggest names that make sense (#19843) * Don't show suggestions for similar variables when a data constructor in a pattern is not in scope. * Only suggest record fields when a record field for record creation or updating is not in scope. * Suggest similar record fields when a record field is not in scope with -XOverloadedRecordDot. * Show suggestions for data constructors if a type constructor or type is not in scope, but only if -XDataKinds is enabled. Fixes #19843. - - - - - ec10cc97 by Matthew Pickering at 2021-05-21T06:23:26-04:00 hadrian: Reduce verbosity on failed testsuite run When the testsuite failed before it would print a big exception which gave you the very long command line which was used to invoke the testsuite. By capturing the exit code and rethrowing the exception, the error is must less verbose: ``` Error when running Shake build system: at want, called at src/Main.hs:104:30 in main:Main * Depends on: test * Raised the exception: user error (tests failed) ``` - - - - - f5f74167 by Matthew Pickering at 2021-05-21T06:24:02-04:00 Only run armv7-linux-deb10 build nightly - - - - - 6eed426b by Sylvain Henry at 2021-05-21T06:24:44-04:00 SysTools: make file copy more efficient - - - - - 0da85d41 by Alan Zimmerman at 2021-05-21T15:05:44-04:00 EPA: Fix explicit specificity and unicode linear arrow annotations Closes #19839 Closes #19840 - - - - - 5ab174e4 by Alan Zimmerman at 2021-05-21T15:06:20-04:00 Remove Maybe from Context in HsQualTy Updates haddock submodule Closes #19845 - - - - - b4d240d3 by Matthew Pickering at 2021-05-22T00:07:42-04:00 hadrian: Reorganise modules so KV parser can be used to define transformers - - - - - 8c871c07 by Matthew Pickering at 2021-05-22T00:07:42-04:00 hadrian: Add omit_pragmas transformer This transformer builds stage2 GHC with -fomit-interface-pragmas which can greatly reduce the amount of rebuilding but still allows most the tests to pass. - - - - - c6806912 by Matthew Pickering at 2021-05-22T00:08:18-04:00 Remove ANN pragmas in check-ppr and check-exact This fixes the `devel2+werror` build combo as stage1 does not have TH enabled. ``` utils/check-exact/Preprocess.hs:51:1: error: [-Werror] Ignoring ANN annotations, because this is a stage-1 compiler without -fexternal-interpreter or doesn't support GHCi | 51 | {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` - - - - - e2d4f241 by PHO at 2021-05-22T00:08:55-04:00 Support NetBSD/aarch64 via LLVM codegen Only adding "aarch64-unknown-netbsd" to gen-data-layout.sh was sufficient to get it working. No other changes were strictly required. - - - - - ef4d2999 by nineonine at 2021-05-22T00:09:32-04:00 Add regression test for #19287 - - - - - 0b1eed74 by Shayne Fletcher at 2021-05-23T08:02:58+10:00 Change representation of field selector occurences - Change the names of the fields in in `data FieldOcc` - Renames `HsRecFld` to `HsRecSel` - Replace `AmbiguousFieldOcc p` in `HsRecSel` with `FieldOcc p` - Contains a haddock submodule update The primary motivation of this change is to remove `AmbiguousFieldOcc`. This is one of a suite of changes improving how record syntax (most notably record update syntax) is represented in the AST. - - - - - 406cd90b by Alan Zimmerman at 2021-05-23T02:07:36-04:00 EPA: AnnAt missing for type application in patterns Ensure that the exact print annotations accurately record the `@` for code like tyApp :: Con k a -> Proxy a tyApp (Con @kx @ax (x :: Proxy ax)) = x :: Proxy (ax :: kx) Closes #19850 - - - - - 82c6a939 by Vladislav Zavialov at 2021-05-23T18:53:13-04:00 Pre-add test case for #19156 - - - - - d82d3823 by Vladislav Zavialov at 2021-05-23T18:53:13-04:00 Introduce Strict.Maybe, Strict.Pair (#19156) This patch fixes a space leak related to the use of Maybe in RealSrcSpan by introducing a strict variant of Maybe. In addition to that, it also introduces a strict pair and uses the newly introduced strict data types in a few other places (e.g. the lexer/parser state) to reduce allocations. Includes a regression test. - - - - - f8c6fce4 by Vladislav Zavialov at 2021-05-23T18:53:50-04:00 HsToken for HsPar, ParPat, HsCmdPar (#19523) This patch is a first step towards a simpler design for exact printing. - - - - - fc23ae89 by nineonine at 2021-05-24T00:14:53-04:00 Add regression test for #9985 - - - - - 3e4ef4b2 by Sylvain Henry at 2021-05-24T00:15:33-04:00 Move warning flag handling into Flags module I need this to make the Logger independent of DynFlags. Also fix copy-paste errors: Opt_WarnNonCanonicalMonadInstances was associated to "noncanonical-monadfail-instances" (MonadFailInstances vs MonadInstances). In the process I've also made the default name for each flag more explicit. - - - - - 098c7794 by Matthew Pickering at 2021-05-24T09:47:52-04:00 check-{ppr/exact}: Rewrite more directly to just parse files There was quite a large amount of indirection in these tests, so I have rewritten them to just directly parse the files rather than making a module graph and entering other twisty packages. - - - - - a3665a7a by Matthew Pickering at 2021-05-24T09:48:27-04:00 docs: Fix example in toIntegralSized Thanks to Mathnerd3141 for the fixed example. Fixes #19880 - - - - - f243acf4 by Divam at 2021-05-25T05:50:51-04:00 Refactor driver code; de-duplicate and split APIs (#14095, !5555) This commit does some de-duplication of logic between the one-shot and --make modes, and splitting of some of the APIs so that its easier to do the fine-grained parallelism implementation. This is the first part of the implementation plan as described in #14095 * compileOne now uses the runPhase pipeline for most of the work. The Interpreter backend handling has been moved to the runPhase. * hscIncrementalCompile has been broken down into multiple APIs. * haddock submodule bump: Rename of variables in html-test ref: This is caused by a change in ModDetails in case of NoBackend. Now the initModDetails is used to recreate the ModDetails from interface and in-memory ModDetails is not used. - - - - - 6ce8e687 by Zubin Duggal at 2021-05-25T05:51:26-04:00 Make tcIfaceCompleteMatch lazier. Insufficient lazyness causes a loop while typechecking COMPLETE pragmas from interfaces (#19744). - - - - - 8f22af8c by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci] darwin uses hadrian Make is bad, and really slow, and we should just stop using it outright, or kill hadrian. Let's rather go for hadrian all the way and phase out make. - - - - - 4d100f68 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci] no more brew or pip We pull dependencies (reliably) via nix, and open up nix where needed. - - - - - c67c9e82 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [bindist] inject xattr -c -r . into the darwin install phase This is so awful, but at least it might get the job done. - - - - - 544414ba by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci/darwin] use system provided iconv and curses Also make sure to be able to build with non-apple-clang, while using apple's SDK on macOS - - - - - 527543fc by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci/darwin] cabal-cache dir can be specified per arch Also while we are at it, run shellcheck on ci.sh - - - - - 7b1eeabf by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci/darwin] set SH to /bin/bash This should prevent some other `bash` to leak into the binary distributions. - - - - - f101e019 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [hadrian] Do not add full tool paths This prohuibits CC=clang to work generically and will always bake in the clang that is found on the build machine in PATH, what ever clang that might be. It might not even be on the final host. - - - - - c4b4b1d7 by Moritz Angermann at 2021-05-25T05:52:02-04:00 [ci] faster pipeline - - - - - 50c3061d by Moritz Angermann at 2021-05-25T05:52:02-04:00 [hadrian] Properly build hsc2hs wrapper - - - - - 11bdf3cd by Matthew Pickering at 2021-05-25T05:52:02-04:00 Revert "hadrian: Don't always links against libffi" This reverts commit 673ff667c98eafc89e6746d1ac69d33b8330d755. - - - - - 2023b344 by Richard Eisenberg at 2021-05-25T09:08:36-04:00 Add 9.2 release note about linear case This is part of #18738 [skip ci] - - - - - cdbce8fc by Alfredo Di Napoli at 2021-05-26T16:03:15-04:00 Support new parser types in GHC This commit converts the lexers and all the parser machinery to use the new parser types and diagnostics infrastructure. Furthermore, it cleans up the way the parser code was emitting hints. As a result of this systematic approach, the test output of the `InfixAppPatErr` and `T984` tests have been changed. Previously they would emit a `SuggestMissingDo` hint, but this was not at all helpful in resolving the error, and it was even confusing by just looking at the original program that triggered the errors. Update haddock submodule - - - - - 9faafb0a by Pepe Iborra at 2021-05-26T16:03:52-04:00 Avoid fingerprinting the absolute path to the source file This change aims to make source files relocatable w.r.t. to the interface files produced by the compiler. This is so that we can download interface files produced by a cloud build system and then reuse them in a local ghcide session catch another case of implicit includes actually use the implicit quote includes add another missing case recomp020 test that .hi files are reused even if .hs files are moved to a new location Added recomp021 to record behaviour with non implicit includes add a note additional pointer to the note Mention #16956 in Note - - - - - 03d69e4b by Andreas Klebinger at 2021-05-27T02:35:11-04:00 Enable strict dicts by default at -O2. In the common case this is a straight performance win at a compile time cost so we enable it at -O2. In rare cases it can lead to compile time regressions because of changed inlining behaviour. Which can very rarely also affect runtime performance. Increasing the inlining threshold can help to avoid this which is documented in the user guide. In terms of measured results this reduced instructions executed for nofib by 1%. However for some cases (e.g. Cabal) enabling this by default increases compile time by 2-3% so we enable it only at -O2 where it's clear that a user is willing to trade compile time for runtime. Most of the testsuite runs without -O2 so there are few perf changes. Increases: T12545/T18698: We perform more WW work because dicts are now treated strict. T9198: Also some more work because functions are now subject to W/W Decreases: T14697: Compiling empty modules. Probably because of changes inside ghc. T9203: I can't reproduce this improvement locally. Might be spurious. ------------------------- Metric Decrease: T12227 T14697 T9203 Metric Increase: T9198 T12545 T18698a T18698b ------------------------- - - - - - 9935e99c by Shayne Fletcher at 2021-05-27T02:35:47-04:00 Change representation of HsGetField and HsProjection Another change in a series improving record syntax in the AST. The key change in this commit is the renaming of `HsFieldLabel` to `DotFieldOcc`. - - - - - ce1b8f42 by Andreas Klebinger at 2021-05-27T02:36:23-04:00 Improve deriveConstants error message. This fixes #19823 - - - - - 6de8ac89 by Alan Zimmerman at 2021-05-27T19:25:24+01:00 [EPA] exact print linear arrows. Closes #19903 Note: the normal ppr does not reproduce unicode linear arrows, so that part of the normal printing test is ommented out in the Makefile for this test. See #18846 - - - - - f74204c4 by Boris Lykah at 2021-05-28T15:32:01-04:00 Document release when TypeApplications allowed declaring variables as inferred - - - - - df997fac by Sylvain Henry at 2021-05-28T15:32:44-04:00 Use quotRemWord in showWord Using the following high-quality benchmark (with -O2): main :: IO () main = do let go 0 = "" go n@(W# n#) = showWord n# (go (n -1)) print $ length (go 10000000) I get the following performance results: - remWord+quotRem: 0,76s user 0,00s system 99% cpu 0,762 total - quotRemWord: 0,45s user 0,01s system 99% cpu 0,456 total Note that showSignedInt already uses quotRemInt. - - - - - 5ae070f1 by Thomas Winant at 2021-05-29T05:04:00-04:00 Add -Wmissing-exported-pattern-synonym-signatures After !4741, it was no longer possible to silence a warning about a missing pattern synonym signature if the `-Wmissing-signatures` flag was on. Restore the previous semantics while still adhering to the principle "enabling an additional warning flag should never make prior warnings disappear". For more symmetry and granularity, introduce `-Wmissing-exported-pattern-synonym-signatures`. See Note [Missing signatures] for an overview of all flags involved. - - - - - 28e0dca2 by Luite Stegeman at 2021-05-29T05:04:39-04:00 Work around LLVM backend overlapping register limitations The stg_ctoi_t and stg_ret_t procedures which convert unboxed tuples between the bytecode an native calling convention were causing a panic when using the LLVM backend. Fixes #19591 - - - - - 6412bf6e by parsonsmatt at 2021-05-29T05:05:18-04:00 Add `newDeclarationGroup` and provide documentation in reifyInstances and isInstance - - - - - 99b5cce9 by parsonsmatt at 2021-05-29T05:05:18-04:00 Address review comments, export from TH - - - - - 76902415 by parsonsmatt at 2021-05-29T05:05:18-04:00 Apply 2 suggestion(s) to 1 file(s) - - - - - 0c0e1855 by parsonsmatt at 2021-05-29T05:05:18-04:00 sigh - - - - - 10f48e22 by Matthew Pickering at 2021-05-29T05:05:55-04:00 ghci: Enable -fkeep-going by default This also demotes the error message about -fkeep-going to a trace message which matches the behaviour of other build systems (such as cabal-install and nix) which don't print any message like this on a failure. We want to remove the stable module check in a future patch, which is an approximation of `-fkeep-going`. At the moment this change shouldn't do very much. - - - - - 492b2dc5 by Zubin Duggal at 2021-05-29T05:06:32-04:00 Fix Note [Positioning of forkM] - - - - - 45387760 by Sylvain Henry at 2021-05-29T10:18:01-04:00 Bignum: match on DataCon workers in rules (#19892) We need to match on DataCon workers for the rules to be triggered. T13701 ghc/alloc decreases by ~2.5% on some archs Metric Decrease: T13701 - - - - - 0f8872ec by Sylvain Henry at 2021-05-29T10:18:01-04:00 Fix and slight improvement to datacon worker/wrapper notes - - - - - 6db8a0f7 by Richard Eisenberg at 2021-05-29T10:18:37-04:00 Rip GHC.Tc.Solver.Monad asunder (only) This creates new modules GHC.Tc.Solver.InertSet and GHC.Tc.Solver.Types. The Monad module is still pretty big, but this is an improvement. Moreover, it means that GHC.HsToCore.Pmc.Solver.Types no longer depends on the constraint solver (it now depends on GHC.Tc.Solver.InertSet), making the error-messages work easier. This patch thus contributes to #18516. - - - - - 42c611cf by Ben Gamari at 2021-05-29T11:57:51-04:00 Split GHC.Utils.Monad.State into .Strict and .Lazy - - - - - ec646247 by Ben Gamari at 2021-05-29T11:58:45-04:00 Use GHC's State monad consistently GHC's internal State monad benefits from oneShot annotations on its state, allowing for more aggressive eta expansion. We currently don't have monad transformers with the same optimisation, so we only change uses of the pure State monad here. See #19657 and 19380. Metric Decrease: hie002 - - - - - 21bdd9b7 by Ben Gamari at 2021-05-29T11:58:52-04:00 StgM: Use ReaderT rather than StateT - - - - - 6b6c4b9a by Viktor Dukhovni at 2021-06-02T04:38:47-04:00 Improve wording of fold[lr]M documentation. The sequencing of monadic effects in foldlM and foldrM was described as respectively right-associative and left-associative, but this could be confusing, as in essence we're just composing Kleisli arrows, whose composition is simply associative. What matters therefore is the order of sequencing of effects, which can be described more clearly without dragging in associativity as such. This avoids describing these folds as being both left-to-right and right-to-left depending on whether we're tracking effects or operator application. The new text should be easier to understand. - - - - - fcd124d5 by Roland Senn at 2021-06-02T04:39:23-04:00 Allow primops in a :print (and friends) command. Fix #19394 * For primops from `GHC.Prim` lookup the HValues in `GHC.PrimopWrappers`. * Add short error messages if a user tries to use a *Non-Id* value or a `pseudoop` in a `:print`, `:sprint` or `force`command. * Add additional test cases for `Magic Ids`. - - - - - adddf248 by Zubin Duggal at 2021-06-02T04:39:58-04:00 Fail before checking instances in checkHsigIface if exports don't match (#19244) - - - - - c5a9e32e by Divam at 2021-06-02T04:40:34-04:00 Specify the reason for import for the backpack's extra imports - - - - - 7d8e1549 by Vladislav Zavialov at 2021-06-02T04:41:08-04:00 Disallow linear arrows in GADT records (#19928) Before this patch, GHC used to silently accept programs such as the following: data R where D1 :: { d1 :: Int } %1 -> R The %1 annotation was completely ignored. Now it is a proper error. One remaining issue is that in the error message (⊸) turns into (%1 ->). This is to be corrected with upcoming exactprint updates. - - - - - 437a6ccd by Matthew Pickering at 2021-06-02T16:23:53-04:00 hadrian: Speed up lint:base rule The rule before decided to build the whole stage1 compiler, but this was unecessary as we were just missing one header file which can be generated directly by calling configure. Before: 18 minutes After: 54s - - - - - de33143c by Matthew Pickering at 2021-06-02T16:23:53-04:00 Run both lint jobs together - - - - - 852a12c8 by Matthew Pickering at 2021-06-02T16:23:53-04:00 CI: Don't explicitly build hadrian before using run_hadrian This causes hadrian to be built twice because the second time uses a different index state. - - - - - b66cf8ad by Matthew Pickering at 2021-06-02T16:24:27-04:00 Fix infinite looping in hptSomeModulesBelow When compiling Agda we entered into an infinite loop as the stopping condition was a bit wrong in hptSomeModulesBelow. The bad situation was something like * We would see module A (NotBoot) and follow it dependencies * Later on we would encounter A (Boot) and follow it's dependencies, because the lookup would not match A (NotBoot) and A (IsBoot) * Somewhere in A (Boot)s dependencies, A (Boot) would appear again and lead us into an infinite loop. Now the state marks whether we have been both variants (IsBoot and NotBoot) so we don't follow dependencies for A (Boot) many times. - - - - - b585aff0 by Sebastian Graf at 2021-06-02T23:06:18-04:00 WW: Mark absent errors as diverging again As the now historic part of `NOTE [aBSENT_ERROR_ID]` explains, we used to have `exprIsHNF` respond True to `absentError` and give it a non-bottoming demand signature, in order to perform case-to-let on certain `case`s we used to emit that scrutinised `absentError` (Urgh). What changed, why don't we emit these questionable absent errors anymore? The absent errors in question filled in for binders that would end up in strict fields after being seq'd. Apparently, the old strictness analyser would give these binders an absent demand, but today we give them head-strict demand `1A` and thus don't replace with absent errors at all. This fixes items (1) and (2) of #19853. - - - - - 79d12d34 by Shayne Fletcher at 2021-06-02T23:06:52-04:00 CountDeps: print graph of module dependencies in dot format The tests `CountParserDeps.hs` and `CountAstDeps.hs` are implemented by calling `CountDeps`. In this MR, `CountDeps.printDeps` is updated such tat by uncommenting a line, you can print a module's dependency graph showing what includes what. The output is in a format suitable for use with graphviz. - - - - - 25977ab5 by Matthew Pickering at 2021-06-03T08:46:47+01:00 Driver Rework Patch This patch comprises of four different but closely related ideas. The net result is fixing a large number of open issues with the driver whilst making it simpler to understand. 1. Use the hash of the source file to determine whether the source file has changed or not. This makes the recompilation checking more robust to modern build systems which are liable to copy files around changing their modification times. 2. Remove the concept of a "stable module", a stable module was one where the object file was older than the source file, and all transitive dependencies were also stable. Now we don't rely on the modification time of the source file, the notion of stability is moot. 3. Fix TH/plugin recompilation after the removal of stable modules. The TH recompilation check used to rely on stable modules. Now there is a uniform and simple way, we directly track the linkables which were loaded into the interpreter whilst compiling a module. This is an over-approximation but more robust wrt package dependencies changing. 4. Fix recompilation checking for dynamic object files. Now we actually check if the dynamic object file exists when compiling with -dynamic-too Fixes #19774 #19771 #19758 #17434 #11556 #9121 #8211 #16495 #7277 #16093 - - - - - d5b89ed4 by Alfredo Di Napoli at 2021-06-03T15:58:33-04:00 Port HsToCore messages to new infrastructure This commit converts a bunch of HsToCore (Ds) messages to use the new GHC's diagnostic message infrastructure. In particular the DsMessage type has been expanded with a lot of type constructors, each encapsulating a particular error and warning emitted during desugaring. Due to the fact that levity polymorphism checking can happen both at the Ds and at the TcRn level, a new `TcLevityCheckDsMessage` constructor has been added to the `TcRnMessage` type. - - - - - 7a05185a by Roland Senn at 2021-06-03T15:59:10-04:00 Follow up #12449: Improve function `Inspect.hs:check2` * Add a Note to clarify RttiTypes. * Don't call `quantifyType` at all the call sites of `check2`. * Simplyfy arguments of functions `Inspect.hs:check1` and `Inspect.hs:check2`. - `check1` only uses the two lists of type variables, but not the types. - `check2` only uses the two types, but not the lists of type variables. * In `Inspect.hs:check2` send only the tau part of the type to `tcSplitTyConApp_maybe`. - - - - - 1bb0565c by Thomas Winant at 2021-06-04T00:30:22-04:00 Fix incorrect mention of -Wprepositive-qualified-syntax in docs The flag is called `-Wprepositive-qualified-module`, not `-Wprepositive-qualified-syntax`. Use the `:ghc-flag:` syntax, which would have caught the mistake in the first place. - - - - - 44d131af by Takenobu Tani at 2021-06-04T00:30:59-04:00 users-guide: Add OverloadedRecordDot and OverloadedRecordUpdate for ghc-9.2 This patch adds OverloadedRecordDot and OverloadedRecordUpdate in 9.2.1's release note. - - - - - f1b748b4 by Alfredo Di Napoli at 2021-06-04T12:43:41-04:00 Add PsHeaderMessage diagnostic (fixes #19923) This commit replaces the PsUnknownMessage diagnostics over at `GHC.Parser.Header` with a new `PsHeaderMessage` type (part of the more general `PsMessage`), so that we can throw parser header's errors which can be correctly caught by `GHC.Driver.Pipeline.preprocess` and rewrapped (correctly) as Driver messages (using the `DriverPsHeaderMessage`). This gets rid of the nasty compiler crash as part of #19923. - - - - - 733757ad by sheaf at 2021-06-04T12:44:19-04:00 Make some simple primops levity-polymorphic Fixes #17817 - - - - - 737b0ae1 by Sylvain Henry at 2021-06-04T12:45:01-04:00 Fix Integral instances for Words * ensure that division wrappers are INLINE * make div/mod/divMod call quot/rem/quotRem (same code) * this ensures that the quotRemWordN# primitive is used to implement divMod (it wasn't the case for sized Words) * make first argument strict for Natural and Integer (similarly to other numeric types) - - - - - 1713cbb0 by Shayne Fletcher at 2021-06-05T03:47:48-04:00 Make 'count-deps' a ghc/util standalone program - Move 'count-deps' into 'ghc/utils' so that it can be called standalone. - Move 'testsuite/tests/parser/should_run/' tests 'CountParserDeps' and 'CountAstDeps' to 'testsuite/tests/count-deps' and reimplement in terms of calling the utility - Document how to use 'count-deps' in 'ghc/utils/count-deps/README' - - - - - 9a28680d by Sylvain Henry at 2021-06-05T03:48:25-04:00 Put Unique related global variables in the RTS (#19940) - - - - - 8c90e6c7 by Richard Eisenberg at 2021-06-05T10:29:22-04:00 Fix #19682 by breaking cycles in Deriveds This commit expands the old Note [Type variable cycles in Givens] to apply as well to Deriveds. See the Note for details and examples. This fixes a regression introduced by my earlier commit that killed off the flattener in favor of the rewriter. A few other things happened along the way: * unifyTest was renamed to touchabilityTest, because that's what it does. * isInsolubleOccursCheck was folded into checkTypeEq, which does much of the same work. To get this to work out, though, we need to keep more careful track of what errors we spot in checkTypeEq, and so CheckTyEqResult has become rather more glorious. * A redundant Note or two was eliminated. * Kill off occCheckForErrors; due to Note [Rewriting synonyms], the extra occCheckExpand here is always redundant. * Store blocked equalities separately from other inerts; less stuff to look through when kicking out. Close #19682. test case: typecheck/should_compile/T19682{,b} - - - - - 3b1aa7db by Moritz Angermann at 2021-06-05T10:29:57-04:00 Adds AArch64 Native Code Generator In which we add a new code generator to the Glasgow Haskell Compiler. This codegen supports ELF and Mach-O targets, thus covering Linux, macOS, and BSDs in principle. It was tested only on macOS and Linux. The NCG follows a similar structure as the other native code generators we already have, and should therfore be realtively easy to follow. It supports most of the features required for a proper native code generator, but does not claim to be perfect or fully optimised. There are still opportunities for optimisations. Metric Decrease: ManyAlternatives ManyConstructors MultiLayerModules PmSeriesG PmSeriesS PmSeriesT PmSeriesV T10421 T10421a T10858 T11195 T11276 T11303b T11374 T11822 T12227 T12545 T12707 T13035 T13253 T13253-spj T13379 T13701 T13719 T14683 T14697 T15164 T15630 T16577 T17096 T17516 T17836 T17836b T17977 T17977b T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T3064 T5030 T5321FD T5321Fun T5631 T5642 T5837 T783 T9198 T9233 T9630 T9872d T9961 WWRec Metric Increase: T4801 - - - - - db1e07f1 by Moritz Angermann at 2021-06-05T10:29:57-04:00 [ci] -llvm with --way=llvm - - - - - 1b2f894f by Moritz Angermann at 2021-06-05T10:29:57-04:00 [ci] no docs for aarch64-linux-llvm - - - - - a1fed3a5 by Moritz Angermann at 2021-06-05T10:29:57-04:00 [ci] force CC=clang for aarch64-linux - - - - - 4db2d44c by Moritz Angermann at 2021-06-05T10:29:57-04:00 [testsuite] fix T13702 with clang - - - - - ecc3a405 by Moritz Angermann at 2021-06-05T10:29:57-04:00 [testsuite] fix T6132 when using the LLVM toolchain - - - - - cced9454 by Shayne Fletcher at 2021-06-05T19:23:11-04:00 Countdeps: Strictly documentation markup fixes [ci skip] - - - - - ea9a4ef6 by Simon Peyton Jones at 2021-06-05T19:23:46-04:00 Avoid useless w/w split, take 2 This commit: commit c6faa42bfb954445c09c5680afd4fb875ef03758 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Mon Mar 9 10:20:42 2020 +0000 Avoid useless w/w split This patch is just a tidy-up for the post-strictness-analysis worker wrapper split. Consider f x = x Strictnesss analysis does not lead to a w/w split, so the obvious thing is to leave it 100% alone. But actually, because the RHS is small, we ended up adding a StableUnfolding for it. There is some reason to do this if we choose /not/ do to w/w on the grounds that the function is small. See Note [Don't w/w inline small non-loop-breaker things] But there is no reason if we would not have done w/w anyway. This patch just moves the conditional to later. Easy. turns out to have a bug in it. Instead of /moving/ the conditional, I /duplicated/ it. Then in a subsequent unrelated tidy-up (087ac4eb) I removed the second (redundant) test! This patch does what I originally intended. There is also a small refactoring in GHC.Core.Unfold, to make the code clearer, but with no change in behaviour. It does, however, have a generally good effect on compile times, because we aren't dealing with so many silly stable unfoldings. Here are the non-zero changes: Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change --------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 791969344.0 792665048.0 +0.1% ManyConstructors(normal) ghc/alloc 4351126824.0 4358303528.0 +0.2% PmSeriesG(normal) ghc/alloc 50362552.0 50482208.0 +0.2% PmSeriesS(normal) ghc/alloc 63733024.0 63619912.0 -0.2% T10421(normal) ghc/alloc 121224624.0 119695448.0 -1.3% GOOD T10421a(normal) ghc/alloc 85256392.0 83714224.0 -1.8% T10547(normal) ghc/alloc 29253072.0 29258256.0 +0.0% T10858(normal) ghc/alloc 189343152.0 187972328.0 -0.7% T11195(normal) ghc/alloc 281208248.0 279727584.0 -0.5% T11276(normal) ghc/alloc 141966952.0 142046224.0 +0.1% T11303b(normal) ghc/alloc 46228360.0 46259024.0 +0.1% T11545(normal) ghc/alloc 2663128768.0 2667412656.0 +0.2% T11822(normal) ghc/alloc 138686944.0 138760176.0 +0.1% T12227(normal) ghc/alloc 482836000.0 475421056.0 -1.5% GOOD T12234(optasm) ghc/alloc 60710520.0 60781808.0 +0.1% T12425(optasm) ghc/alloc 104089000.0 104022424.0 -0.1% T12545(normal) ghc/alloc 1711759416.0 1705711528.0 -0.4% T12707(normal) ghc/alloc 991541120.0 991921776.0 +0.0% T13035(normal) ghc/alloc 108199872.0 108370704.0 +0.2% T13056(optasm) ghc/alloc 414642544.0 412580384.0 -0.5% T13253(normal) ghc/alloc 361701272.0 355838624.0 -1.6% T13253-spj(normal) ghc/alloc 157710168.0 157397768.0 -0.2% T13379(normal) ghc/alloc 370984400.0 371345888.0 +0.1% T13701(normal) ghc/alloc 2439764144.0 2441351984.0 +0.1% T14052(ghci) ghc/alloc 2154090896.0 2156671400.0 +0.1% T15164(normal) ghc/alloc 1478517688.0 1440317696.0 -2.6% GOOD T15630(normal) ghc/alloc 178053912.0 172489808.0 -3.1% T16577(normal) ghc/alloc 7859948896.0 7854524080.0 -0.1% T17516(normal) ghc/alloc 1271520128.0 1202096488.0 -5.5% GOOD T17836(normal) ghc/alloc 1123320632.0 1123922480.0 +0.1% T17836b(normal) ghc/alloc 54526280.0 54576776.0 +0.1% T17977b(normal) ghc/alloc 42706752.0 42730544.0 +0.1% T18140(normal) ghc/alloc 108834568.0 108693816.0 -0.1% T18223(normal) ghc/alloc 5539629264.0 5579500872.0 +0.7% T18304(normal) ghc/alloc 97589720.0 97196944.0 -0.4% T18478(normal) ghc/alloc 770755472.0 771232888.0 +0.1% T18698a(normal) ghc/alloc 408691160.0 374364992.0 -8.4% GOOD T18698b(normal) ghc/alloc 492419768.0 458809408.0 -6.8% GOOD T18923(normal) ghc/alloc 72177032.0 71368824.0 -1.1% T1969(normal) ghc/alloc 803523496.0 804655112.0 +0.1% T3064(normal) ghc/alloc 198411784.0 198608512.0 +0.1% T4801(normal) ghc/alloc 312416688.0 312874976.0 +0.1% T5321Fun(normal) ghc/alloc 325230680.0 325474448.0 +0.1% T5631(normal) ghc/alloc 592064448.0 593518968.0 +0.2% T5837(normal) ghc/alloc 37691496.0 37710904.0 +0.1% T783(normal) ghc/alloc 404629536.0 405064432.0 +0.1% T9020(optasm) ghc/alloc 266004608.0 266375592.0 +0.1% T9198(normal) ghc/alloc 49221336.0 49268648.0 +0.1% T9233(normal) ghc/alloc 913464984.0 742680256.0 -18.7% GOOD T9675(optasm) ghc/alloc 552296608.0 466322000.0 -15.6% GOOD T9872a(normal) ghc/alloc 1789910616.0 1793924472.0 +0.2% T9872b(normal) ghc/alloc 2315141376.0 2310338056.0 -0.2% T9872c(normal) ghc/alloc 1840422424.0 1841567224.0 +0.1% T9872d(normal) ghc/alloc 556713248.0 556838432.0 +0.0% T9961(normal) ghc/alloc 383809160.0 384601600.0 +0.2% WWRec(normal) ghc/alloc 773751272.0 753949608.0 -2.6% GOOD Residency goes down too: Metrics: compile_time/max_bytes_used ------------------------------------ Baseline Test Metric value New value Change ----------------------------------------------------------- T10370(optasm) ghc/max 42058448.0 39481672.0 -6.1% T11545(normal) ghc/max 43641392.0 43634752.0 -0.0% T15304(normal) ghc/max 29895824.0 29439032.0 -1.5% T15630(normal) ghc/max 8822568.0 8772328.0 -0.6% T18698a(normal) ghc/max 13882536.0 13787112.0 -0.7% T18698b(normal) ghc/max 14714112.0 13836408.0 -6.0% T1969(normal) ghc/max 24724128.0 24733496.0 +0.0% T3064(normal) ghc/max 14041152.0 14034768.0 -0.0% T3294(normal) ghc/max 32769248.0 32760312.0 -0.0% T9630(normal) ghc/max 41605120.0 41572184.0 -0.1% T9675(optasm) ghc/max 18652296.0 17253480.0 -7.5% Metric Decrease: T10421 T12227 T15164 T17516 T18698a T18698b T9233 T9675 WWRec Metric Increase: T12545 - - - - - 52a524f7 by Simon Peyton Jones at 2021-06-05T19:23:46-04:00 Re-do rubbish literals As #19882 pointed out, we were simply doing rubbish literals wrong. (I'll refrain from explaining the wrong-ness here -- see the ticket.) This patch fixes it by adding a Type (of kind RuntimeRep) as field of LitRubbish, rather than [PrimRep]. The Note [Rubbish literals] in GHC.Types.Literal explains the details. - - - - - 34424b9d by Simon Peyton Jones at 2021-06-05T19:23:46-04:00 Drop absent bindings in worker/wrapper Consider this (from #19824) let t = ...big... in ...(f t x)... were `f` ignores its first argument. With luck f's wrapper will inline thereby dropping `t`, but maybe not: the arguments to f all look boring. So we pre-empt the problem by replacing t's RHS with an absent filler during w/w. Simple and effective. The main payload is the new `isAbsDmd` case in `tryWw`, but there are some other minor refactorings: * To implment this I had to refactor `mk_absent_let` to `mkAbsentFiller`, which can be called from `tryWW`. * wwExpr took both WwOpts and DynFlags which seems silly. I combined them into one. * I renamed the historical mkInineRule to mkWrapperUnfolding - - - - - 3e343292 by Ben Gamari at 2021-06-05T19:23:46-04:00 testsuite: Eliminate fragility of ioprof As noted in #10037, the `ioprof` test would change its stderr output (specifically the stacktrace produced by `error`) depending upon optimisation level. As the `error` backtrace is not the point of this test, we now ignore the `stderr` output. - - - - - 5e1a2244 by Ben Gamari at 2021-06-05T19:23:46-04:00 testsuite: Fix Note style - - - - - 4dc681c7 by Sylvain Henry at 2021-06-07T10:35:39+02:00 Make Logger independent of DynFlags Introduce LogFlags as a independent subset of DynFlags used for logging. As a consequence in many places we don't have to pass both Logger and DynFlags anymore. The main reason for this refactoring is that I want to refactor the systools interfaces: for now many systools functions use DynFlags both to use the Logger and to fetch their parameters (e.g. ldInputs for the linker). I'm interested in refactoring the way they fetch their parameters (i.e. use dedicated XxxOpts data types instead of DynFlags) for #19877. But if I did this refactoring before refactoring the Logger, we would have duplicate parameters (e.g. ldInputs from DynFlags and linkerInputs from LinkerOpts). Hence this patch first. Some flags don't really belong to LogFlags because they are subsystem specific (e.g. most DumpFlags). For example -ddump-asm should better be passed in NCGConfig somehow. This patch doesn't fix this tight coupling: the dump flags are part of the UI but they are passed all the way down for example to infer the file name for the dumps. Because LogFlags are a subset of the DynFlags, we must update the former when the latter changes (not so often). As a consequence we now use accessors to read/write DynFlags in HscEnv instead of using `hsc_dflags` directly. In the process I've also made some subsystems less dependent on DynFlags: - CmmToAsm: by passing some missing flags via NCGConfig (see new fields in GHC.CmmToAsm.Config) - Core.Opt.*: - by passing -dinline-check value into UnfoldingOpts - by fixing some Core passes interfaces (e.g. CallArity, FloatIn) that took DynFlags argument for no good reason. - as a side-effect GHC.Core.Opt.Pipeline.doCorePass is much less convoluted. - - - - - 3a90814f by Sylvain Henry at 2021-06-07T11:19:35+02:00 Parser: make less DynFlags dependent This is an attempt at reducing the number of dependencies of the Parser (as reported by CountParserDeps). Modules in GHC.Parser.* don't import GHC.Driver.Session directly anymore. Sadly some GHC.Driver.* modules are still transitively imported and the number of dependencies didn't decrease. But it's a step in the right direction. - - - - - 40c0f67f by Sylvain Henry at 2021-06-07T11:19:35+02:00 Bump haddock submodule - - - - - 9e724f6e by Viktor Dukhovni at 2021-06-07T15:35:22-04:00 Small ZipList optimisation In (<|>) for ZipList, avoid processing the first argument twice (both as first argument of (++) and for its length in drop count of the second argument). Previously, the entire first argument was forced into memory, now (<|>) can run in constant space even with long inputs. - - - - - 7ea3b7eb by Ryan Scott at 2021-06-08T01:07:10+05:30 Introduce `hsExprType :: HsExpr GhcTc -> Type` in the new module `GHC.Hs.Syn.Type` The existing `hsPatType`, `hsLPatType` and `hsLitType` functions have also been moved to this module This is a less ambitious take on the same problem that !2182 and !3866 attempt to solve. Rather than have the `hsExprType` function attempt to efficiently compute the `Type` of every subexpression in an `HsExpr`, this simply computes the overall `Type` of a single `HsExpr`. - Explicitly forbids the `SplicePat` `HsIPVar`, `HsBracket`, `HsRnBracketOut` and `HsTcBracketOut` constructors during the typechecking phase by using `Void` as the TTG extension field - Also introduces `dataConCantHappen` as a domain specific alternative to `absurd` to handle cases where the TTG extension points forbid a constructor. - Turns HIE file generation into a pure function that doesn't need access to the `DsM` monad to compute types, but uses `hsExprType` instead. - Computes a few more types during HIE file generation - Makes GHCi's `:set +c` command also use `hsExprType` instead of going through the desugarer to compute types. Updates haddock submodule Co-authored-by: Zubin Duggal <zubin.duggal at gmail.com> - - - - - 378c0bba by Tamar Christina at 2021-06-08T15:40:50-04:00 winio: use synchronous access explicitly for handles that may not be asynchronous. - - - - - 31bfafec by Baldur Blöndal at 2021-06-09T09:46:17-04:00 Added a regression test, this would trigger a Core Lint error before GHC 9 - - - - - d69067a1 by Matthew Pickering at 2021-06-09T09:46:51-04:00 FinderCache: Also cache file hashing in interface file checks Now that we hash object files to decide when to recompile due to TH, this can make a big difference as each interface file in a project will contain reference to the object files of all package dependencies. Especially when these are statically linked, hashing them can add up. The cache is invalidated when `depanalPartial` is called, like the normal finder cache. - - - - - f4a5e30e by Simon Peyton Jones at 2021-06-10T02:38:19-04:00 Do not add unfoldings to lambda-binders For reasons described in GHC.Core.Opt.Simplify Historical Note [Case binders and join points], we used to keep a Core unfolding in one of the lambda-binders for a join point. But this was always a gross hack -- it's very odd to have an unfolding in a lambda binder, that refers to earlier lambda binders. The hack bit us in various ways: * Most seriously, it is incompatible with linear types in Core. * It complicated demand analysis, and could worsen results * It required extra care in the simplifier (simplLamBinder) * It complicated !5641 (look for "join binder unfoldings") So this patch just removes the hack. Happily, doind so turned out to have no effect on performance. - - - - - 8baa8874 by Li-yao Xia at 2021-06-10T02:38:54-04:00 User's Guide: reword and fix punctuation in description of PostfixOperators - - - - - fb6b6379 by Matthew Pickering at 2021-06-10T02:39:29-04:00 Add (broken) test for #19966 - - - - - 61c51c00 by Sylvain Henry at 2021-06-10T02:40:07-04:00 Fix redundant import - - - - - 472c2bf0 by sheaf at 2021-06-10T13:54:05-04:00 Reword: representation instead of levity fixes #19756, updates haddock submodule - - - - - 3d5cb335 by Simon Peyton Jones at 2021-06-10T13:54:40-04:00 Fix INLINE pragmas in desugarer In #19969 we discovered that GHC has has a bug *forever* that means it sometimes essentially discarded INLINE pragams. This happened when you have * Two more more mutually recursive functions * Some of which (presumably not all!) have an INLINE pragma * Completely monomorphic. This hits a particular case in GHC.HsToCore.Binds.dsAbsBinds, which was simply wrong -- it put the INLINE pragma on the wrong binder. This patch fixes the bug, rather easily, by adjusting the no-tyvar, no-dict case of GHC.HsToCore.Binds.dsAbsBinds. I also discovered that the GHC.Core.Opt.Pipeline.shortOutIndirections was not doing a good job for {-# INLINE lcl_id #-} lcl_id = BIG gbl_id = lcl_id Here we want to transfer the stable unfolding to gbl_id (we do), but we also want to remove it from lcl_id (we were not doing that). Otherwise both Ids have large stable unfoldings. Easily fixed. Note [Transferring IdInfo] explains. - - - - - 2a7e29e5 by Ben Gamari at 2021-06-16T16:58:37+00:00 gitlab-ci: Bump ci-images - - - - - 6c131ba0 by Baldur Blöndal at 2021-06-16T20:18:35-04:00 DerivingVia for Hsc instances. GND for NonDetFastString and LexicalFastString. - - - - - a2e4cb80 by Vladislav Zavialov at 2021-06-16T20:19:10-04:00 HsUniToken and HsToken for HsArrow (#19623) Another step towards a simpler design for exact printing. Updates the haddock submodule. - - - - - 01fd2617 by Matthew Pickering at 2021-06-16T20:19:45-04:00 profiling: Look in RHS of rules for cost centre ticks There are some obscure situations where the RHS of a rule can contain a tick which is not mentioned anywhere else in the program. If this happens you end up with an obscure linker error. The solution is quite simple, traverse the RHS of rules to also look for ticks. It turned out to be easier to implement if the traversal was moved into CoreTidy rather than at the start of code generation because there we still had easy access to the rules. ./StreamD.o(.text+0x1b9f2): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc' ./MArray.o(.text+0xbe83): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc' Main.o(.text+0x6fdb): error: undefined reference to 'StreamK_mkStreamFromStream_HPC_cc' - - - - - d8bfebec by AriFordsham at 2021-06-16T20:20:22-04:00 Corrected typo - - - - - 34484c89 by Divam at 2021-06-16T20:20:59-04:00 Remove the backend correction logic, as it is already been fixed at this point - - - - - e25772a0 by Peter Trommler at 2021-06-16T20:21:34-04:00 PPC NCG: Fix panic in linear register allocator - - - - - a83d2999 by Krzysztof Gogolewski at 2021-06-16T20:22:09-04:00 Fix error message for record updates, #19972 Fix found by Adam Gundry. - - - - - a0622459 by Matthew Pickering at 2021-06-17T11:55:17+01:00 Move validate-x86_64-linux-deb9-hadrian back to quick-build This increases the critical path length but in practice will reduce pressure on runners because less jobs overall will be spawned. See #20003 [skip ci] - - - - - 3b783496 by Simon Peyton Jones at 2021-06-18T12:27:33-04:00 Enhance cast worker/wrapper for INLINABLE In #19890 we realised that cast worker/wrapper didn't really work properly for functions with an INLINABLE pragma, and hence a stable unfolding. This patch fixes the problem. Instead of disabling cast w/w when there is a stable unfolding (as we did before), we now tranfer the stable unfolding to the worker. It turned out that it was easier to do that if I moved the cast w/w stuff from prepareBinding to completeBind. No chnages at all in nofib results: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- Min -0.0% 0.0% -63.8% -78.2% 0.0% Max -0.0% 0.0% +11.8% +11.7% 0.0% Geometric Mean -0.0% -0.0% -26.6% -33.4% -0.0% Small decreases in compile-time allocation for two tests (below) of around 2%. T12545 increased in compile-time alloc by 4%, but it's not reproducible on my machine, and is a known-wobbly test. Metric Increase: T12545 Metric Decrease: T18698a T18698b - - - - - c6a00c15 by Simon Peyton Jones at 2021-06-18T12:27:33-04:00 Improve abstractVars quantification ordering When floating a binding out past some type-variable binders, don't gratuitiously change the order of the binders. This small change gives code that is simpler, has less risk of non-determinism, and does not gratuitiously change type-variable order. See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. This is really just refactoring; no change in behaviour. - - - - - db7e6dc5 by Simon Peyton Jones at 2021-06-18T12:27:33-04:00 Improve pretty-printing of coercions With -dsuppress-coercions, it's still good to be able to see the type of the coercion. This patch prints the type. Maybe we should have a flag to control this too. - - - - - 5d3d9925 by Gleb Popov at 2021-06-18T12:27:36-04:00 Pass -DLIBICONV_PLUG when building base library on FreeBSD. If libiconv is installed from packages on the build machine, there is a high chance that the build system will pick up /usr/local/include/iconv.h instead of base /usr/include/iconv.h This additional preprocessor define makes package's libiconv header compatible with system one, fixing the build. Closes issue #19958 - - - - - 1e2ba8a4 by Matthew Pickering at 2021-06-19T12:22:27-04:00 CI: Keep the value of PERF_NOTE_KEY in darwin environments This fixes the performance test tracking for all darwin environments. - - - - - 028b9474 by Simon Peyton Jones at 2021-06-19T12:23:02-04:00 Add comments explaining why #19833 is wrong I realised that the suggestion in #19833 doesn't work, and documented why in Note [Zapping Used Once info in WorkWrap] - - - - - 6b2952cf by Sylvain Henry at 2021-06-19T12:23:39-04:00 RTS: fix indentation warning - - - - - a6548a66 by David at 2021-06-19T12:24:15-04:00 Correct haddock annotations in GetOpt - - - - - 23bb09c9 by Sylvain Henry at 2021-06-19T12:24:52-04:00 Perf: fix appendFS To append 2 FastString we don't need to convert them into ByteString: use ShortByteString's Semigroup instance instead. - - - - - 1c79ddc8 by Matthew Pickering at 2021-06-19T12:25:26-04:00 RTS: Fix flag parsing for --eventlog-flush-interval Fixes #20006 - - - - - fc8ad5f3 by Simon Peyton Jones at 2021-06-19T12:26:01-04:00 Fix type and strictness signature of fork# When working eta-expansion and reduction, I found that fork# had a weaker strictness signature than it should have (#19992). In particular, it didn't record that it applies its argument exactly once. To this I needed to give it a proper type (its first argument is always a function, which in turn entailed a small change to the call in GHC.Conc.Sync This patch fixes it. - - - - - 217b4dcc by Krzysztof Gogolewski at 2021-06-19T12:26:35-04:00 Deprecate -Wmissing-monadfail-instances (#17875) Also document deprecation of Wnoncanonical-monadfail-instances and -Wimplicit-kind-vars - - - - - 8838241f by Sylvain Henry at 2021-06-19T12:27:12-04:00 Fix naturalToFloat/Double * move naturalToFloat/Double from ghc-bignum to base:GHC.Float and make them wired-in (as their integerToFloat/Double counterparts) * use the same rounding method as integerToFloat/Double. This is an oversight of 540fa6b2cff3802877ff56a47ab3611e33a9ac86 * add passthrough rules for intToFloat, intToDouble, wordToFloat, wordToDouble. - - - - - 3f60a7e5 by Vladislav Zavialov at 2021-06-19T22:58:33-04:00 Do not reassociate lexical negation (#19838) - - - - - 4c87a3d1 by Ryan Scott at 2021-06-19T22:59:08-04:00 Simplify pprLHsContext This removes an _ad hoc_ special case for empty `LHsContext`s in `pprLHsContext`, fixing #20011. To avoid regressions in pretty-printing data types and classes constructed via TH, we now apply a heuristic where we convert empty datatype contexts and superclasses to a `Nothing` (rather than `Just` an empty context). This will, for instance, avoid pretty-printing every TH-constructed data type as `data () => Blah ...`. - - - - - a6a8d3f5 by Moritz Angermann at 2021-06-20T07:11:58-04:00 Guard Allocate Exec via LIBFFI by LIBFFI We now have two darwin flavours. AArch64-Darwin, and x86_64-darwin, the latter one which has proper custom adjustor support, the former though relies on libffi. Mixing both leads to odd crashes, as the closures might not fit the size of the libffi closures. Hence this needs to be guarded by the USE_LBFFI_FOR_ADJUSTORS guard. Original patch by Hamish Mackenzie - - - - - 689016dc by Matthew Pickering at 2021-06-20T07:12:32-04:00 Darwin CI: Don't explicitly pass ncurses/iconv paths Passing --with-ncurses-libraries means the path which gets backed in progagate into the built binaries. This is incorrect when we want to distribute the binaries because the user might not have the library in that specific place. It's the user's reponsibility to direct the dynamic linker to the right place. Fixes #19968 - - - - - 4a65c0f8 by Matthew Pickering at 2021-06-20T07:12:32-04:00 rts: Pass -Wl,_U,___darwin_check_fd_set_overflow on Darwin Note [fd_set_overflow] ~~~~~~~~~~~~~~~~~~~~~~ In this note is the very sad tale of __darwin_fd_set_overflow. The 8.10.5 release was broken because it was built in an environment where the libraries were provided by XCode 12.*, these libraries introduced a reference to __darwin_fd_set_overflow via the FD_SET macro which is used in Select.c. Unfortunately, this symbol is not available with XCode 11.* which led to a linker error when trying to link anything. This is almost certainly a bug in XCode but we still have to work around it. Undefined symbols for architecture x86_64: "___darwin_check_fd_set_overflow", referenced from: _awaitEvent in libHSrts.a(Select.o) ld: symbol(s) not found for architecture x86_64 One way to fix this is to upgrade your version of xcode, but this would force the upgrade on users prematurely. Fortunately it also seems safe to pass the linker option "-Wl,-U,___darwin_check_fd_set_overflow" because the usage of the symbol is guarded by a guard to check if it's defined. __header_always_inline int __darwin_check_fd_set(int _a, const void *_b) { if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) { return __darwin_check_fd_set_overflow(_a, _b, 1); return __darwin_check_fd_set_overflow(_a, _b, 0); } else { return 1; } Across the internet there are many other reports of this issue See: https://github.com/mono/mono/issues/19393 , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 The issue was originally reported in #19950 Fixes #19950 - - - - - 6c783817 by Zubin Duggal at 2021-06-20T07:13:07-04:00 Set min LLVM version to 9 and make version checking use a non-inclusive upper bound. We use a non-inclusive upper bound so that setting the upper bound to 13 for example means that all 12.x versions are accepted. - - - - - 6281a333 by Matthew Pickering at 2021-06-20T07:13:41-04:00 Linker/darwin: Properly honour -fno-use-rpaths The specification is now simple * On linux, use `-Xlinker -rpath -Xlinker` to set the rpath of the executable * On darwin, never use `-Xlinker -rpath -Xlinker`, always inject the rpath afterwards, see `runInjectRPaths`. * If `-fno-use-rpaths` is passed then *never* inject anything into the rpath. Fixes #20004 - - - - - 5abf5997 by Fraser Tweedale at 2021-06-20T07:14:18-04:00 hadrian/README.md: update bignum options - - - - - 65bad0de by Matthew Pickering at 2021-06-22T02:33:00-04:00 CI: Don't set EXTRA_HC_OPTS in head.hackage job Upstream environment variables take precedance over downstream variables. It is more consistent (and easier to modify) if the variables are all set in the head.hackage CI file rather than setting this here. [skip ci] - - - - - 14956cb8 by Sylvain Henry at 2021-06-22T02:33:38-04:00 Put tracing functions into their own module Now that Outputable is independent of DynFlags, we can put tracing functions using SDocs into their own module that doesn't transitively depend on any GHC.Driver.* module. A few modules needed to be moved to avoid loops in DEBUG mode. - - - - - 595dfbb0 by Matthew Pickering at 2021-06-22T02:34:13-04:00 rts: Document --eventlog-flush-interval in RtsFlags Fixes #19995 - - - - - 362f078e by Krzysztof Gogolewski at 2021-06-22T02:34:49-04:00 Typos, minor comment fixes - Remove fstName, sndName, fstIdKey, sndIdKey - no longer used, removed from basicKnownKeyNames - Remove breakpointId, breakpointCondId, opaqueTyCon, unknownTyCon - they were used in the old implementation of the GHCi debugger - Fix typos in comments - Remove outdated comment in Lint.hs - Use 'LitRubbish' instead of 'RubbishLit' for consistency - Remove comment about subkinding - superseded by Note [Kind Constraint and kind Type] - Mention ticket ID in a linear types error message - Fix formatting in using-warnings.rst and linear-types.rst - Remove comment about 'Any' in Dynamic.hs - Dynamic now uses Typeable + existential instead of Any - Remove codeGen/should_compile/T13233.hs This was added by accident, it is not used and T13233 is already in should_fail - - - - - f7e41d78 by Matthew Pickering at 2021-06-22T02:35:24-04:00 ghc-bignum: trimed ~> trimmed Just a small typo which propagated through ghc-bignum - - - - - 62d720db by Potato Hatsue at 2021-06-22T02:36:00-04:00 Fix a typo in pattern synonyms doc - - - - - 87f57ecf by Adam Sandberg Ericsson at 2021-06-23T02:58:00-04:00 ci: fix ci.sh by creating build.mk in one place Previously `prepare_build_mk` created a build.mk that was overwritten right after. This makes the BIGNUM_BACKEND choice take effect, fixing #19953, and causing the metric increase below in the integer-simple job. Metric Increase: space_leak_001 - - - - - 7f6454fb by Matthew Pickering at 2021-06-23T02:58:35-04:00 Optimiser: Correctly deal with strings starting with unicode characters in exprConApp_maybe For example: "\0" is encoded to "C0 80", then the rule would correct use a decoding function to work out the first character was "C0 80" but then just used BS.tail so the rest of the string was "80". This resulted in "\0" being transformed into '\C0\80' : unpackCStringUTF8# "80" Which is obviously bogus. I rewrote the function to call utf8UnconsByteString directly and avoid the roundtrip through Faststring so now the head/tail is computed by the same call. Fixes #19976 - - - - - e14b893a by Matthew Pickering at 2021-06-23T02:59:09-04:00 testsuite: Don't try to run tests with missing libraries As noticed by sgraf, we were still running reqlib tests, even if the library was not available. The reasons for this were not clear to me as they would never work and it was causing some issues with empty stderr files being generated if you used --test-accept. Now if the required library is not there, the test is just skipped, and a counter increased to mark the fact. Perhaps in the future it would be nicer to explicitly record why certain tests are skipped. Missing libraries causing a skip is a special case at the moment. Fixes #20005 - - - - - aa1d0eb3 by sheaf at 2021-06-23T02:59:48-04:00 Enable TcPlugin tests on Windows - - - - - d8e5b274 by Matthew Pickering at 2021-06-23T03:00:23-04:00 ghci: Correct free variable calculation in StgToByteCode Fixes #20019 - - - - - 6bf82316 by Matthew Pickering at 2021-06-23T03:00:57-04:00 hadrian: Pass correct leading_underscore configuration to tests - - - - - 8fba28ec by Moritz Angermann at 2021-06-23T03:01:32-04:00 [testsuite] mark T3007 broken on darwin. Cabal explicitly passes options to set the rpath, which we then also try to set using install_name_tool. Cabal should also pass `-fno-use-rpaths` to suppress the setting of the rpath from within GHC. - - - - - 633bbc1f by Douglas Wilson at 2021-06-23T08:52:26+01:00 ci: Don't allow the nightly pipeline to be interrupted. Since 58cfcc65 the default for jobs has been "interruptible", this means that when new commits are pushed to a branch which already has a running pipeline then the old pipelines for this branch are cancelled. This includes the master branch, and in particular, new commits merged to the master branch will cancel the nightly job. The semantics of pipeline cancelling are actually a bit more complicated though. The interruptible flag is *per job*, but once a pipeline has run *any* non-interruptible job, then the whole pipeline is considered non-interruptible (ref https://gitlab.com/gitlab-org/gitlab/-/issues/32837). This leads to the hack in this MR where by default all jobs are `interruptible: True`, but for pipelines we definitely want to run, there is a dummy job which happens first, which is `interreuptible: False`. This has the effect of dirtying the whole pipeline and preventing another push to master from cancelling it. For now, this patch solves the immediate problem of making sure nightly jobs are not cancelled. In the future, we may want to enable this job also for the master branch, making that change might mean we need more CI capacity than currently available. [skip ci] Ticket: #19554 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 8191785e by Aaron Allen at 2021-06-23T20:33:48-04:00 Converts diagnostics for two errors in Ghc.Tc.Module (#19926) This adds constructors to TcRnMessage to replace use of TcRnUnknownMessage in Ghc.Tc.Module. Adds a test case for the UnsafeDueToPlugin warning. Closes #19926 - - - - - e2d8023d by Sylvain Henry at 2021-06-23T20:34:23-04:00 Add some tests for sized primops - - - - - d79530d1 by Moritz Angermann at 2021-06-23T20:34:23-04:00 [aarch64 NCG] Add better support for sub-word primops During the intial NCG development, GHC did not have support for anything below Words. As such the NCG didn't support any of this either. AArch64-Darwin however needs support for subword, as arguments in excess of the first eight (8) passed via registers are passed on the stack, and there in a packed fashion. Thus ghc learned about subword sizes. This than lead us to gain subword primops, and these subsequently highlighted deficiencies in the AArch64 NCG. This patch rectifies the ones I found through via the test-suite. I do not claim this to be exhaustive. Fixes: #19993 Metric Increase: T10421 T13035 T13719 T14697 T1969 T9203 T9872a T9872b T9872c T9872d T9961 haddock.Cabal haddock.base parsing001 - - - - - 38a6d8b8 by Viktor Dukhovni at 2021-06-23T20:34:58-04:00 Fix typo in Note [Quick Look for particular Ids] Fixes #20029 - - - - - 74c87414 by Tamar Christina at 2021-06-24T12:01:58-04:00 rts: move xxxHash out of the user namespace - - - - - 4023d4d9 by Krzysztof Gogolewski at 2021-06-24T12:02:33-04:00 Fix desugaring with unboxed types (#19883) - - - - - 4c6af6be by Alan Zimmerman at 2021-06-24T12:03:10-04:00 EPA: Bringing over tests and updates from ghc-exactprint - - - - - d6ab9c60 by Moritz Angermann at 2021-06-24T12:03:45-04:00 [aarch64-macho] Fix off-by-one error in the linker We need to be careful about the sign bit for BR26 relocation otherwise we end up encoding a large positive number and reading back a large negative number. - - - - - 48171833 by Matthew Pickering at 2021-06-24T12:04:19-04:00 CI: Fix the cabal_test job to compile the Distribution.Simple target The "Cabal test" was previously testing the compilation of the very advanced Setup.hs file. Now we compile the whole library, as the test intended. - - - - - 171413c6 by Matthew Pickering at 2021-06-24T12:04:19-04:00 cabal_test: Make output more like head.hackage output This helps with the import of the results into the performance database. - - - - - 138b7a57 by Viktor Dukhovni at 2021-06-24T12:04:54-04:00 There's no "errorWithCallStack", just use "error". There's no `errorWithCallStack`, only `errorWithStackTrace`, but the latter is now deprecated, since `error` now defaults to returning a stack strace. So rather than change this to the intended deprecated function we replace `errorWithCallStack` with `error` instead. - - - - - 4d5967b5 by Krzysztof Gogolewski at 2021-06-24T20:35:56-04:00 Fixes around incomplete guards (#20023, #20024) - Fix linearity error with incomplete MultiWayIf (#20023) - Fix partial pattern binding error message (#20024) - Remove obsolete test LinearPolyTest It tested the special typing rule for ($), which was removed during the implementation of Quick Look 97cff9190d3. - Fix ticket numbers in linear/*/all.T, they referred to linear types issue tracker - - - - - c1c29808 by Christian Takle at 2021-06-24T20:36:32-04:00 Update quantified_constraints.rst - - - - - 1c811959 by Moritz Angermann at 2021-06-24T20:37:07-04:00 [iserv] learn -wait cli flag Often times when attaching a debugger to iserv it's helpful to have iserv wait a few seconds for the debugger to attach. -wait can be passed via -opti-wait if needed. - - - - - f926ecfd by Matthew Pickering at 2021-06-24T20:37:42-04:00 linker: Replace one missed usage of Opt_RPath with useXLinkerRPath Thanks to @wz1000 for spotting this oversight. - - - - - fa6451b7 by Luite Stegeman at 2021-06-24T20:38:18-04:00 fix sdist for base library config.sub and config.guess aren't used anymore, so they should be removed from the base.cabal file - - - - - d1f59540 by sheaf at 2021-06-25T05:19:18-04:00 Make reallyUnsafePtrEquality# levity-polymorphic fixes #17126, updates containers submodule - - - - - 30afb381 by Matthew Pickering at 2021-06-25T05:19:53-04:00 ghci: Add test for #18330 This test was fixed by 25977ab542a30df4ae71d9699d015bcdd1ab7cfb Fixes #18330 - - - - - f43a11d7 by Matthew Pickering at 2021-06-25T05:19:53-04:00 driver: Add test for #17481 Fixed in 25977ab542a30df4ae71d9699d015bcdd1ab7cfb Fixes #17481 - - - - - eb39981a by Matthew Pickering at 2021-06-25T05:19:53-04:00 driver: Add test for T14923 - - - - - 83dce402 by Zubin Duggal at 2021-06-25T05:20:27-04:00 Add regression test for #19921 - - - - - 0bb78838 by Vladislav Zavialov at 2021-06-25T15:41:24-04:00 Suggest similar names when reporting types in terms (#19978) This fixes an error message regression. - - - - - 6cc80766 by Matthew Pickering at 2021-06-25T15:41:58-04:00 driver: Add implicit package dependencies for template-haskell package When TemplateHaskellQuotes is enabled, we also generate programs which mention symbols from the template-haskell module. So that package is added conditionally if the extension is turned on. We should really do the same for other wired-in packages: * base * ghc-bignum * ghc-prim * rts When we link an executable, we must also link against these libraries. In accordance with every other package, these dependencies should be added into the direct dependencies for a module automatically and end up in the interface file to record the fact the object file was created by linking against these packages. Unfortunately it is not so easy to work out when symbols from each of these libraries ends up in the generated program. You might think that `base` would always be used but the `ghc-prim` package doesn't depend on `base`, so you have to be a bit careful and this futher enhancement is left to a future patch. - - - - - 221a104f by GHC GitLab CI at 2021-06-26T22:42:03-04:00 codeGen: Fix header size for array write barriers Previously the code generator's logic for invoking the nonmoving write barrier was inconsistent with the write barrier itself. Namely, the code generator treated the header size argument as being in words whereas the barrier expected bytes. This was the cause of #19715. Fixes #19715. - - - - - 30f233fe by GHC GitLab CI at 2021-06-26T22:42:03-04:00 rts: Eliminate redundant branch Previously we branched unnecessarily on IF_NONMOVING_WRITE_BARRIER_ENABLED on every trip through the array barrier push loop. - - - - - 9b776cbb by sheaf at 2021-06-26T22:42:39-04:00 Re-export UnliftedRep and UnliftedType from GHC.Exts - - - - - b1792fef by Zubin Duggal at 2021-06-27T06:14:36-04:00 user-guide: Improve documentation of NumDecimals - - - - - 3e71874b by Jakob Brünker at 2021-06-27T06:15:11-04:00 Tc: Allow Typeable in quantified constraints Previously, when using Typeable in a quantified constraint, GHC would complain that user-specified instances of Typeable aren't allowed. This was because checking for SigmaCtxt was missing from a check for whether an instance head is a hand-written binding. Fixes #20033 - - - - - d7758da4 by Sebastian Graf at 2021-06-27T14:57:39-04:00 Simplifier: Do Cast W/W for INLINE strong loop-breakers Strong loop-breakers never inline, INLINE pragma or not. Hence they should be treated as if there was no INLINE pragma on them. Also not doing Cast W/W for INLINE strong loop-breakers will trip up Strictness W/W, because it treats them as if there was no INLINE pragma. Subsequently, that will lead to a panic once Strictness W/W will no longer do eta-expansion, as we discovered while implementing !5814. I also renamed to `unfoldingInfo` to `realUnfoldingInfo` and redefined `unfoldingInfo` to zap the unfolding it returns in case of a strong loop-breaker. Now the naming and semantics is symmetrical to `idUnfolding`/`realIdUnfolding`. Now there was no more reason for `hasInlineUnfolding` to operate on `Id`, because the zapping of strong loop-breaker unfoldings moved from `idUnfolding` to `unfoldingInfo`, so I refactored it to take `IdInfo` and call it both from the Simplifier and WorkWrap, making it utterly clear that both checks are equivalent. - - - - - eee498bf by Sebastian Graf at 2021-06-27T14:57:39-04:00 WorkWrap: Remove mkWWargs (#19874) `mkWWargs`'s job was pushing casts inwards and doing eta expansion to match the arity with the number of argument demands we w/w for. Nowadays, we use the Simplifier to eta expand to arity. In fact, in recent years we have even seen the eta expansion done by w/w as harmful, see Note [Don't eta expand in w/w]. If a function hasn't enough manifest lambdas, don't w/w it! What purpose does `mkWWargs` serve in this world? Not a great one, it turns out! I could remove it by pulling some important bits, notably Note [Freshen WW arguments] and Note [Join points and beta-redexes]. Result: We reuse the freshened binder names of the wrapper in the worker where possible (see testuite changes), much nicer! In order to avoid scoping errors due to lambda-bound unfoldings in worker arguments, we zap those unfoldings now. In doing so, we fix #19766. Fixes #19874. - - - - - 37472a10 by Sebastian Graf at 2021-06-27T14:57:39-04:00 WorkWrap: Make mkWWstr and mkWWcpr generate fewer let bindings In https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5814#note_355144, Simon noted that `mkWWstr` and `mkWWcpr` could generate fewer let bindings and be implemented less indirectly by returning the rebuilt expressions directly, e.g. instead of ``` f :: (Int, Int) -> Int f (x, y) = x+y ==> f :: (Int, Int) -> Int f p = case p of (x, y) -> case x of I# x' -> case y of I# y' -> case $wf x' y' of r' -> let r = I# r' -- immediately returned in r f :: Int# -> Int# -> Int# $wf x' y' = let x = I# x' in -- only used in p let y = I# y' in -- only used in p let p = (x, y) in -- only used in the App below case (\(x,y) -> x+y) p of I# r' -> r' ``` we know generate ``` f :: (Int, Int) -> Int f p = case p of (x, y) -> case x of I# x' -> case y of I# y' -> case $wf x' y' of r' -> I# r' -- 1 fewer let f :: Int# -> Int# -> Int# $wf x' y' = case (\(x,y) -> x+y) (I# x, I# y) of I# r' -> -- 3 fewer lets r' ``` Which is much nicer and makes it easier to comprehend the output of worker-wrapper pre-Simplification as well as puts less strain on the Simplifier. I had to drop support for #18983, but we found that it's broken anyway. Simon is working on a patch that provides a bit more justification. - - - - - e69d070b by Sebastian Graf at 2021-06-27T14:57:39-04:00 Add regression test for #17819 The only item left in #17819. Fixes #17819. - - - - - b92479f9 by Sebastian Graf at 2021-06-27T14:57:39-04:00 Inliner: Regard LitRubbish as TrivArg and not ConLike Part of fixing #19766 required the emission of `LitRubbish` as absent filler in places where we used `absentError` before. In WWRec we have the situation that such bindings occur in the argument to functions. With `LitRubbish` we inlined those functions, because 1. The absent binding was regarded as ConLike. So I fixed `exprIsHNFLike` to respond `False` to `LitRubbish`. 2. The other source of inlining was that after inlining such an absent binding, `LitRubbish` itself was regarded `ValueArg` by `interestingArg`, leading to more inlining. It now responds `TrivArg` to `LitRubbish`. Fixes #20035. There's one slight 1.6% ghc/alloc regression left in T15164 that is due to an additional specialisation `$s$cget`. I've no idea why that happens; the Core output before is identical and has the call site that we specialise for. Metric Decrease: WWRec - - - - - 43bbf4b2 by Sebastian Graf at 2021-06-27T14:57:39-04:00 testsuite: Widen acceptance window of T12545 (#19414) In a sequel of #19414, I wrote a script that measures min and max allocation bounds of T12545 based on randomly modifying -dunique-increment. I got a spread of as much as 4.8%. But instead of widening the acceptance window further (to 5%), I committed the script as part of this commit, so that false positive increases can easily be diagnosed by comparing min and max bounds to HEAD. Indeed, for !5814 we have seen T12545 go from -0.3% to 3.3% after a rebase. I made sure that the min and max bounds actually stayed the same. In the future, this kind of check can very easily be done in a matter of a minute. Maybe we should increase the acceptance threshold if we need to check often (leave a comment on #19414 if you had to check), but I've not been bitten by it for half a year, which seems OK. Metric Increase: T12545 - - - - - 469126b3 by Matthew Pickering at 2021-06-27T14:58:14-04:00 Revert "Make reallyUnsafePtrEquality# levity-polymorphic" This reverts commit d1f59540e8b7be96b55ab4b286539a70bc75416c. This commit breaks the build of unordered-containers ``` [3 of 9] Compiling Data.HashMap.Internal.Array ( Data/HashMap/Internal/Array.hs, dist/build/Data/HashMap/Internal/Array.o, dist/build/Data/HashMap/Internal/Array.dyn_o ) *** Parser [Data.HashMap.Internal.Array]: Parser [Data.HashMap.Internal.Array]: alloc=21043544 time=13.621 *** Renamer/typechecker [Data.HashMap.Internal.Array]: Renamer/typechecker [Data.HashMap.Internal.Array]: alloc=151218672 time=187.083 *** Desugar [Data.HashMap.Internal.Array]: ghc: panic! (the 'impossible' happened) GHC version 9.3.20210625: expectJust splitFunTy CallStack (from HasCallStack): error, called at compiler/GHC/Data/Maybe.hs:68:27 in ghc:GHC.Data.Maybe expectJust, called at compiler/GHC/Core/Type.hs:1247:14 in ghc:GHC.Core.Type ``` Revert containers submodule update - - - - - 46c2d0b0 by Peter Trommler at 2021-06-28T10:45:54-04:00 Fix libffi on PowerPC Update submodule libffi-tarballs to upstream commit 4f9e20a. Remove C compiler flags that suppress warnings in the RTS. Those warnings have been fixed by libffi upstream. Fixes #19885 - - - - - d4c43df1 by Zubin Duggal at 2021-06-28T10:46:29-04:00 Update docs for change in parsing behaviour of infix operators like in GHC 9 - - - - - 755cb2b0 by Alfredo Di Napoli at 2021-06-28T16:57:28-04:00 Try to simplify zoo of functions in `Tc.Utils.Monad` This commit tries to untangle the zoo of diagnostic-related functions in `Tc.Utils.Monad` so that we can have the interfaces mentions only `TcRnMessage`s while we push the creation of these messages upstream. It also ports TcRnMessage diagnostics to use the new API, in particular this commit switch to use TcRnMessage in the external interfaces of the diagnostic functions, and port the old SDoc to be wrapped into TcRnUnknownMessage. - - - - - a7f9670e by Ryan Scott at 2021-06-28T16:58:03-04:00 Fix type and strictness signature of forkOn# This is a follow-up to #19992, which fixes the type and strictness signature for `fork#`. The `forkOn#` primop also needs analogous changes, which this patch accomplishes. - - - - - b760c1f7 by Sebastian Graf at 2021-06-29T15:35:29-04:00 Demand: Better representation (#19050) In #19050, we identified several ways in which we could make more illegal states irrepresentable. This patch introduces a few representation changes around `Demand` and `Card` with a better and earlier-failing API exported through pattern synonyms. Specifically, 1. The old enum definition of `Card` led to severely bloated code of operations on it. I switched to a bit vector representation; much nicer overall IMO. See Note [Bit vector representation for Card]. Most of the gripes with the old representation were related to where which kind of `Card` was allowed and the fact that it doesn't make sense for an absent or bottoming demand to carry a `SubDemand` that describes an evaluation context that is never realised. 2. So I refactored the `Demand` representation so that it has two new data constructors for `AbsDmd` and `BotDmd`. The old `(:*)` data constructor becomes a pattern synonym which expands absent demands as needed, so that it still forms a complete match and a versatile builder. The new `Demand` data constructor now carries a `CardNonAbs` and only occurs in a very limited number of internal call sites. 3. Wherever a full-blown `Card` might end up in a `CardNonAbs` field (like that of `D` or `Call`), I assert the consistency. When the smart builder of `(:*)` is called with an absent `Card`, I assert that the `SubDemand` is the same that we would expand to in the matcher. 4. `Poly` now takes a `CardNonOnce` and encodes the previously noticed invariant that we never produce `Poly C_11` or `Poly C_01`. I made sure that we never construct a `Poly` with `C_11` or `C_01`. Fixes #19050. We lose a tiny bit of anal perf overall, probably because the new `Demand` definition can't be unboxed. The biggest loser is WWRec, where allocations go from 16MB to 26MB in DmdAnal, making up for a total increase of (merely) 1.6%. It's all within acceptance thresholds. There are even two ghc/alloc metric decreases. T11545 decreases by *67%*! Metric Decrease: T11545 T18304 - - - - - 4e9f58c7 by sheaf at 2021-06-29T15:36:08-04:00 Use HsExpansion for overloaded list patterns Fixes #14380, #19997 - - - - - 2ce7c515 by Matthew Pickering at 2021-06-29T15:36:42-04:00 ci: Don't allow aarch64-darwin to fail Part way to #20013 - - - - - f79615d2 by Roland Senn at 2021-07-01T03:29:58-04:00 Add testcase for #19460 Avoid an other regression. - - - - - b51b4b97 by Sylvain Henry at 2021-07-01T03:30:36-04:00 Make withException use SDocContext instead of DynFlags - - - - - 6f097a81 by Sylvain Henry at 2021-07-01T03:30:36-04:00 Remove useless .hs-boot - - - - - 6d712150 by Sylvain Henry at 2021-07-01T03:30:36-04:00 Dynflags: introduce DiagOpts Use DiagOpts for diagnostic options instead of directly querying DynFlags (#17957). Surprising performance improvements on CI: T4801(normal) ghc/alloc 313236344.0 306515216.0 -2.1% GOOD T9961(normal) ghc/alloc 384502736.0 380584384.0 -1.0% GOOD ManyAlternatives(normal) ghc/alloc 797356128.0 786644928.0 -1.3% ManyConstructors(normal) ghc/alloc 4389732432.0 4317740880.0 -1.6% T783(normal) ghc/alloc 408142680.0 402812176.0 -1.3% Metric Decrease: T4801 T9961 T783 ManyAlternatives ManyConstructors Bump haddock submodule - - - - - d455c39e by Emily Martins at 2021-07-01T03:31:13-04:00 Unify primary and secondary GHCi prompt Fixes #20042 Signed-off-by: Emily Martins <emily.flakeheart at gmail.com> Signed-off-by: Hécate Moonlight <hecate at glitchbra.in> - - - - - 05ae4772 by Emily Martins at 2021-07-01T03:31:13-04:00 Unify remaining GHCi prompt example Signed-off-by: Emily Martins <emily.flakeheart at gmail.com> - - - - - c22761fa by Moritz Angermann at 2021-07-01T03:31:48-04:00 [ci] don't allow aarch64-linux (ncg) to fail by accepting the current state of metrics (and the NCG is new, so this seems prudent to do), we can require aarch64-linux (ncg) to build without permitting failure. Metric Increase: T13035 T13719 T14697 T1969 T9203 T9872a T9872b T9872c T9872d T9961 WWRec haddock.Cabal haddock.base parsing001 - - - - - 82e6a4d2 by Moritz Angermann at 2021-07-01T03:31:48-04:00 [ci] Separate llvm and NCG test metrics for aarch64-linux - - - - - e8192ae4 by Moritz Angermann at 2021-07-01T03:31:48-04:00 [Parser: Lexer] Fix !6132 clang's cpp injects spaces prior to #!/. - - - - - 66bd5931 by Moritz Angermann at 2021-07-01T03:31:48-04:00 [ci] Enable T6132 across all targets We should have fixed clangs mess now. - - - - - 66834286 by Marco Zocca at 2021-07-01T10:23:52+00:00 float out some docstrings and comment some function parameters - - - - - a3c451be by Roland Senn at 2021-07-01T16:05:21-04:00 Remove redundant test case print036. The test case `print036` was marked `broken` by #9046. Issue #9046 is a duplicate of #12449. However the test case `T12449` contains several test that are similar to those in `print036`. Hence test case `print036` is redundant and can be deleted. - - - - - 6ac9ea86 by Simon Peyton Jones at 2021-07-02T00:27:04-04:00 One-shot changes (#20008) I discovered that GHC.Core.Unify.bindTv was getting arity 2, rather than 3, in one of my builds. In HEAD it does get the right arity, but only because CallArity (just) manages to spot it. In my situation it (just) failed to discover this. Best to make it robust, which this patch does. See Note [INLINE pragmas and (>>)] in GHC.Utils.Monad. There a bunch of other modules that probably should have the same treatment: GHC.CmmToAsm.Reg.Linear.State GHC.Tc.Solver.Monad GHC.Tc.Solver.Rewrite GHC.Utils.Monad.State.Lazy GHC.Utils.Monad.State.Strict but doing so is not part of this patch - - - - - a820f900 by Sylvain Henry at 2021-07-02T00:27:42-04:00 Detect underflow in fromIntegral/Int->Natural rule Fix #20066 - - - - - bb716a93 by Viktor Dukhovni at 2021-07-02T04:28:34-04:00 Fix cut/paste typo foldrM should be foldlM - - - - - 39d665e4 by Moritz Angermann at 2021-07-02T04:29:09-04:00 Revert "Move validate-x86_64-linux-deb9-hadrian back to quick-build" This reverts commit a0622459f1d9a7068e81b8a707ffc63e153444f8. - - - - - c1c98800 by Moritz Angermann at 2021-07-02T04:29:09-04:00 Move aarch64-linux-llvm to nightly This job takes by far the longest time on its own, we now have a NCG. Once we have fast aarch64 machines, we can consider putting this one back. - - - - - 5e30451d by Luite Stegeman at 2021-07-02T23:24:38-04:00 Support unlifted datatypes in GHCi fixes #19628 - - - - - 9b1d9cbf by Sebastian Graf at 2021-07-02T23:25:13-04:00 Arity: Handle shadowing properly In #20070, we noticed that `findRhsArity` copes badly with shadowing. A simple function like `g_123 x_123 = x_123`, where the labmda binder shadows, already regressed badly. Indeed, the whole `arityType` function wasn't thinking about shadowing *at all*. I rectified that and established the invariant that `ae_join` and `am_sigs` should always be disjoint. That entails deleting bindings from `ae_join` whenever we add something to `am_sigs` and vice versa, which would otherwise be a bug in the making. That *should* fix (but I don't want to close it) #20070. - - - - - 4b4c5e43 by Fraser Tweedale at 2021-07-06T13:36:46-04:00 Implement improved "get executable path" query System.Environment.getExecutablePath has some problems: - Some system-specific implementations throw an exception in some scenarios, e.g. when the executable file has been deleted - The Linux implementation succeeds but returns an invalid FilePath when the file has been deleted. - The fallback implementation returns argv[0] which is not necessarily an absolute path, and is subject to manipulation. - The documentation does not explain any of this. Breaking the getExecutablePath API or changing its behaviour is not an appealing direction. So we will provide a new API. There are two facets to the problem of querying the executable path: 1. Does the platform provide a reliable way to do it? This is statically known. 2. If so, is there a valid answer, and what is it? This may vary, even over the runtime of a single process. Accordingly, the type of the new mechanism is: Maybe (IO (Maybe FilePath)) This commit implements this mechanism, defining the query action for FreeBSD, Linux, macOS and Windows. Fixes: #10957 Fixes: #12377 - - - - - a4e742c5 by Fraser Tweedale at 2021-07-06T13:36:46-04:00 Add test for executablePath - - - - - 4002bd1d by Ethan Kiang at 2021-07-06T13:37:24-04:00 Pass '-x c++' and '-std=c++11' to `cc` for cpp files, in Hadrian '-x c++' was found to be required on Darwin Clang 11 and 12. '-std=c++' was found to be needed on Clang 12 but not 11. - - - - - 354ac99d by Sylvain Henry at 2021-07-06T13:38:06-04:00 Use target platform in guessOutputFile - - - - - 17091114 by Edward at 2021-07-06T13:38:42-04:00 Fix issue 20038 - Change 'variable' -> 'variables' - - - - - 6618008b by Andreas Klebinger at 2021-07-06T21:17:37+00:00 Fix #19889 - Invalid BMI2 instructions generated. When arguments are 8 *or 16* bits wide, then truncate before/after and use the 32bit operation. - - - - - 421beb3f by Matthew Pickering at 2021-07-07T11:56:36-04:00 driver: Convert runPipeline to use a free monad This patch converts the runPipeline function to be implemented in terms of a free monad rather than the previous CompPipeline. The advantages of this are three-fold: 1. Different parts of the pipeline can return different results, the limits of runPipeline were being pushed already by !5555, this opens up futher fine-grainedism of the pipeline. 2. The same mechanism can be extended to build-plan at the module level so the whole build plan can be expressed in terms of one computation which can then be treated uniformly. 3. The pipeline monad can now be interpreted in different ways, for example, you may want to interpret the `TPhase` action into the monad for your own build system (such as shake). That bit will probably require a bit more work, but this is a step in the right directin. There are a few more modules containing useful functions for interacting with the pipelines. * GHC.Driver.Pipeline: Functions for building pipelines at a high-level * GHC.Driver.Pipeline.Execute: Functions for providing the default interpretation of TPhase, in terms of normal IO. * GHC.Driver.Pipeline.Phases: The home for TPhase, the typed phase data type which dictates what the phases are. * GHC.Driver.Pipeline.Monad: Definitions to do with the TPipelineClass and MonadUse class. Hooks consumers may notice the type of the `phaseHook` has got slightly more restrictive, you can now no longer control the continuation of the pipeline by returning the next phase to execute but only override individual phases. If this is a problem then please open an issue and we will work out a solution. ------------------------- Metric Decrease: T4029 ------------------------- - - - - - 5a31abe3 by Matthew Pickering at 2021-07-07T11:56:36-04:00 driver: Add test for #12983 This test has worked since 8.10.2 at least but was recently broken and is now working again after this patch. Closes #12983 - - - - - 56eb57a6 by Alfredo Di Napoli at 2021-07-08T08:13:23+02:00 Rename getErrorMessages and getMessages function in parser code This commit renames the `getErrorMessages` and `getMessages` function in the parser code to `getPsErrorMessages` and `getPsMessages`, to avoid import conflicts, as we have already `getErrorMessages` and `getMessages` defined in `GHC.Types.Error`. Fixes #19920. Update haddock submodule - - - - - 82284ba1 by Matthew Pickering at 2021-07-09T08:46:09-04:00 Remove reqlib from cgrun025 test - - - - - bc38286c by Matthew Pickering at 2021-07-09T08:46:09-04:00 Make throwto002 a normal (not reqlib) test - - - - - 573012c7 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add the TcRnShadowedName constructor to TcRnMessage This commit adds the TcRnShadowedName to the TcRnMessage type and it uses it in GHC.Rename.Utils. - - - - - 55872423 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add the TcRnDuplicateWarningDecls to TcRnMessage - - - - - 1e805517 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnSimplifierTooManyIterations to TcRnMessage - - - - - bc2c00dd by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalPatSynDecl to TcRnMessage - - - - - 52353476 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnEmptyRecordUpdate to TcRnMessage - - - - - f0a02dcc by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalFieldPunning to TcRnMessage - - - - - 5193bd06 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalWildCardsInRecord to TcRnMessage - - - - - e17850c4 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnDuplicateFieldName to TcRnMessage - - - - - 6b4f3a99 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalViewPattern to TcRnMessage - - - - - 8d28b481 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnCharLiteralOutOfRange to TcRnMessage - - - - - 64e20521 by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Remove redundant patSigErr - - - - - 60fabd7e by Alfredo Di Napoli at 2021-07-09T08:46:44-04:00 Add TcRnIllegalWildcardsInConstructor to TcRnMessage - - - - - 2d4cdfda by Sylvain Henry at 2021-07-09T08:47:22-04:00 Avoid unsafePerformIO for getProgName getProgName was used to append the name of the program (e.g. "ghc") to printed error messages in the Show instance of GhcException. It doesn't belong here as GHCi and GHC API users may want to override this behavior by setting a different error handler. So we now call it in the defaultErrorHandler instead. - - - - - 901f0e1b by sheaf at 2021-07-10T13:29:03+02:00 Don't return unitExpr in dsWhenNoErrs - fixes #18149 and #14765 dsWhenNoErrs now returns "runtimeError @ty" when disallowed representation polymorphism is detected, where ty is the type of the result CoreExpr. "ty" is passed as an additional argument to dsWhenNoErrs, and is used only in the case of such an error. The calls to dsWhenNoErrs must now compute the type of the CoreExpr they are trying to build, so that an error of the right type can be used in case of a representation polymorphism failure. - - - - - c38bce73 by Matthew Pickering at 2021-07-10T19:59:34-04:00 ci: Copy the cache from inside the nix-shell where $HOME is different on darwin Hopefully fixes the flaky CI failures we have seen recently. Co-authored-by: Moritz Angerman <moritz.angermann at gmail.com> - - - - - a181313e by Alfredo Di Napoli at 2021-07-12T14:19:22+02:00 Add proper GHCHints for most PsMessage constructors This commit adds proper hints to most diagnostic types in the `GHC.Parser.Errors.Types` module. By "proper" we mean that previous to this commit the hints were bundled together with the diagnostic message, whereas now we moved most of them as proper `[GhcHint]` in the implementation of `diagnosticHints`. More specifically, this is the list of constructors which now has proper hints: * PsErrIllegalBangPattern * PsWarnOperatorWhitespaceExtConflict * PsErrLambdaCase * PsErrIllegalPatSynExport * PsWarnOperatorWhitespace * PsErrMultiWayIf * PsErrIllegalQualifiedDo * PsErrNumUnderscores * PsErrLinearFunction * PsErrIllegalTraditionalRecordSyntax * PsErrIllegalExplicitNamespace * PsErrOverloadedRecordUpdateNotEnabled * PsErrIllegalDataTypeContext * PsErrSemiColonsInCondExpr * PsErrSemiColonsInCondCmd * PsWarnStarIsType * PsWarnImportPreQualified * PsErrImportPostQualified * PsErrEmptyDoubleQuotes * PsErrIllegalRoleName * PsWarnStarBinder For some reason, this patch increases the peak_megabyte_allocated of the T11545 test to 90 (from a baseline of 80) but that particular test doesn't emit any parsing diagnostic or hint and the metric increase happens only for the `aarch64-linux-deb10`. Metric Increase: T11545 - - - - - aef7d513 by Matthew Pickering at 2021-07-13T15:16:19-04:00 driver: Fix interaction of -Wunused-packages and reexported-modules Spurious warnings were previously emitted if an import came from a reexport due to how -Wunused-packages were implemented. Removing the dependency would cause compilation to fail. The fix is to reimplement the warning a bit more directly, by searching for which package each import comes from using the normal module finding functions rather than consulting the EPS. This has the advantage that the check could be performed at any time after downsweep rather than also relying on a populated EPS. Fixes #19518 and #19777 - - - - - bb8e0df8 by Adrien at 2021-07-13T15:16:56-04:00 Added a hopefully clarificatory sentence about the notion of "atomicity" presupposed in the documentation on MVar. - - - - - 99921593 by Zubin Duggal at 2021-07-13T20:45:44+00:00 Don't panic on 'no skolem info' and add failing tests - - - - - de98a0ce by Sylvain Henry at 2021-07-15T23:29:09-04:00 Additional constant-folding rule for binary AND/OR Add a constant folding rule allowing the subsumption of an application if the same argument is applied twice, e.g. (v .&. 0xFF) .&. 0xFF ~~> v .&. 0xFF (v .|. 0xFF) .|. 0xFF ~~> v .|. 0xFF - - - - - 41d6cfc4 by Sylvain Henry at 2021-07-15T23:29:09-04:00 Add Word64#/Int64# primops Word64#/Int64# are only used on 32-bit architectures. Before this patch, operations on these types were directly using the FFI. Now we use real primops that are then lowered into ccalls. The advantage of doing this is that we can now perform constant folding on Word64#/Int64# (#19024). Most of this work was done by John Ericson in !3658. However this patch doesn't go as far as e.g. changing Word64 to always be using Word64#. Noticeable performance improvements T9203(normal) run/alloc 89870808.0 66662456.0 -25.8% GOOD haddock.Cabal(normal) run/alloc 14215777340.8 12780374172.0 -10.1% GOOD haddock.base(normal) run/alloc 15420020877.6 13643834480.0 -11.5% GOOD Metric Decrease: T9203 haddock.Cabal haddock.base - - - - - 5b187575 by Simon Peyton Jones at 2021-07-19T10:59:38+01:00 Better sharing of join points (#19996) This patch, provoked by regressions in the text package (#19557), improves sharing of join points. This also fixes the terrible behaviour in #20049. See Note [Duplicating join points] in GHC.Core.Opt.Simplify. * In the StrictArg case of mkDupableContWithDmds, don't use Plan A for data constructors * In postInlineUnconditionally, don't inline JoinIds Avoids inlining join $j x = Just x in case blah of A -> $j x1 B -> $j x2 C -> $j x3 * In mkDupableStrictBind and mkDupableStrictAlt, create join points (much) more often: exprIsTrivial rather than exprIsDupable. This may be much, but we'll see. Metric Decrease: T12545 T13253-spj T13719 T18140 T18282 T18304 T18698a T18698b Metric Increase: T16577 T18923 T9961 - - - - - e5a4cfa5 by Sylvain Henry at 2021-07-19T19:36:37-04:00 Bignum: don't allocate in bignat_mul (#20028) We allocated the recursively entered `mul` helper function because it captures some args. - - - - - 952ba18e by Matthew Pickering at 2021-07-19T19:37:12-04:00 th: Weaken return type of myCoreToStgExpr The previous code assumed properties of the CoreToStg translation, namely that a core let expression which be translated to a single non-recursive top-level STG binding. This assumption was false, as evidenced by #20060. The consequence of this was the need to modify the call sites of `myCoreToStgExpr`, the main one being in hscCompileCoreExpr', which the meant we had to use byteCodeGen instead of stgExprToBCOs to convert the returned value to bytecode. I removed the `stgExprToBCOs` function as it is no longer used in the compiler. There is still some partiallity with this patch (the lookup in hscCompileCoreExpr') but this should be more robust that before. Fixes #20060 - - - - - 3e8b39ea by Alfredo Di Napoli at 2021-07-19T19:37:47-04:00 Rename RecordPuns to NamedFieldPuns in LangExt.Extension This commit renames the `RecordPuns` type constructor inside `GHC.LanguageExtensions.Type.hs` to `NamedFieldPuns`. The rationale is that the `RecordPuns` language extension was deprecated a long time ago, but it was still present in the AST, introducing an annoying mismatch between what GHC suggested (i.e. "use NamedFieldPuns") and what that translated into in terms of Haskell types. - - - - - 535123e4 by Simon Peyton Jones at 2021-07-19T19:38:21-04:00 Don't duplicate constructors in the simplifier Ticket #20125 showed that the Simplifier could sometimes duplicate a constructor binding. CSE would often eliminate it later, but doing it in the first place was utterly wrong. See Note [Do not duplicate constructor applications] in Simplify.hs I also added a short-cut to Simplify.simplNonRecX for the case when the RHS is trivial. I don't think this will change anything, just make the compiler run a tiny bit faster. - - - - - 58b960d2 by Sylvain Henry at 2021-07-19T19:38:59-04:00 Make TmpFs independent of DynFlags This is small step towards #19877. We want to make the Loader/Linker interface more abstract to be easily reused (i.e. don't pass it DynFlags) but the system linker uses TmpFs which required a DynFlags value to get its temp directory. We explicitly pass the temp directory now. Similarly TmpFs was consulting the DynFlags to decide whether to clean or: this is now done by the caller in the driver code. - - - - - d706fd04 by Matthew Pickering at 2021-07-20T09:22:46+01:00 hadrian: Update docs targets documentation [skip ci] The README had got a little out of sync with the current state of affairs. - - - - - 9eb1641e by Matthew Pickering at 2021-07-21T02:45:39-04:00 driver: Fix recompilation for modules importing GHC.Prim The GHC.Prim module is quite special as there is no interface file, therefore it doesn't appear in ms_textual_imports, but the ghc-prim package does appear in the direct package dependencies. This confused the recompilation checking which couldn't find any modules from ghc-prim and concluded that the package was no longer a dependency. The fix is to keep track of whether GHC.Prim is imported separately in the relevant places. Fixes #20084 - - - - - 06d1ca85 by Alfredo Di Napoli at 2021-07-21T02:46:13-04:00 Refactor SuggestExtension constructor in GhcHint This commit refactors the SuggestExtension type constructor of the GhcHint to be more powerful and flexible. In particular, we can now embed extra user information (essentially "sugar") to help clarifying the suggestion. This makes the following possible: Suggested fix: Perhaps you intended to use GADTs or a similar language extension to enable syntax: data T where We can still give to IDEs and tools a `LangExt.Extension` they can use, but in the pretty-printed message we can tell the user a bit more on why such extension is needed. On top of that, we now have the ability to express conjuctions and disjunctons, for those cases where GHC suggests to enable "X or Y" and for the cases where we need "X and Y". - - - - - 5b157eb2 by Fendor at 2021-07-21T02:46:50-04:00 Use Ways API instead of Set specific functions - - - - - 10124b16 by Mario Blažević at 2021-07-21T02:47:25-04:00 template-haskell: Add support for default declarations Fixes #19373 - - - - - 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 - - - - - 149dd4f0 by Ben Gamari at 2022-09-14T16:59:18-04:00 llvmGen: Adapt to allow LLVM 15 We now must use `-passes` in place of `-O<n>` due to #21936. Closes #21936. - - - - - 11 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 - .gitlab/issue_templates/feature_request.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/25e2165fc5916540ee8f63205431d79ceda83ef7...149dd4f016f6b1897c3d060dd6202f20130040c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/25e2165fc5916540ee8f63205431d79ceda83ef7...149dd4f016f6b1897c3d060dd6202f20130040c3 You're receiving 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 Sep 14 21:17:25 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 17:17:25 -0400 Subject: [Git][ghc/ghc][master] 6 commits: hadrian: Use a stamp file to record when a package is built in a certain way Message-ID: <632244e553acc_3b59a620aecbec11667f2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - .gitlab/ci.sh - hadrian/hadrian.cabal - hadrian/src/Base.hs - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Context/Type.hs - hadrian/src/Hadrian/Builder.hs - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs - hadrian/src/Oracles/ModuleFiles.hs - hadrian/src/Packages.hs - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Dependencies.hs - hadrian/src/Rules/Documentation.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Libffi.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Nofib.hs - hadrian/src/Rules/Program.hs - hadrian/src/Rules/Register.hs - hadrian/src/Rules/Rts.hs - hadrian/src/Rules/SourceDist.hs - hadrian/src/Rules/Test.hs - hadrian/src/Rules/ToolArgs.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Common.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Builders/GhcPkg.hs - hadrian/src/Settings/Builders/Haddock.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d7e71b03f4b2eb693f5ea69dadbccf491e7403f...71d8db86d159e3f3f4d1d23c124306cac6448a96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d7e71b03f4b2eb693f5ea69dadbccf491e7403f...71d8db86d159e3f3f4d1d23c124306cac6448a96 You're receiving 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 Sep 14 21:17:56 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 17:17:56 -0400 Subject: [Git][ghc/ghc][master] Repair c++ probing on OpenBSD Message-ID: <63224504e551b_3b59a6194ffb5011706b1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 ``` - - - - - 1 changed file: - m4/fp_find_cxx_std_lib.m4 Changes: ===================================== m4/fp_find_cxx_std_lib.m4 ===================================== @@ -75,6 +75,7 @@ EOF case $CXX_STD_LIB_FLAVOUR in c++) try_libs "-lc++ -lc++abi" "libc++.so" "c++ c++abi" || \ + try_libs "-lc++ -lc++abi -lpthread" "libc++.so" "c++ c++abi pthread" || \ try_libs "-lc++ -lcxxrt" "libc++.so" "c++ cxxrt" || AC_MSG_ERROR([Failed to find C++ standard library]) ;; stdc++) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43e574f04fc2b612356a9805abe60b708b0b32c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43e574f04fc2b612356a9805abe60b708b0b32c9 You're receiving 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 Sep 14 21:18:51 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 17:18:51 -0400 Subject: [Git][ghc/ghc][master] libraries: template-haskell: vendor filepath differently Message-ID: <6322453bcb541_3b59a65183811739ca@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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) - - - - - 5 changed files: - libraries/template-haskell/changelog.md - libraries/template-haskell/template-haskell.cabal.in - + libraries/template-haskell/vendored-filepath/System/FilePath.hs - + libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs - + libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs Changes: ===================================== libraries/template-haskell/changelog.md ===================================== @@ -20,6 +20,11 @@ is used as operator, it will be bound to a promoted data constructor rather than a type constructor, if both are in scope. + * Add a `vendor-filepath` Cabal flag to the `template-haskell` package. If + this flag is set then `template-haskell` will not depend on the `filepath` + package and will instead use some modules from `filepath` that have been + copied into the `template-haskell` source tree. + ## 2.18.0.0 * The types of `ConP` and `conP` have been changed to allow for an additional list of type applications preceding the argument patterns. ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -73,7 +73,7 @@ Library System.FilePath System.FilePath.Posix System.FilePath.Windows - hs-source-dirs: ../filepath . + hs-source-dirs: ./vendored-filepath . default-extensions: ImplicitPrelude else ===================================== libraries/template-haskell/vendored-filepath/System/FilePath.hs ===================================== @@ -0,0 +1,149 @@ +-- Vendored from filepath v1.4.2.2 + +{-# LANGUAGE CPP #-} +#if __GLASGOW_HASKELL__ >= 704 +{-# LANGUAGE Safe #-} +#endif +{- | +Module : System.FilePath +Copyright : (c) Neil Mitchell 2005-2014 +License : BSD3 + +Maintainer : ndmitchell at gmail.com +Stability : stable +Portability : portable + +A library for 'FilePath' manipulations, using Posix or Windows filepaths +depending on the platform. + +Both "System.FilePath.Posix" and "System.FilePath.Windows" provide the +same interface. + +Given the example 'FilePath': @\/directory\/file.ext@ + +We can use the following functions to extract pieces. + +* 'takeFileName' gives @\"file.ext\"@ + +* 'takeDirectory' gives @\"\/directory\"@ + +* 'takeExtension' gives @\".ext\"@ + +* 'dropExtension' gives @\"\/directory\/file\"@ + +* 'takeBaseName' gives @\"file\"@ + +And we could have built an equivalent path with the following expressions: + +* @\"\/directory\" '' \"file.ext\"@. + +* @\"\/directory\/file" '<.>' \"ext\"@. + +* @\"\/directory\/file.txt" '-<.>' \"ext\"@. + +Each function in this module is documented with several examples, +which are also used as tests. + +Here are a few examples of using the @filepath@ functions together: + +/Example 1:/ Find the possible locations of a Haskell module @Test@ imported from module @Main@: + +@['replaceFileName' path_to_main \"Test\" '<.>' ext | ext <- [\"hs\",\"lhs\"] ]@ + +/Example 2:/ Download a file from @url@ and save it to disk: + + at do let file = 'makeValid' url + System.Directory.createDirectoryIfMissing True ('takeDirectory' file)@ + +/Example 3:/ Compile a Haskell file, putting the @.hi@ file under @interface@: + +@'takeDirectory' file '' \"interface\" '' ('takeFileName' file '-<.>' \"hi\")@ + +References: +[1] (Microsoft MSDN) +-} + + +#if defined(mingw32_HOST_OS) || defined(__MINGW32__) +module System.FilePath( + -- * Separator predicates + FilePath, + pathSeparator, pathSeparators, isPathSeparator, + searchPathSeparator, isSearchPathSeparator, + extSeparator, isExtSeparator, + + -- * @$PATH@ methods + splitSearchPath, getSearchPath, + + -- * Extension functions + splitExtension, + takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>), + splitExtensions, dropExtensions, takeExtensions, replaceExtensions, isExtensionOf, + stripExtension, + + -- * Filename\/directory functions + splitFileName, + takeFileName, replaceFileName, dropFileName, + takeBaseName, replaceBaseName, + takeDirectory, replaceDirectory, + combine, (), + splitPath, joinPath, splitDirectories, + + -- * Drive functions + splitDrive, joinDrive, + takeDrive, hasDrive, dropDrive, isDrive, + + -- * Trailing slash functions + hasTrailingPathSeparator, + addTrailingPathSeparator, + dropTrailingPathSeparator, + + -- * File name manipulations + normalise, equalFilePath, + makeRelative, + isRelative, isAbsolute, + isValid, makeValid +) where +import System.FilePath.Windows +#else +module System.FilePath( + -- * Separator predicates + FilePath, + pathSeparator, pathSeparators, isPathSeparator, + searchPathSeparator, isSearchPathSeparator, + extSeparator, isExtSeparator, + + -- * @$PATH@ methods + splitSearchPath, getSearchPath, + + -- * Extension functions + splitExtension, + takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>), + splitExtensions, dropExtensions, takeExtensions, replaceExtensions, isExtensionOf, + stripExtension, + + -- * Filename\/directory functions + splitFileName, + takeFileName, replaceFileName, dropFileName, + takeBaseName, replaceBaseName, + takeDirectory, replaceDirectory, + combine, (), + splitPath, joinPath, splitDirectories, + + -- * Drive functions + splitDrive, joinDrive, + takeDrive, hasDrive, dropDrive, isDrive, + + -- * Trailing slash functions + hasTrailingPathSeparator, + addTrailingPathSeparator, + dropTrailingPathSeparator, + + -- * File name manipulations + normalise, equalFilePath, + makeRelative, + isRelative, isAbsolute, + isValid, makeValid +) where +import System.FilePath.Posix +#endif ===================================== libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs ===================================== @@ -0,0 +1,1047 @@ +-- Vendored from filepath v1.4.2.2 + +{-# LANGUAGE PatternGuards #-} + +-- This template expects CPP definitions for: +-- MODULE_NAME = Posix | Windows +-- IS_WINDOWS = False | True + +-- | +-- Module : System.FilePath.MODULE_NAME +-- Copyright : (c) Neil Mitchell 2005-2014 +-- License : BSD3 +-- +-- Maintainer : ndmitchell at gmail.com +-- Stability : stable +-- Portability : portable +-- +-- A library for 'FilePath' manipulations, using MODULE_NAME style paths on +-- all platforms. Importing "System.FilePath" is usually better. +-- +-- Given the example 'FilePath': @\/directory\/file.ext@ +-- +-- We can use the following functions to extract pieces. +-- +-- * 'takeFileName' gives @\"file.ext\"@ +-- +-- * 'takeDirectory' gives @\"\/directory\"@ +-- +-- * 'takeExtension' gives @\".ext\"@ +-- +-- * 'dropExtension' gives @\"\/directory\/file\"@ +-- +-- * 'takeBaseName' gives @\"file\"@ +-- +-- And we could have built an equivalent path with the following expressions: +-- +-- * @\"\/directory\" '' \"file.ext\"@. +-- +-- * @\"\/directory\/file" '<.>' \"ext\"@. +-- +-- * @\"\/directory\/file.txt" '-<.>' \"ext\"@. +-- +-- Each function in this module is documented with several examples, +-- which are also used as tests. +-- +-- Here are a few examples of using the @filepath@ functions together: +-- +-- /Example 1:/ Find the possible locations of a Haskell module @Test@ imported from module @Main@: +-- +-- @['replaceFileName' path_to_main \"Test\" '<.>' ext | ext <- [\"hs\",\"lhs\"] ]@ +-- +-- /Example 2:/ Download a file from @url@ and save it to disk: +-- +-- @do let file = 'makeValid' url +-- System.Directory.createDirectoryIfMissing True ('takeDirectory' file)@ +-- +-- /Example 3:/ Compile a Haskell file, putting the @.hi@ file under @interface@: +-- +-- @'takeDirectory' file '' \"interface\" '' ('takeFileName' file '-<.>' \"hi\")@ +-- +-- References: +-- [1] (Microsoft MSDN) +module System.FilePath.Posix + ( + -- * Separator predicates + FilePath, + pathSeparator, pathSeparators, isPathSeparator, + searchPathSeparator, isSearchPathSeparator, + extSeparator, isExtSeparator, + + -- * @$PATH@ methods + splitSearchPath, getSearchPath, + + -- * Extension functions + splitExtension, + takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>), + splitExtensions, dropExtensions, takeExtensions, replaceExtensions, isExtensionOf, + stripExtension, + + -- * Filename\/directory functions + splitFileName, + takeFileName, replaceFileName, dropFileName, + takeBaseName, replaceBaseName, + takeDirectory, replaceDirectory, + combine, (), + splitPath, joinPath, splitDirectories, + + -- * Drive functions + splitDrive, joinDrive, + takeDrive, hasDrive, dropDrive, isDrive, + + -- * Trailing slash functions + hasTrailingPathSeparator, + addTrailingPathSeparator, + dropTrailingPathSeparator, + + -- * File name manipulations + normalise, equalFilePath, + makeRelative, + isRelative, isAbsolute, + isValid, makeValid + ) + where + +import Data.Char(toLower, toUpper, isAsciiLower, isAsciiUpper) +import Data.Maybe(isJust) +import Data.List(stripPrefix, isSuffixOf) + +import System.Environment(getEnv) + + +infixr 7 <.>, -<.> +infixr 5 + + + + + +--------------------------------------------------------------------- +-- Platform Abstraction Methods (private) + +-- | Is the operating system Unix or Linux like +isPosix :: Bool +isPosix = not isWindows + +-- | Is the operating system Windows like +isWindows :: Bool +isWindows = False + + +--------------------------------------------------------------------- +-- The basic functions + +-- | The character that separates directories. In the case where more than +-- one character is possible, 'pathSeparator' is the \'ideal\' one. +-- +-- > Windows: pathSeparator == '\\' +-- > Posix: pathSeparator == '/' +-- > isPathSeparator pathSeparator +pathSeparator :: Char +pathSeparator = if isWindows then '\\' else '/' + +-- | The list of all possible separators. +-- +-- > Windows: pathSeparators == ['\\', '/'] +-- > Posix: pathSeparators == ['/'] +-- > pathSeparator `elem` pathSeparators +pathSeparators :: [Char] +pathSeparators = if isWindows then "\\/" else "/" + +-- | Rather than using @(== 'pathSeparator')@, use this. Test if something +-- is a path separator. +-- +-- > isPathSeparator a == (a `elem` pathSeparators) +isPathSeparator :: Char -> Bool +isPathSeparator '/' = True +isPathSeparator '\\' = isWindows +isPathSeparator _ = False + + +-- | The character that is used to separate the entries in the $PATH environment variable. +-- +-- > Windows: searchPathSeparator == ';' +-- > Posix: searchPathSeparator == ':' +searchPathSeparator :: Char +searchPathSeparator = if isWindows then ';' else ':' + +-- | Is the character a file separator? +-- +-- > isSearchPathSeparator a == (a == searchPathSeparator) +isSearchPathSeparator :: Char -> Bool +isSearchPathSeparator = (== searchPathSeparator) + + +-- | File extension character +-- +-- > extSeparator == '.' +extSeparator :: Char +extSeparator = '.' + +-- | Is the character an extension character? +-- +-- > isExtSeparator a == (a == extSeparator) +isExtSeparator :: Char -> Bool +isExtSeparator = (== extSeparator) + + +--------------------------------------------------------------------- +-- Path methods (environment $PATH) + +-- | Take a string, split it on the 'searchPathSeparator' character. +-- Blank items are ignored on Windows, and converted to @.@ on Posix. +-- On Windows path elements are stripped of quotes. +-- +-- Follows the recommendations in +-- +-- +-- > Posix: splitSearchPath "File1:File2:File3" == ["File1","File2","File3"] +-- > Posix: splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"] +-- > Windows: splitSearchPath "File1;File2;File3" == ["File1","File2","File3"] +-- > Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"] +-- > Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"] +splitSearchPath :: String -> [FilePath] +splitSearchPath = f + where + f xs = case break isSearchPathSeparator xs of + (pre, [] ) -> g pre + (pre, _:post) -> g pre ++ f post + + g "" = ["." | isPosix] + g ('\"':x@(_:_)) | isWindows && last x == '\"' = [init x] + g x = [x] + + +-- | Get a list of 'FilePath's in the $PATH variable. +getSearchPath :: IO [FilePath] +getSearchPath = fmap splitSearchPath (getEnv "PATH") + + +--------------------------------------------------------------------- +-- Extension methods + +-- | Split on the extension. 'addExtension' is the inverse. +-- +-- > splitExtension "/directory/path.ext" == ("/directory/path",".ext") +-- > uncurry (++) (splitExtension x) == x +-- > Valid x => uncurry addExtension (splitExtension x) == x +-- > splitExtension "file.txt" == ("file",".txt") +-- > splitExtension "file" == ("file","") +-- > splitExtension "file/file.txt" == ("file/file",".txt") +-- > splitExtension "file.txt/boris" == ("file.txt/boris","") +-- > splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") +-- > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred") +-- > splitExtension "file/path.txt/" == ("file/path.txt/","") +splitExtension :: FilePath -> (String, String) +splitExtension x = case nameDot of + "" -> (x,"") + _ -> (dir ++ init nameDot, extSeparator : ext) + where + (dir,file) = splitFileName_ x + (nameDot,ext) = breakEnd isExtSeparator file + +-- | Get the extension of a file, returns @\"\"@ for no extension, @.ext@ otherwise. +-- +-- > takeExtension "/directory/path.ext" == ".ext" +-- > takeExtension x == snd (splitExtension x) +-- > Valid x => takeExtension (addExtension x "ext") == ".ext" +-- > Valid x => takeExtension (replaceExtension x "ext") == ".ext" +takeExtension :: FilePath -> String +takeExtension = snd . splitExtension + +-- | Remove the current extension and add another, equivalent to 'replaceExtension'. +-- +-- > "/directory/path.txt" -<.> "ext" == "/directory/path.ext" +-- > "/directory/path.txt" -<.> ".ext" == "/directory/path.ext" +-- > "foo.o" -<.> "c" == "foo.c" +(-<.>) :: FilePath -> String -> FilePath +(-<.>) = replaceExtension + +-- | Set the extension of a file, overwriting one if already present, equivalent to '-<.>'. +-- +-- > replaceExtension "/directory/path.txt" "ext" == "/directory/path.ext" +-- > replaceExtension "/directory/path.txt" ".ext" == "/directory/path.ext" +-- > replaceExtension "file.txt" ".bob" == "file.bob" +-- > replaceExtension "file.txt" "bob" == "file.bob" +-- > replaceExtension "file" ".bob" == "file.bob" +-- > replaceExtension "file.txt" "" == "file" +-- > replaceExtension "file.fred.bob" "txt" == "file.fred.txt" +-- > replaceExtension x y == addExtension (dropExtension x) y +replaceExtension :: FilePath -> String -> FilePath +replaceExtension x y = dropExtension x <.> y + +-- | Add an extension, even if there is already one there, equivalent to 'addExtension'. +-- +-- > "/directory/path" <.> "ext" == "/directory/path.ext" +-- > "/directory/path" <.> ".ext" == "/directory/path.ext" +(<.>) :: FilePath -> String -> FilePath +(<.>) = addExtension + +-- | Remove last extension, and the \".\" preceding it. +-- +-- > dropExtension "/directory/path.ext" == "/directory/path" +-- > dropExtension x == fst (splitExtension x) +dropExtension :: FilePath -> FilePath +dropExtension = fst . splitExtension + +-- | Add an extension, even if there is already one there, equivalent to '<.>'. +-- +-- > addExtension "/directory/path" "ext" == "/directory/path.ext" +-- > addExtension "file.txt" "bib" == "file.txt.bib" +-- > addExtension "file." ".bib" == "file..bib" +-- > addExtension "file" ".bib" == "file.bib" +-- > addExtension "/" "x" == "/.x" +-- > addExtension x "" == x +-- > Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext" +-- > Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt" +addExtension :: FilePath -> String -> FilePath +addExtension file "" = file +addExtension file xs@(x:_) = joinDrive a res + where + res = if isExtSeparator x then b ++ xs + else b ++ [extSeparator] ++ xs + + (a,b) = splitDrive file + +-- | Does the given filename have an extension? +-- +-- > hasExtension "/directory/path.ext" == True +-- > hasExtension "/directory/path" == False +-- > null (takeExtension x) == not (hasExtension x) +hasExtension :: FilePath -> Bool +hasExtension = any isExtSeparator . takeFileName + + +-- | Does the given filename have the specified extension? +-- +-- > "png" `isExtensionOf` "/directory/file.png" == True +-- > ".png" `isExtensionOf` "/directory/file.png" == True +-- > ".tar.gz" `isExtensionOf` "bar/foo.tar.gz" == True +-- > "ar.gz" `isExtensionOf` "bar/foo.tar.gz" == False +-- > "png" `isExtensionOf` "/directory/file.png.jpg" == False +-- > "csv/table.csv" `isExtensionOf` "/data/csv/table.csv" == False +isExtensionOf :: String -> FilePath -> Bool +isExtensionOf ext@('.':_) = isSuffixOf ext . takeExtensions +isExtensionOf ext = isSuffixOf ('.':ext) . takeExtensions + +-- | Drop the given extension from a FilePath, and the @\".\"@ preceding it. +-- Returns 'Nothing' if the FilePath does not have the given extension, or +-- 'Just' and the part before the extension if it does. +-- +-- This function can be more predictable than 'dropExtensions', especially if the filename +-- might itself contain @.@ characters. +-- +-- > stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x" +-- > stripExtension "hi.o" "foo.x.hs.o" == Nothing +-- > dropExtension x == fromJust (stripExtension (takeExtension x) x) +-- > dropExtensions x == fromJust (stripExtension (takeExtensions x) x) +-- > stripExtension ".c.d" "a.b.c.d" == Just "a.b" +-- > stripExtension ".c.d" "a.b..c.d" == Just "a.b." +-- > stripExtension "baz" "foo.bar" == Nothing +-- > stripExtension "bar" "foobar" == Nothing +-- > stripExtension "" x == Just x +stripExtension :: String -> FilePath -> Maybe FilePath +stripExtension [] path = Just path +stripExtension ext@(x:_) path = stripSuffix dotExt path + where dotExt = if isExtSeparator x then ext else '.':ext + + +-- | Split on all extensions. +-- +-- > splitExtensions "/directory/path.ext" == ("/directory/path",".ext") +-- > splitExtensions "file.tar.gz" == ("file",".tar.gz") +-- > uncurry (++) (splitExtensions x) == x +-- > Valid x => uncurry addExtension (splitExtensions x) == x +-- > splitExtensions "file.tar.gz" == ("file",".tar.gz") +splitExtensions :: FilePath -> (FilePath, String) +splitExtensions x = (a ++ c, d) + where + (a,b) = splitFileName_ x + (c,d) = break isExtSeparator b + +-- | Drop all extensions. +-- +-- > dropExtensions "/directory/path.ext" == "/directory/path" +-- > dropExtensions "file.tar.gz" == "file" +-- > not $ hasExtension $ dropExtensions x +-- > not $ any isExtSeparator $ takeFileName $ dropExtensions x +dropExtensions :: FilePath -> FilePath +dropExtensions = fst . splitExtensions + +-- | Get all extensions. +-- +-- > takeExtensions "/directory/path.ext" == ".ext" +-- > takeExtensions "file.tar.gz" == ".tar.gz" +takeExtensions :: FilePath -> String +takeExtensions = snd . splitExtensions + + +-- | Replace all extensions of a file with a new extension. Note +-- that 'replaceExtension' and 'addExtension' both work for adding +-- multiple extensions, so only required when you need to drop +-- all extensions first. +-- +-- > replaceExtensions "file.fred.bob" "txt" == "file.txt" +-- > replaceExtensions "file.fred.bob" "tar.gz" == "file.tar.gz" +replaceExtensions :: FilePath -> String -> FilePath +replaceExtensions x y = dropExtensions x <.> y + + + +--------------------------------------------------------------------- +-- Drive methods + +-- | Is the given character a valid drive letter? +-- only a-z and A-Z are letters, not isAlpha which is more unicodey +isLetter :: Char -> Bool +isLetter x = isAsciiLower x || isAsciiUpper x + + +-- | Split a path into a drive and a path. +-- On Posix, \/ is a Drive. +-- +-- > uncurry (++) (splitDrive x) == x +-- > Windows: splitDrive "file" == ("","file") +-- > Windows: splitDrive "c:/file" == ("c:/","file") +-- > Windows: splitDrive "c:\\file" == ("c:\\","file") +-- > Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test") +-- > Windows: splitDrive "\\\\shared" == ("\\\\shared","") +-- > Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file") +-- > Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file") +-- > Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file") +-- > Windows: splitDrive "/d" == ("","/d") +-- > Posix: splitDrive "/test" == ("/","test") +-- > Posix: splitDrive "//test" == ("//","test") +-- > Posix: splitDrive "test/file" == ("","test/file") +-- > Posix: splitDrive "file" == ("","file") +splitDrive :: FilePath -> (FilePath, FilePath) +splitDrive x | isPosix = span (== '/') x +splitDrive x | Just y <- readDriveLetter x = y +splitDrive x | Just y <- readDriveUNC x = y +splitDrive x | Just y <- readDriveShare x = y +splitDrive x = ("",x) + +addSlash :: FilePath -> FilePath -> (FilePath, FilePath) +addSlash a xs = (a++c,d) + where (c,d) = span isPathSeparator xs + +-- See [1]. +-- "\\?\D:\" or "\\?\UNC\\" +readDriveUNC :: FilePath -> Maybe (FilePath, FilePath) +readDriveUNC (s1:s2:'?':s3:xs) | all isPathSeparator [s1,s2,s3] = + case map toUpper xs of + ('U':'N':'C':s4:_) | isPathSeparator s4 -> + let (a,b) = readDriveShareName (drop 4 xs) + in Just (s1:s2:'?':s3:take 4 xs ++ a, b) + _ -> case readDriveLetter xs of + -- Extended-length path. + Just (a,b) -> Just (s1:s2:'?':s3:a,b) + Nothing -> Nothing +readDriveUNC _ = Nothing + +{- c:\ -} +readDriveLetter :: String -> Maybe (FilePath, FilePath) +readDriveLetter (x:':':y:xs) | isLetter x && isPathSeparator y = Just $ addSlash [x,':'] (y:xs) +readDriveLetter (x:':':xs) | isLetter x = Just ([x,':'], xs) +readDriveLetter _ = Nothing + +{- \\sharename\ -} +readDriveShare :: String -> Maybe (FilePath, FilePath) +readDriveShare (s1:s2:xs) | isPathSeparator s1 && isPathSeparator s2 = + Just (s1:s2:a,b) + where (a,b) = readDriveShareName xs +readDriveShare _ = Nothing + +{- assume you have already seen \\ -} +{- share\bob -> "share\", "bob" -} +readDriveShareName :: String -> (FilePath, FilePath) +readDriveShareName name = addSlash a b + where (a,b) = break isPathSeparator name + + + +-- | Join a drive and the rest of the path. +-- +-- > Valid x => uncurry joinDrive (splitDrive x) == x +-- > Windows: joinDrive "C:" "foo" == "C:foo" +-- > Windows: joinDrive "C:\\" "bar" == "C:\\bar" +-- > Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo" +-- > Windows: joinDrive "/:" "foo" == "/:\\foo" +joinDrive :: FilePath -> FilePath -> FilePath +joinDrive = combineAlways + +-- | Get the drive from a filepath. +-- +-- > takeDrive x == fst (splitDrive x) +takeDrive :: FilePath -> FilePath +takeDrive = fst . splitDrive + +-- | Delete the drive, if it exists. +-- +-- > dropDrive x == snd (splitDrive x) +dropDrive :: FilePath -> FilePath +dropDrive = snd . splitDrive + +-- | Does a path have a drive. +-- +-- > not (hasDrive x) == null (takeDrive x) +-- > Posix: hasDrive "/foo" == True +-- > Windows: hasDrive "C:\\foo" == True +-- > Windows: hasDrive "C:foo" == True +-- > hasDrive "foo" == False +-- > hasDrive "" == False +hasDrive :: FilePath -> Bool +hasDrive = not . null . takeDrive + + +-- | Is an element a drive +-- +-- > Posix: isDrive "/" == True +-- > Posix: isDrive "/foo" == False +-- > Windows: isDrive "C:\\" == True +-- > Windows: isDrive "C:\\foo" == False +-- > isDrive "" == False +isDrive :: FilePath -> Bool +isDrive x = not (null x) && null (dropDrive x) + + +--------------------------------------------------------------------- +-- Operations on a filepath, as a list of directories + +-- | Split a filename into directory and file. '' is the inverse. +-- The first component will often end with a trailing slash. +-- +-- > splitFileName "/directory/file.ext" == ("/directory/","file.ext") +-- > Valid x => uncurry () (splitFileName x) == x || fst (splitFileName x) == "./" +-- > Valid x => isValid (fst (splitFileName x)) +-- > splitFileName "file/bob.txt" == ("file/", "bob.txt") +-- > splitFileName "file/" == ("file/", "") +-- > splitFileName "bob" == ("./", "bob") +-- > Posix: splitFileName "/" == ("/","") +-- > Windows: splitFileName "c:" == ("c:","") +splitFileName :: FilePath -> (String, String) +splitFileName x = (if null dir then "./" else dir, name) + where + (dir, name) = splitFileName_ x + +-- version of splitFileName where, if the FilePath has no directory +-- component, the returned directory is "" rather than "./". This +-- is used in cases where we are going to combine the returned +-- directory to make a valid FilePath, and having a "./" appear would +-- look strange and upset simple equality properties. See +-- e.g. replaceFileName. +splitFileName_ :: FilePath -> (String, String) +splitFileName_ x = (drv ++ dir, file) + where + (drv,pth) = splitDrive x + (dir,file) = breakEnd isPathSeparator pth + +-- | Set the filename. +-- +-- > replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext" +-- > Valid x => replaceFileName x (takeFileName x) == x +replaceFileName :: FilePath -> String -> FilePath +replaceFileName x y = a y where (a,_) = splitFileName_ x + +-- | Drop the filename. Unlike 'takeDirectory', this function will leave +-- a trailing path separator on the directory. +-- +-- > dropFileName "/directory/file.ext" == "/directory/" +-- > dropFileName x == fst (splitFileName x) +dropFileName :: FilePath -> FilePath +dropFileName = fst . splitFileName + + +-- | Get the file name. +-- +-- > takeFileName "/directory/file.ext" == "file.ext" +-- > takeFileName "test/" == "" +-- > takeFileName x `isSuffixOf` x +-- > takeFileName x == snd (splitFileName x) +-- > Valid x => takeFileName (replaceFileName x "fred") == "fred" +-- > Valid x => takeFileName (x "fred") == "fred" +-- > Valid x => isRelative (takeFileName x) +takeFileName :: FilePath -> FilePath +takeFileName = snd . splitFileName + +-- | Get the base name, without an extension or path. +-- +-- > takeBaseName "/directory/file.ext" == "file" +-- > takeBaseName "file/test.txt" == "test" +-- > takeBaseName "dave.ext" == "dave" +-- > takeBaseName "" == "" +-- > takeBaseName "test" == "test" +-- > takeBaseName (addTrailingPathSeparator x) == "" +-- > takeBaseName "file/file.tar.gz" == "file.tar" +takeBaseName :: FilePath -> String +takeBaseName = dropExtension . takeFileName + +-- | Set the base name. +-- +-- > replaceBaseName "/directory/other.ext" "file" == "/directory/file.ext" +-- > replaceBaseName "file/test.txt" "bob" == "file/bob.txt" +-- > replaceBaseName "fred" "bill" == "bill" +-- > replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar" +-- > Valid x => replaceBaseName x (takeBaseName x) == x +replaceBaseName :: FilePath -> String -> FilePath +replaceBaseName pth nam = combineAlways a (nam <.> ext) + where + (a,b) = splitFileName_ pth + ext = takeExtension b + +-- | Is an item either a directory or the last character a path separator? +-- +-- > hasTrailingPathSeparator "test" == False +-- > hasTrailingPathSeparator "test/" == True +hasTrailingPathSeparator :: FilePath -> Bool +hasTrailingPathSeparator "" = False +hasTrailingPathSeparator x = isPathSeparator (last x) + + +hasLeadingPathSeparator :: FilePath -> Bool +hasLeadingPathSeparator "" = False +hasLeadingPathSeparator x = isPathSeparator (head x) + + +-- | Add a trailing file path separator if one is not already present. +-- +-- > hasTrailingPathSeparator (addTrailingPathSeparator x) +-- > hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x +-- > Posix: addTrailingPathSeparator "test/rest" == "test/rest/" +addTrailingPathSeparator :: FilePath -> FilePath +addTrailingPathSeparator x = if hasTrailingPathSeparator x then x else x ++ [pathSeparator] + + +-- | Remove any trailing path separators +-- +-- > dropTrailingPathSeparator "file/test/" == "file/test" +-- > dropTrailingPathSeparator "/" == "/" +-- > Windows: dropTrailingPathSeparator "\\" == "\\" +-- > Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x +dropTrailingPathSeparator :: FilePath -> FilePath +dropTrailingPathSeparator x = + if hasTrailingPathSeparator x && not (isDrive x) + then let x' = dropWhileEnd isPathSeparator x + in if null x' then [last x] else x' + else x + + +-- | Get the directory name, move up one level. +-- +-- > takeDirectory "/directory/other.ext" == "/directory" +-- > takeDirectory x `isPrefixOf` x || takeDirectory x == "." +-- > takeDirectory "foo" == "." +-- > takeDirectory "/" == "/" +-- > takeDirectory "/foo" == "/" +-- > takeDirectory "/foo/bar/baz" == "/foo/bar" +-- > takeDirectory "/foo/bar/baz/" == "/foo/bar/baz" +-- > takeDirectory "foo/bar/baz" == "foo/bar" +-- > Windows: takeDirectory "foo\\bar" == "foo" +-- > Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar" +-- > Windows: takeDirectory "C:\\" == "C:\\" +takeDirectory :: FilePath -> FilePath +takeDirectory = dropTrailingPathSeparator . dropFileName + +-- | Set the directory, keeping the filename the same. +-- +-- > replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext" +-- > Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x +replaceDirectory :: FilePath -> String -> FilePath +replaceDirectory x dir = combineAlways dir (takeFileName x) + + +-- | An alias for ''. +combine :: FilePath -> FilePath -> FilePath +combine a b | hasLeadingPathSeparator b || hasDrive b = b + | otherwise = combineAlways a b + +-- | Combine two paths, assuming rhs is NOT absolute. +combineAlways :: FilePath -> FilePath -> FilePath +combineAlways a b | null a = b + | null b = a + | hasTrailingPathSeparator a = a ++ b + | otherwise = case a of + [a1,':'] | isWindows && isLetter a1 -> a ++ b + _ -> a ++ [pathSeparator] ++ b + + +-- | Combine two paths with a path separator. +-- If the second path starts with a path separator or a drive letter, then it returns the second. +-- The intention is that @readFile (dir '' file)@ will access the same file as +-- @setCurrentDirectory dir; readFile file at . +-- +-- > Posix: "/directory" "file.ext" == "/directory/file.ext" +-- > Windows: "/directory" "file.ext" == "/directory\\file.ext" +-- > "directory" "/file.ext" == "/file.ext" +-- > Valid x => (takeDirectory x takeFileName x) `equalFilePath` x +-- +-- Combined: +-- +-- > Posix: "/" "test" == "/test" +-- > Posix: "home" "bob" == "home/bob" +-- > Posix: "x:" "foo" == "x:/foo" +-- > Windows: "C:\\foo" "bar" == "C:\\foo\\bar" +-- > Windows: "home" "bob" == "home\\bob" +-- +-- Not combined: +-- +-- > Posix: "home" "/bob" == "/bob" +-- > Windows: "home" "C:\\bob" == "C:\\bob" +-- +-- Not combined (tricky): +-- +-- On Windows, if a filepath starts with a single slash, it is relative to the +-- root of the current drive. In [1], this is (confusingly) referred to as an +-- absolute path. +-- The current behavior of '' is to never combine these forms. +-- +-- > Windows: "home" "/bob" == "/bob" +-- > Windows: "home" "\\bob" == "\\bob" +-- > Windows: "C:\\home" "\\bob" == "\\bob" +-- +-- On Windows, from [1]: "If a file name begins with only a disk designator +-- but not the backslash after the colon, it is interpreted as a relative path +-- to the current directory on the drive with the specified letter." +-- The current behavior of '' is to never combine these forms. +-- +-- > Windows: "D:\\foo" "C:bar" == "C:bar" +-- > Windows: "C:\\foo" "C:bar" == "C:bar" +() :: FilePath -> FilePath -> FilePath +() = combine + + +-- | Split a path by the directory separator. +-- +-- > splitPath "/directory/file.ext" == ["/","directory/","file.ext"] +-- > concat (splitPath x) == x +-- > splitPath "test//item/" == ["test//","item/"] +-- > splitPath "test/item/file" == ["test/","item/","file"] +-- > splitPath "" == [] +-- > Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"] +-- > Posix: splitPath "/file/test" == ["/","file/","test"] +splitPath :: FilePath -> [FilePath] +splitPath x = [drive | drive /= ""] ++ f path + where + (drive,path) = splitDrive x + + f "" = [] + f y = (a++c) : f d + where + (a,b) = break isPathSeparator y + (c,d) = span isPathSeparator b + +-- | Just as 'splitPath', but don't add the trailing slashes to each element. +-- +-- > splitDirectories "/directory/file.ext" == ["/","directory","file.ext"] +-- > splitDirectories "test/file" == ["test","file"] +-- > splitDirectories "/test/file" == ["/","test","file"] +-- > Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"] +-- > Valid x => joinPath (splitDirectories x) `equalFilePath` x +-- > splitDirectories "" == [] +-- > Windows: splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"] +-- > splitDirectories "/test///file" == ["/","test","file"] +splitDirectories :: FilePath -> [FilePath] +splitDirectories = map dropTrailingPathSeparator . splitPath + + +-- | Join path elements back together. +-- +-- > joinPath a == foldr () "" a +-- > joinPath ["/","directory/","file.ext"] == "/directory/file.ext" +-- > Valid x => joinPath (splitPath x) == x +-- > joinPath [] == "" +-- > Posix: joinPath ["test","file","path"] == "test/file/path" +joinPath :: [FilePath] -> FilePath +-- Note that this definition on c:\\c:\\, join then split will give c:\\. +joinPath = foldr combine "" + + + + + + +--------------------------------------------------------------------- +-- File name manipulators + +-- | Equality of two 'FilePath's. +-- If you call @System.Directory.canonicalizePath@ +-- first this has a much better chance of working. +-- Note that this doesn't follow symlinks or DOSNAM~1s. +-- +-- Similar to 'normalise', this does not expand @".."@, because of symlinks. +-- +-- > x == y ==> equalFilePath x y +-- > normalise x == normalise y ==> equalFilePath x y +-- > equalFilePath "foo" "foo/" +-- > not (equalFilePath "/a/../c" "/c") +-- > not (equalFilePath "foo" "/foo") +-- > Posix: not (equalFilePath "foo" "FOO") +-- > Windows: equalFilePath "foo" "FOO" +-- > Windows: not (equalFilePath "C:" "C:/") +equalFilePath :: FilePath -> FilePath -> Bool +equalFilePath a b = f a == f b + where + f x | isWindows = dropTrailingPathSeparator $ map toLower $ normalise x + | otherwise = dropTrailingPathSeparator $ normalise x + + +-- | Contract a filename, based on a relative path. Note that the resulting path +-- will never introduce @..@ paths, as the presence of symlinks means @..\/b@ +-- may not reach @a\/b@ if it starts from @a\/c at . For a worked example see +-- . +-- +-- The corresponding @makeAbsolute@ function can be found in +-- @System.Directory at . +-- +-- > makeRelative "/directory" "/directory/file.ext" == "file.ext" +-- > Valid x => makeRelative (takeDirectory x) x `equalFilePath` takeFileName x +-- > makeRelative x x == "." +-- > Valid x y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y makeRelative y x) x +-- > Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob" +-- > Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob" +-- > Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob" +-- > Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob" +-- > Windows: makeRelative "/Home" "/home/bob" == "bob" +-- > Windows: makeRelative "/" "//" == "//" +-- > Posix: makeRelative "/Home" "/home/bob" == "/home/bob" +-- > Posix: makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar" +-- > Posix: makeRelative "/fred" "bob" == "bob" +-- > Posix: makeRelative "/file/test" "/file/test/fred" == "fred" +-- > Posix: makeRelative "/file/test" "/file/test/fred/" == "fred/" +-- > Posix: makeRelative "some/path" "some/path/a/b/c" == "a/b/c" +makeRelative :: FilePath -> FilePath -> FilePath +makeRelative root path + | equalFilePath root path = "." + | takeAbs root /= takeAbs path = path + | otherwise = f (dropAbs root) (dropAbs path) + where + f "" y = dropWhile isPathSeparator y + f x y = let (x1,x2) = g x + (y1,y2) = g y + in if equalFilePath x1 y1 then f x2 y2 else path + + g x = (dropWhile isPathSeparator a, dropWhile isPathSeparator b) + where (a,b) = break isPathSeparator $ dropWhile isPathSeparator x + + -- on windows, need to drop '/' which is kind of absolute, but not a drive + dropAbs x | hasLeadingPathSeparator x && not (hasDrive x) = tail x + dropAbs x = dropDrive x + + takeAbs x | hasLeadingPathSeparator x && not (hasDrive x) = [pathSeparator] + takeAbs x = map (\y -> if isPathSeparator y then pathSeparator else toLower y) $ takeDrive x + +-- | Normalise a file +-- +-- * \/\/ outside of the drive can be made blank +-- +-- * \/ -> 'pathSeparator' +-- +-- * .\/ -> \"\" +-- +-- Does not remove @".."@, because of symlinks. +-- +-- > Posix: normalise "/file/\\test////" == "/file/\\test/" +-- > Posix: normalise "/file/./test" == "/file/test" +-- > Posix: normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/" +-- > Posix: normalise "../bob/fred/" == "../bob/fred/" +-- > Posix: normalise "/a/../c" == "/a/../c" +-- > Posix: normalise "./bob/fred/" == "bob/fred/" +-- > Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\" +-- > Windows: normalise "c:\\" == "C:\\" +-- > Windows: normalise "C:.\\" == "C:" +-- > Windows: normalise "\\\\server\\test" == "\\\\server\\test" +-- > Windows: normalise "//server/test" == "\\\\server\\test" +-- > Windows: normalise "c:/file" == "C:\\file" +-- > Windows: normalise "/file" == "\\file" +-- > Windows: normalise "\\" == "\\" +-- > Windows: normalise "/./" == "\\" +-- > normalise "." == "." +-- > Posix: normalise "./" == "./" +-- > Posix: normalise "./." == "./" +-- > Posix: normalise "/./" == "/" +-- > Posix: normalise "/" == "/" +-- > Posix: normalise "bob/fred/." == "bob/fred/" +-- > Posix: normalise "//home" == "/home" +normalise :: FilePath -> FilePath +normalise path = result ++ [pathSeparator | addPathSeparator] + where + (drv,pth) = splitDrive path + result = joinDrive' (normaliseDrive drv) (f pth) + + joinDrive' "" "" = "." + joinDrive' d p = joinDrive d p + + addPathSeparator = isDirPath pth + && not (hasTrailingPathSeparator result) + && not (isRelativeDrive drv) + + isDirPath xs = hasTrailingPathSeparator xs + || not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs) + + f = joinPath . dropDots . propSep . splitDirectories + + propSep (x:xs) | all isPathSeparator x = [pathSeparator] : xs + | otherwise = x : xs + propSep [] = [] + + dropDots = filter ("." /=) + +normaliseDrive :: FilePath -> FilePath +normaliseDrive "" = "" +normaliseDrive _ | isPosix = [pathSeparator] +normaliseDrive drive = if isJust $ readDriveLetter x2 + then map toUpper x2 + else x2 + where + x2 = map repSlash drive + + repSlash x = if isPathSeparator x then pathSeparator else x + +-- Information for validity functions on Windows. See [1]. +isBadCharacter :: Char -> Bool +isBadCharacter x = x >= '\0' && x <= '\31' || x `elem` ":*?><|\"" + +badElements :: [FilePath] +badElements = + ["CON","PRN","AUX","NUL","CLOCK$" + ,"COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9" + ,"LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"] + + +-- | Is a FilePath valid, i.e. could you create a file like it? This function checks for invalid names, +-- and invalid characters, but does not check if length limits are exceeded, as these are typically +-- filesystem dependent. +-- +-- > isValid "" == False +-- > isValid "\0" == False +-- > Posix: isValid "/random_ path:*" == True +-- > Posix: isValid x == not (null x) +-- > Windows: isValid "c:\\test" == True +-- > Windows: isValid "c:\\test:of_test" == False +-- > Windows: isValid "test*" == False +-- > Windows: isValid "c:\\test\\nul" == False +-- > Windows: isValid "c:\\test\\prn.txt" == False +-- > Windows: isValid "c:\\nul\\file" == False +-- > Windows: isValid "\\\\" == False +-- > Windows: isValid "\\\\\\foo" == False +-- > Windows: isValid "\\\\?\\D:file" == False +-- > Windows: isValid "foo\tbar" == False +-- > Windows: isValid "nul .txt" == False +-- > Windows: isValid " nul.txt" == True +isValid :: FilePath -> Bool +isValid "" = False +isValid x | '\0' `elem` x = False +isValid _ | isPosix = True +isValid path = + not (any isBadCharacter x2) && + not (any f $ splitDirectories x2) && + not (isJust (readDriveShare x1) && all isPathSeparator x1) && + not (isJust (readDriveUNC x1) && not (hasTrailingPathSeparator x1)) + where + (x1,x2) = splitDrive path + f x = map toUpper (dropWhileEnd (== ' ') $ dropExtensions x) `elem` badElements + + +-- | Take a FilePath and make it valid; does not change already valid FilePaths. +-- +-- > isValid (makeValid x) +-- > isValid x ==> makeValid x == x +-- > makeValid "" == "_" +-- > makeValid "file\0name" == "file_name" +-- > Windows: makeValid "c:\\already\\/valid" == "c:\\already\\/valid" +-- > Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test" +-- > Windows: makeValid "test*" == "test_" +-- > Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_" +-- > Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt" +-- > Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt" +-- > Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file" +-- > Windows: makeValid "\\\\\\foo" == "\\\\drive" +-- > Windows: makeValid "\\\\?\\D:file" == "\\\\?\\D:\\file" +-- > Windows: makeValid "nul .txt" == "nul _.txt" +makeValid :: FilePath -> FilePath +makeValid "" = "_" +makeValid path + | isPosix = map (\x -> if x == '\0' then '_' else x) path + | isJust (readDriveShare drv) && all isPathSeparator drv = take 2 drv ++ "drive" + | isJust (readDriveUNC drv) && not (hasTrailingPathSeparator drv) = + makeValid (drv ++ [pathSeparator] ++ pth) + | otherwise = joinDrive drv $ validElements $ validChars pth + where + (drv,pth) = splitDrive path + + validChars = map f + f x = if isBadCharacter x then '_' else x + + validElements x = joinPath $ map g $ splitPath x + g x = h a ++ b + where (a,b) = break isPathSeparator x + h x = if map toUpper (dropWhileEnd (== ' ') a) `elem` badElements then a ++ "_" <.> b else x + where (a,b) = splitExtensions x + + +-- | Is a path relative, or is it fixed to the root? +-- +-- > Windows: isRelative "path\\test" == True +-- > Windows: isRelative "c:\\test" == False +-- > Windows: isRelative "c:test" == True +-- > Windows: isRelative "c:\\" == False +-- > Windows: isRelative "c:/" == False +-- > Windows: isRelative "c:" == True +-- > Windows: isRelative "\\\\foo" == False +-- > Windows: isRelative "\\\\?\\foo" == False +-- > Windows: isRelative "\\\\?\\UNC\\foo" == False +-- > Windows: isRelative "/foo" == True +-- > Windows: isRelative "\\foo" == True +-- > Posix: isRelative "test/path" == True +-- > Posix: isRelative "/test" == False +-- > Posix: isRelative "/" == False +-- +-- According to [1]: +-- +-- * "A UNC name of any format [is never relative]." +-- +-- * "You cannot use the "\\?\" prefix with a relative path." +isRelative :: FilePath -> Bool +isRelative x = null drive || isRelativeDrive drive + where drive = takeDrive x + + +{- c:foo -} +-- From [1]: "If a file name begins with only a disk designator but not the +-- backslash after the colon, it is interpreted as a relative path to the +-- current directory on the drive with the specified letter." +isRelativeDrive :: String -> Bool +isRelativeDrive x = + maybe False (not . hasTrailingPathSeparator . fst) (readDriveLetter x) + + +-- | @not . 'isRelative'@ +-- +-- > isAbsolute x == not (isRelative x) +isAbsolute :: FilePath -> Bool +isAbsolute = not . isRelative + + +----------------------------------------------------------------------------- +-- dropWhileEnd (>2) [1,2,3,4,1,2,3,4] == [1,2,3,4,1,2]) +-- Note that Data.List.dropWhileEnd is only available in base >= 4.5. +dropWhileEnd :: (a -> Bool) -> [a] -> [a] +dropWhileEnd p = reverse . dropWhile p . reverse + +-- takeWhileEnd (>2) [1,2,3,4,1,2,3,4] == [3,4]) +takeWhileEnd :: (a -> Bool) -> [a] -> [a] +takeWhileEnd p = reverse . takeWhile p . reverse + +-- spanEnd (>2) [1,2,3,4,1,2,3,4] = ([1,2,3,4,1,2], [3,4]) +spanEnd :: (a -> Bool) -> [a] -> ([a], [a]) +spanEnd p xs = (dropWhileEnd p xs, takeWhileEnd p xs) + +-- breakEnd (< 2) [1,2,3,4,1,2,3,4] == ([1,2,3,4,1],[2,3,4]) +breakEnd :: (a -> Bool) -> [a] -> ([a], [a]) +breakEnd p = spanEnd (not . p) + +-- | The stripSuffix function drops the given suffix from a list. It returns +-- Nothing if the list did not end with the suffix given, or Just the list +-- before the suffix, if it does. +stripSuffix :: Eq a => [a] -> [a] -> Maybe [a] +stripSuffix xs ys = fmap reverse $ stripPrefix (reverse xs) (reverse ys) ===================================== libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs ===================================== @@ -0,0 +1,1047 @@ +-- Vendored from filepath v1.4.2.2 + +{-# LANGUAGE PatternGuards #-} + +-- This template expects CPP definitions for: +-- MODULE_NAME = Posix | Windows +-- IS_WINDOWS = False | True + +-- | +-- Module : System.FilePath.MODULE_NAME +-- Copyright : (c) Neil Mitchell 2005-2014 +-- License : BSD3 +-- +-- Maintainer : ndmitchell at gmail.com +-- Stability : stable +-- Portability : portable +-- +-- A library for 'FilePath' manipulations, using MODULE_NAME style paths on +-- all platforms. Importing "System.FilePath" is usually better. +-- +-- Given the example 'FilePath': @\/directory\/file.ext@ +-- +-- We can use the following functions to extract pieces. +-- +-- * 'takeFileName' gives @\"file.ext\"@ +-- +-- * 'takeDirectory' gives @\"\/directory\"@ +-- +-- * 'takeExtension' gives @\".ext\"@ +-- +-- * 'dropExtension' gives @\"\/directory\/file\"@ +-- +-- * 'takeBaseName' gives @\"file\"@ +-- +-- And we could have built an equivalent path with the following expressions: +-- +-- * @\"\/directory\" '' \"file.ext\"@. +-- +-- * @\"\/directory\/file" '<.>' \"ext\"@. +-- +-- * @\"\/directory\/file.txt" '-<.>' \"ext\"@. +-- +-- Each function in this module is documented with several examples, +-- which are also used as tests. +-- +-- Here are a few examples of using the @filepath@ functions together: +-- +-- /Example 1:/ Find the possible locations of a Haskell module @Test@ imported from module @Main@: +-- +-- @['replaceFileName' path_to_main \"Test\" '<.>' ext | ext <- [\"hs\",\"lhs\"] ]@ +-- +-- /Example 2:/ Download a file from @url@ and save it to disk: +-- +-- @do let file = 'makeValid' url +-- System.Directory.createDirectoryIfMissing True ('takeDirectory' file)@ +-- +-- /Example 3:/ Compile a Haskell file, putting the @.hi@ file under @interface@: +-- +-- @'takeDirectory' file '' \"interface\" '' ('takeFileName' file '-<.>' \"hi\")@ +-- +-- References: +-- [1] (Microsoft MSDN) +module System.FilePath.Windows + ( + -- * Separator predicates + FilePath, + pathSeparator, pathSeparators, isPathSeparator, + searchPathSeparator, isSearchPathSeparator, + extSeparator, isExtSeparator, + + -- * @$PATH@ methods + splitSearchPath, getSearchPath, + + -- * Extension functions + splitExtension, + takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>), + splitExtensions, dropExtensions, takeExtensions, replaceExtensions, isExtensionOf, + stripExtension, + + -- * Filename\/directory functions + splitFileName, + takeFileName, replaceFileName, dropFileName, + takeBaseName, replaceBaseName, + takeDirectory, replaceDirectory, + combine, (), + splitPath, joinPath, splitDirectories, + + -- * Drive functions + splitDrive, joinDrive, + takeDrive, hasDrive, dropDrive, isDrive, + + -- * Trailing slash functions + hasTrailingPathSeparator, + addTrailingPathSeparator, + dropTrailingPathSeparator, + + -- * File name manipulations + normalise, equalFilePath, + makeRelative, + isRelative, isAbsolute, + isValid, makeValid + ) + where + +import Data.Char(toLower, toUpper, isAsciiLower, isAsciiUpper) +import Data.Maybe(isJust) +import Data.List(stripPrefix, isSuffixOf) + +import System.Environment(getEnv) + + +infixr 7 <.>, -<.> +infixr 5 + + + + + +--------------------------------------------------------------------- +-- Platform Abstraction Methods (private) + +-- | Is the operating system Unix or Linux like +isPosix :: Bool +isPosix = not isWindows + +-- | Is the operating system Windows like +isWindows :: Bool +isWindows = True + + +--------------------------------------------------------------------- +-- The basic functions + +-- | The character that separates directories. In the case where more than +-- one character is possible, 'pathSeparator' is the \'ideal\' one. +-- +-- > Windows: pathSeparator == '\\' +-- > Posix: pathSeparator == '/' +-- > isPathSeparator pathSeparator +pathSeparator :: Char +pathSeparator = if isWindows then '\\' else '/' + +-- | The list of all possible separators. +-- +-- > Windows: pathSeparators == ['\\', '/'] +-- > Posix: pathSeparators == ['/'] +-- > pathSeparator `elem` pathSeparators +pathSeparators :: [Char] +pathSeparators = if isWindows then "\\/" else "/" + +-- | Rather than using @(== 'pathSeparator')@, use this. Test if something +-- is a path separator. +-- +-- > isPathSeparator a == (a `elem` pathSeparators) +isPathSeparator :: Char -> Bool +isPathSeparator '/' = True +isPathSeparator '\\' = isWindows +isPathSeparator _ = False + + +-- | The character that is used to separate the entries in the $PATH environment variable. +-- +-- > Windows: searchPathSeparator == ';' +-- > Posix: searchPathSeparator == ':' +searchPathSeparator :: Char +searchPathSeparator = if isWindows then ';' else ':' + +-- | Is the character a file separator? +-- +-- > isSearchPathSeparator a == (a == searchPathSeparator) +isSearchPathSeparator :: Char -> Bool +isSearchPathSeparator = (== searchPathSeparator) + + +-- | File extension character +-- +-- > extSeparator == '.' +extSeparator :: Char +extSeparator = '.' + +-- | Is the character an extension character? +-- +-- > isExtSeparator a == (a == extSeparator) +isExtSeparator :: Char -> Bool +isExtSeparator = (== extSeparator) + + +--------------------------------------------------------------------- +-- Path methods (environment $PATH) + +-- | Take a string, split it on the 'searchPathSeparator' character. +-- Blank items are ignored on Windows, and converted to @.@ on Posix. +-- On Windows path elements are stripped of quotes. +-- +-- Follows the recommendations in +-- +-- +-- > Posix: splitSearchPath "File1:File2:File3" == ["File1","File2","File3"] +-- > Posix: splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"] +-- > Windows: splitSearchPath "File1;File2;File3" == ["File1","File2","File3"] +-- > Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"] +-- > Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"] +splitSearchPath :: String -> [FilePath] +splitSearchPath = f + where + f xs = case break isSearchPathSeparator xs of + (pre, [] ) -> g pre + (pre, _:post) -> g pre ++ f post + + g "" = ["." | isPosix] + g ('\"':x@(_:_)) | isWindows && last x == '\"' = [init x] + g x = [x] + + +-- | Get a list of 'FilePath's in the $PATH variable. +getSearchPath :: IO [FilePath] +getSearchPath = fmap splitSearchPath (getEnv "PATH") + + +--------------------------------------------------------------------- +-- Extension methods + +-- | Split on the extension. 'addExtension' is the inverse. +-- +-- > splitExtension "/directory/path.ext" == ("/directory/path",".ext") +-- > uncurry (++) (splitExtension x) == x +-- > Valid x => uncurry addExtension (splitExtension x) == x +-- > splitExtension "file.txt" == ("file",".txt") +-- > splitExtension "file" == ("file","") +-- > splitExtension "file/file.txt" == ("file/file",".txt") +-- > splitExtension "file.txt/boris" == ("file.txt/boris","") +-- > splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") +-- > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred") +-- > splitExtension "file/path.txt/" == ("file/path.txt/","") +splitExtension :: FilePath -> (String, String) +splitExtension x = case nameDot of + "" -> (x,"") + _ -> (dir ++ init nameDot, extSeparator : ext) + where + (dir,file) = splitFileName_ x + (nameDot,ext) = breakEnd isExtSeparator file + +-- | Get the extension of a file, returns @\"\"@ for no extension, @.ext@ otherwise. +-- +-- > takeExtension "/directory/path.ext" == ".ext" +-- > takeExtension x == snd (splitExtension x) +-- > Valid x => takeExtension (addExtension x "ext") == ".ext" +-- > Valid x => takeExtension (replaceExtension x "ext") == ".ext" +takeExtension :: FilePath -> String +takeExtension = snd . splitExtension + +-- | Remove the current extension and add another, equivalent to 'replaceExtension'. +-- +-- > "/directory/path.txt" -<.> "ext" == "/directory/path.ext" +-- > "/directory/path.txt" -<.> ".ext" == "/directory/path.ext" +-- > "foo.o" -<.> "c" == "foo.c" +(-<.>) :: FilePath -> String -> FilePath +(-<.>) = replaceExtension + +-- | Set the extension of a file, overwriting one if already present, equivalent to '-<.>'. +-- +-- > replaceExtension "/directory/path.txt" "ext" == "/directory/path.ext" +-- > replaceExtension "/directory/path.txt" ".ext" == "/directory/path.ext" +-- > replaceExtension "file.txt" ".bob" == "file.bob" +-- > replaceExtension "file.txt" "bob" == "file.bob" +-- > replaceExtension "file" ".bob" == "file.bob" +-- > replaceExtension "file.txt" "" == "file" +-- > replaceExtension "file.fred.bob" "txt" == "file.fred.txt" +-- > replaceExtension x y == addExtension (dropExtension x) y +replaceExtension :: FilePath -> String -> FilePath +replaceExtension x y = dropExtension x <.> y + +-- | Add an extension, even if there is already one there, equivalent to 'addExtension'. +-- +-- > "/directory/path" <.> "ext" == "/directory/path.ext" +-- > "/directory/path" <.> ".ext" == "/directory/path.ext" +(<.>) :: FilePath -> String -> FilePath +(<.>) = addExtension + +-- | Remove last extension, and the \".\" preceding it. +-- +-- > dropExtension "/directory/path.ext" == "/directory/path" +-- > dropExtension x == fst (splitExtension x) +dropExtension :: FilePath -> FilePath +dropExtension = fst . splitExtension + +-- | Add an extension, even if there is already one there, equivalent to '<.>'. +-- +-- > addExtension "/directory/path" "ext" == "/directory/path.ext" +-- > addExtension "file.txt" "bib" == "file.txt.bib" +-- > addExtension "file." ".bib" == "file..bib" +-- > addExtension "file" ".bib" == "file.bib" +-- > addExtension "/" "x" == "/.x" +-- > addExtension x "" == x +-- > Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext" +-- > Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt" +addExtension :: FilePath -> String -> FilePath +addExtension file "" = file +addExtension file xs@(x:_) = joinDrive a res + where + res = if isExtSeparator x then b ++ xs + else b ++ [extSeparator] ++ xs + + (a,b) = splitDrive file + +-- | Does the given filename have an extension? +-- +-- > hasExtension "/directory/path.ext" == True +-- > hasExtension "/directory/path" == False +-- > null (takeExtension x) == not (hasExtension x) +hasExtension :: FilePath -> Bool +hasExtension = any isExtSeparator . takeFileName + + +-- | Does the given filename have the specified extension? +-- +-- > "png" `isExtensionOf` "/directory/file.png" == True +-- > ".png" `isExtensionOf` "/directory/file.png" == True +-- > ".tar.gz" `isExtensionOf` "bar/foo.tar.gz" == True +-- > "ar.gz" `isExtensionOf` "bar/foo.tar.gz" == False +-- > "png" `isExtensionOf` "/directory/file.png.jpg" == False +-- > "csv/table.csv" `isExtensionOf` "/data/csv/table.csv" == False +isExtensionOf :: String -> FilePath -> Bool +isExtensionOf ext@('.':_) = isSuffixOf ext . takeExtensions +isExtensionOf ext = isSuffixOf ('.':ext) . takeExtensions + +-- | Drop the given extension from a FilePath, and the @\".\"@ preceding it. +-- Returns 'Nothing' if the FilePath does not have the given extension, or +-- 'Just' and the part before the extension if it does. +-- +-- This function can be more predictable than 'dropExtensions', especially if the filename +-- might itself contain @.@ characters. +-- +-- > stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x" +-- > stripExtension "hi.o" "foo.x.hs.o" == Nothing +-- > dropExtension x == fromJust (stripExtension (takeExtension x) x) +-- > dropExtensions x == fromJust (stripExtension (takeExtensions x) x) +-- > stripExtension ".c.d" "a.b.c.d" == Just "a.b" +-- > stripExtension ".c.d" "a.b..c.d" == Just "a.b." +-- > stripExtension "baz" "foo.bar" == Nothing +-- > stripExtension "bar" "foobar" == Nothing +-- > stripExtension "" x == Just x +stripExtension :: String -> FilePath -> Maybe FilePath +stripExtension [] path = Just path +stripExtension ext@(x:_) path = stripSuffix dotExt path + where dotExt = if isExtSeparator x then ext else '.':ext + + +-- | Split on all extensions. +-- +-- > splitExtensions "/directory/path.ext" == ("/directory/path",".ext") +-- > splitExtensions "file.tar.gz" == ("file",".tar.gz") +-- > uncurry (++) (splitExtensions x) == x +-- > Valid x => uncurry addExtension (splitExtensions x) == x +-- > splitExtensions "file.tar.gz" == ("file",".tar.gz") +splitExtensions :: FilePath -> (FilePath, String) +splitExtensions x = (a ++ c, d) + where + (a,b) = splitFileName_ x + (c,d) = break isExtSeparator b + +-- | Drop all extensions. +-- +-- > dropExtensions "/directory/path.ext" == "/directory/path" +-- > dropExtensions "file.tar.gz" == "file" +-- > not $ hasExtension $ dropExtensions x +-- > not $ any isExtSeparator $ takeFileName $ dropExtensions x +dropExtensions :: FilePath -> FilePath +dropExtensions = fst . splitExtensions + +-- | Get all extensions. +-- +-- > takeExtensions "/directory/path.ext" == ".ext" +-- > takeExtensions "file.tar.gz" == ".tar.gz" +takeExtensions :: FilePath -> String +takeExtensions = snd . splitExtensions + + +-- | Replace all extensions of a file with a new extension. Note +-- that 'replaceExtension' and 'addExtension' both work for adding +-- multiple extensions, so only required when you need to drop +-- all extensions first. +-- +-- > replaceExtensions "file.fred.bob" "txt" == "file.txt" +-- > replaceExtensions "file.fred.bob" "tar.gz" == "file.tar.gz" +replaceExtensions :: FilePath -> String -> FilePath +replaceExtensions x y = dropExtensions x <.> y + + + +--------------------------------------------------------------------- +-- Drive methods + +-- | Is the given character a valid drive letter? +-- only a-z and A-Z are letters, not isAlpha which is more unicodey +isLetter :: Char -> Bool +isLetter x = isAsciiLower x || isAsciiUpper x + + +-- | Split a path into a drive and a path. +-- On Posix, \/ is a Drive. +-- +-- > uncurry (++) (splitDrive x) == x +-- > Windows: splitDrive "file" == ("","file") +-- > Windows: splitDrive "c:/file" == ("c:/","file") +-- > Windows: splitDrive "c:\\file" == ("c:\\","file") +-- > Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test") +-- > Windows: splitDrive "\\\\shared" == ("\\\\shared","") +-- > Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file") +-- > Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file") +-- > Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file") +-- > Windows: splitDrive "/d" == ("","/d") +-- > Posix: splitDrive "/test" == ("/","test") +-- > Posix: splitDrive "//test" == ("//","test") +-- > Posix: splitDrive "test/file" == ("","test/file") +-- > Posix: splitDrive "file" == ("","file") +splitDrive :: FilePath -> (FilePath, FilePath) +splitDrive x | isPosix = span (== '/') x +splitDrive x | Just y <- readDriveLetter x = y +splitDrive x | Just y <- readDriveUNC x = y +splitDrive x | Just y <- readDriveShare x = y +splitDrive x = ("",x) + +addSlash :: FilePath -> FilePath -> (FilePath, FilePath) +addSlash a xs = (a++c,d) + where (c,d) = span isPathSeparator xs + +-- See [1]. +-- "\\?\D:\" or "\\?\UNC\\" +readDriveUNC :: FilePath -> Maybe (FilePath, FilePath) +readDriveUNC (s1:s2:'?':s3:xs) | all isPathSeparator [s1,s2,s3] = + case map toUpper xs of + ('U':'N':'C':s4:_) | isPathSeparator s4 -> + let (a,b) = readDriveShareName (drop 4 xs) + in Just (s1:s2:'?':s3:take 4 xs ++ a, b) + _ -> case readDriveLetter xs of + -- Extended-length path. + Just (a,b) -> Just (s1:s2:'?':s3:a,b) + Nothing -> Nothing +readDriveUNC _ = Nothing + +{- c:\ -} +readDriveLetter :: String -> Maybe (FilePath, FilePath) +readDriveLetter (x:':':y:xs) | isLetter x && isPathSeparator y = Just $ addSlash [x,':'] (y:xs) +readDriveLetter (x:':':xs) | isLetter x = Just ([x,':'], xs) +readDriveLetter _ = Nothing + +{- \\sharename\ -} +readDriveShare :: String -> Maybe (FilePath, FilePath) +readDriveShare (s1:s2:xs) | isPathSeparator s1 && isPathSeparator s2 = + Just (s1:s2:a,b) + where (a,b) = readDriveShareName xs +readDriveShare _ = Nothing + +{- assume you have already seen \\ -} +{- share\bob -> "share\", "bob" -} +readDriveShareName :: String -> (FilePath, FilePath) +readDriveShareName name = addSlash a b + where (a,b) = break isPathSeparator name + + + +-- | Join a drive and the rest of the path. +-- +-- > Valid x => uncurry joinDrive (splitDrive x) == x +-- > Windows: joinDrive "C:" "foo" == "C:foo" +-- > Windows: joinDrive "C:\\" "bar" == "C:\\bar" +-- > Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo" +-- > Windows: joinDrive "/:" "foo" == "/:\\foo" +joinDrive :: FilePath -> FilePath -> FilePath +joinDrive = combineAlways + +-- | Get the drive from a filepath. +-- +-- > takeDrive x == fst (splitDrive x) +takeDrive :: FilePath -> FilePath +takeDrive = fst . splitDrive + +-- | Delete the drive, if it exists. +-- +-- > dropDrive x == snd (splitDrive x) +dropDrive :: FilePath -> FilePath +dropDrive = snd . splitDrive + +-- | Does a path have a drive. +-- +-- > not (hasDrive x) == null (takeDrive x) +-- > Posix: hasDrive "/foo" == True +-- > Windows: hasDrive "C:\\foo" == True +-- > Windows: hasDrive "C:foo" == True +-- > hasDrive "foo" == False +-- > hasDrive "" == False +hasDrive :: FilePath -> Bool +hasDrive = not . null . takeDrive + + +-- | Is an element a drive +-- +-- > Posix: isDrive "/" == True +-- > Posix: isDrive "/foo" == False +-- > Windows: isDrive "C:\\" == True +-- > Windows: isDrive "C:\\foo" == False +-- > isDrive "" == False +isDrive :: FilePath -> Bool +isDrive x = not (null x) && null (dropDrive x) + + +--------------------------------------------------------------------- +-- Operations on a filepath, as a list of directories + +-- | Split a filename into directory and file. '' is the inverse. +-- The first component will often end with a trailing slash. +-- +-- > splitFileName "/directory/file.ext" == ("/directory/","file.ext") +-- > Valid x => uncurry () (splitFileName x) == x || fst (splitFileName x) == "./" +-- > Valid x => isValid (fst (splitFileName x)) +-- > splitFileName "file/bob.txt" == ("file/", "bob.txt") +-- > splitFileName "file/" == ("file/", "") +-- > splitFileName "bob" == ("./", "bob") +-- > Posix: splitFileName "/" == ("/","") +-- > Windows: splitFileName "c:" == ("c:","") +splitFileName :: FilePath -> (String, String) +splitFileName x = (if null dir then "./" else dir, name) + where + (dir, name) = splitFileName_ x + +-- version of splitFileName where, if the FilePath has no directory +-- component, the returned directory is "" rather than "./". This +-- is used in cases where we are going to combine the returned +-- directory to make a valid FilePath, and having a "./" appear would +-- look strange and upset simple equality properties. See +-- e.g. replaceFileName. +splitFileName_ :: FilePath -> (String, String) +splitFileName_ x = (drv ++ dir, file) + where + (drv,pth) = splitDrive x + (dir,file) = breakEnd isPathSeparator pth + +-- | Set the filename. +-- +-- > replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext" +-- > Valid x => replaceFileName x (takeFileName x) == x +replaceFileName :: FilePath -> String -> FilePath +replaceFileName x y = a y where (a,_) = splitFileName_ x + +-- | Drop the filename. Unlike 'takeDirectory', this function will leave +-- a trailing path separator on the directory. +-- +-- > dropFileName "/directory/file.ext" == "/directory/" +-- > dropFileName x == fst (splitFileName x) +dropFileName :: FilePath -> FilePath +dropFileName = fst . splitFileName + + +-- | Get the file name. +-- +-- > takeFileName "/directory/file.ext" == "file.ext" +-- > takeFileName "test/" == "" +-- > takeFileName x `isSuffixOf` x +-- > takeFileName x == snd (splitFileName x) +-- > Valid x => takeFileName (replaceFileName x "fred") == "fred" +-- > Valid x => takeFileName (x "fred") == "fred" +-- > Valid x => isRelative (takeFileName x) +takeFileName :: FilePath -> FilePath +takeFileName = snd . splitFileName + +-- | Get the base name, without an extension or path. +-- +-- > takeBaseName "/directory/file.ext" == "file" +-- > takeBaseName "file/test.txt" == "test" +-- > takeBaseName "dave.ext" == "dave" +-- > takeBaseName "" == "" +-- > takeBaseName "test" == "test" +-- > takeBaseName (addTrailingPathSeparator x) == "" +-- > takeBaseName "file/file.tar.gz" == "file.tar" +takeBaseName :: FilePath -> String +takeBaseName = dropExtension . takeFileName + +-- | Set the base name. +-- +-- > replaceBaseName "/directory/other.ext" "file" == "/directory/file.ext" +-- > replaceBaseName "file/test.txt" "bob" == "file/bob.txt" +-- > replaceBaseName "fred" "bill" == "bill" +-- > replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar" +-- > Valid x => replaceBaseName x (takeBaseName x) == x +replaceBaseName :: FilePath -> String -> FilePath +replaceBaseName pth nam = combineAlways a (nam <.> ext) + where + (a,b) = splitFileName_ pth + ext = takeExtension b + +-- | Is an item either a directory or the last character a path separator? +-- +-- > hasTrailingPathSeparator "test" == False +-- > hasTrailingPathSeparator "test/" == True +hasTrailingPathSeparator :: FilePath -> Bool +hasTrailingPathSeparator "" = False +hasTrailingPathSeparator x = isPathSeparator (last x) + + +hasLeadingPathSeparator :: FilePath -> Bool +hasLeadingPathSeparator "" = False +hasLeadingPathSeparator x = isPathSeparator (head x) + + +-- | Add a trailing file path separator if one is not already present. +-- +-- > hasTrailingPathSeparator (addTrailingPathSeparator x) +-- > hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x +-- > Posix: addTrailingPathSeparator "test/rest" == "test/rest/" +addTrailingPathSeparator :: FilePath -> FilePath +addTrailingPathSeparator x = if hasTrailingPathSeparator x then x else x ++ [pathSeparator] + + +-- | Remove any trailing path separators +-- +-- > dropTrailingPathSeparator "file/test/" == "file/test" +-- > dropTrailingPathSeparator "/" == "/" +-- > Windows: dropTrailingPathSeparator "\\" == "\\" +-- > Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x +dropTrailingPathSeparator :: FilePath -> FilePath +dropTrailingPathSeparator x = + if hasTrailingPathSeparator x && not (isDrive x) + then let x' = dropWhileEnd isPathSeparator x + in if null x' then [last x] else x' + else x + + +-- | Get the directory name, move up one level. +-- +-- > takeDirectory "/directory/other.ext" == "/directory" +-- > takeDirectory x `isPrefixOf` x || takeDirectory x == "." +-- > takeDirectory "foo" == "." +-- > takeDirectory "/" == "/" +-- > takeDirectory "/foo" == "/" +-- > takeDirectory "/foo/bar/baz" == "/foo/bar" +-- > takeDirectory "/foo/bar/baz/" == "/foo/bar/baz" +-- > takeDirectory "foo/bar/baz" == "foo/bar" +-- > Windows: takeDirectory "foo\\bar" == "foo" +-- > Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar" +-- > Windows: takeDirectory "C:\\" == "C:\\" +takeDirectory :: FilePath -> FilePath +takeDirectory = dropTrailingPathSeparator . dropFileName + +-- | Set the directory, keeping the filename the same. +-- +-- > replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext" +-- > Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x +replaceDirectory :: FilePath -> String -> FilePath +replaceDirectory x dir = combineAlways dir (takeFileName x) + + +-- | An alias for ''. +combine :: FilePath -> FilePath -> FilePath +combine a b | hasLeadingPathSeparator b || hasDrive b = b + | otherwise = combineAlways a b + +-- | Combine two paths, assuming rhs is NOT absolute. +combineAlways :: FilePath -> FilePath -> FilePath +combineAlways a b | null a = b + | null b = a + | hasTrailingPathSeparator a = a ++ b + | otherwise = case a of + [a1,':'] | isWindows && isLetter a1 -> a ++ b + _ -> a ++ [pathSeparator] ++ b + + +-- | Combine two paths with a path separator. +-- If the second path starts with a path separator or a drive letter, then it returns the second. +-- The intention is that @readFile (dir '' file)@ will access the same file as +-- @setCurrentDirectory dir; readFile file at . +-- +-- > Posix: "/directory" "file.ext" == "/directory/file.ext" +-- > Windows: "/directory" "file.ext" == "/directory\\file.ext" +-- > "directory" "/file.ext" == "/file.ext" +-- > Valid x => (takeDirectory x takeFileName x) `equalFilePath` x +-- +-- Combined: +-- +-- > Posix: "/" "test" == "/test" +-- > Posix: "home" "bob" == "home/bob" +-- > Posix: "x:" "foo" == "x:/foo" +-- > Windows: "C:\\foo" "bar" == "C:\\foo\\bar" +-- > Windows: "home" "bob" == "home\\bob" +-- +-- Not combined: +-- +-- > Posix: "home" "/bob" == "/bob" +-- > Windows: "home" "C:\\bob" == "C:\\bob" +-- +-- Not combined (tricky): +-- +-- On Windows, if a filepath starts with a single slash, it is relative to the +-- root of the current drive. In [1], this is (confusingly) referred to as an +-- absolute path. +-- The current behavior of '' is to never combine these forms. +-- +-- > Windows: "home" "/bob" == "/bob" +-- > Windows: "home" "\\bob" == "\\bob" +-- > Windows: "C:\\home" "\\bob" == "\\bob" +-- +-- On Windows, from [1]: "If a file name begins with only a disk designator +-- but not the backslash after the colon, it is interpreted as a relative path +-- to the current directory on the drive with the specified letter." +-- The current behavior of '' is to never combine these forms. +-- +-- > Windows: "D:\\foo" "C:bar" == "C:bar" +-- > Windows: "C:\\foo" "C:bar" == "C:bar" +() :: FilePath -> FilePath -> FilePath +() = combine + + +-- | Split a path by the directory separator. +-- +-- > splitPath "/directory/file.ext" == ["/","directory/","file.ext"] +-- > concat (splitPath x) == x +-- > splitPath "test//item/" == ["test//","item/"] +-- > splitPath "test/item/file" == ["test/","item/","file"] +-- > splitPath "" == [] +-- > Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"] +-- > Posix: splitPath "/file/test" == ["/","file/","test"] +splitPath :: FilePath -> [FilePath] +splitPath x = [drive | drive /= ""] ++ f path + where + (drive,path) = splitDrive x + + f "" = [] + f y = (a++c) : f d + where + (a,b) = break isPathSeparator y + (c,d) = span isPathSeparator b + +-- | Just as 'splitPath', but don't add the trailing slashes to each element. +-- +-- > splitDirectories "/directory/file.ext" == ["/","directory","file.ext"] +-- > splitDirectories "test/file" == ["test","file"] +-- > splitDirectories "/test/file" == ["/","test","file"] +-- > Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"] +-- > Valid x => joinPath (splitDirectories x) `equalFilePath` x +-- > splitDirectories "" == [] +-- > Windows: splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"] +-- > splitDirectories "/test///file" == ["/","test","file"] +splitDirectories :: FilePath -> [FilePath] +splitDirectories = map dropTrailingPathSeparator . splitPath + + +-- | Join path elements back together. +-- +-- > joinPath a == foldr () "" a +-- > joinPath ["/","directory/","file.ext"] == "/directory/file.ext" +-- > Valid x => joinPath (splitPath x) == x +-- > joinPath [] == "" +-- > Posix: joinPath ["test","file","path"] == "test/file/path" +joinPath :: [FilePath] -> FilePath +-- Note that this definition on c:\\c:\\, join then split will give c:\\. +joinPath = foldr combine "" + + + + + + +--------------------------------------------------------------------- +-- File name manipulators + +-- | Equality of two 'FilePath's. +-- If you call @System.Directory.canonicalizePath@ +-- first this has a much better chance of working. +-- Note that this doesn't follow symlinks or DOSNAM~1s. +-- +-- Similar to 'normalise', this does not expand @".."@, because of symlinks. +-- +-- > x == y ==> equalFilePath x y +-- > normalise x == normalise y ==> equalFilePath x y +-- > equalFilePath "foo" "foo/" +-- > not (equalFilePath "/a/../c" "/c") +-- > not (equalFilePath "foo" "/foo") +-- > Posix: not (equalFilePath "foo" "FOO") +-- > Windows: equalFilePath "foo" "FOO" +-- > Windows: not (equalFilePath "C:" "C:/") +equalFilePath :: FilePath -> FilePath -> Bool +equalFilePath a b = f a == f b + where + f x | isWindows = dropTrailingPathSeparator $ map toLower $ normalise x + | otherwise = dropTrailingPathSeparator $ normalise x + + +-- | Contract a filename, based on a relative path. Note that the resulting path +-- will never introduce @..@ paths, as the presence of symlinks means @..\/b@ +-- may not reach @a\/b@ if it starts from @a\/c at . For a worked example see +-- . +-- +-- The corresponding @makeAbsolute@ function can be found in +-- @System.Directory at . +-- +-- > makeRelative "/directory" "/directory/file.ext" == "file.ext" +-- > Valid x => makeRelative (takeDirectory x) x `equalFilePath` takeFileName x +-- > makeRelative x x == "." +-- > Valid x y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y makeRelative y x) x +-- > Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob" +-- > Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob" +-- > Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob" +-- > Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob" +-- > Windows: makeRelative "/Home" "/home/bob" == "bob" +-- > Windows: makeRelative "/" "//" == "//" +-- > Posix: makeRelative "/Home" "/home/bob" == "/home/bob" +-- > Posix: makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar" +-- > Posix: makeRelative "/fred" "bob" == "bob" +-- > Posix: makeRelative "/file/test" "/file/test/fred" == "fred" +-- > Posix: makeRelative "/file/test" "/file/test/fred/" == "fred/" +-- > Posix: makeRelative "some/path" "some/path/a/b/c" == "a/b/c" +makeRelative :: FilePath -> FilePath -> FilePath +makeRelative root path + | equalFilePath root path = "." + | takeAbs root /= takeAbs path = path + | otherwise = f (dropAbs root) (dropAbs path) + where + f "" y = dropWhile isPathSeparator y + f x y = let (x1,x2) = g x + (y1,y2) = g y + in if equalFilePath x1 y1 then f x2 y2 else path + + g x = (dropWhile isPathSeparator a, dropWhile isPathSeparator b) + where (a,b) = break isPathSeparator $ dropWhile isPathSeparator x + + -- on windows, need to drop '/' which is kind of absolute, but not a drive + dropAbs x | hasLeadingPathSeparator x && not (hasDrive x) = tail x + dropAbs x = dropDrive x + + takeAbs x | hasLeadingPathSeparator x && not (hasDrive x) = [pathSeparator] + takeAbs x = map (\y -> if isPathSeparator y then pathSeparator else toLower y) $ takeDrive x + +-- | Normalise a file +-- +-- * \/\/ outside of the drive can be made blank +-- +-- * \/ -> 'pathSeparator' +-- +-- * .\/ -> \"\" +-- +-- Does not remove @".."@, because of symlinks. +-- +-- > Posix: normalise "/file/\\test////" == "/file/\\test/" +-- > Posix: normalise "/file/./test" == "/file/test" +-- > Posix: normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/" +-- > Posix: normalise "../bob/fred/" == "../bob/fred/" +-- > Posix: normalise "/a/../c" == "/a/../c" +-- > Posix: normalise "./bob/fred/" == "bob/fred/" +-- > Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\" +-- > Windows: normalise "c:\\" == "C:\\" +-- > Windows: normalise "C:.\\" == "C:" +-- > Windows: normalise "\\\\server\\test" == "\\\\server\\test" +-- > Windows: normalise "//server/test" == "\\\\server\\test" +-- > Windows: normalise "c:/file" == "C:\\file" +-- > Windows: normalise "/file" == "\\file" +-- > Windows: normalise "\\" == "\\" +-- > Windows: normalise "/./" == "\\" +-- > normalise "." == "." +-- > Posix: normalise "./" == "./" +-- > Posix: normalise "./." == "./" +-- > Posix: normalise "/./" == "/" +-- > Posix: normalise "/" == "/" +-- > Posix: normalise "bob/fred/." == "bob/fred/" +-- > Posix: normalise "//home" == "/home" +normalise :: FilePath -> FilePath +normalise path = result ++ [pathSeparator | addPathSeparator] + where + (drv,pth) = splitDrive path + result = joinDrive' (normaliseDrive drv) (f pth) + + joinDrive' "" "" = "." + joinDrive' d p = joinDrive d p + + addPathSeparator = isDirPath pth + && not (hasTrailingPathSeparator result) + && not (isRelativeDrive drv) + + isDirPath xs = hasTrailingPathSeparator xs + || not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs) + + f = joinPath . dropDots . propSep . splitDirectories + + propSep (x:xs) | all isPathSeparator x = [pathSeparator] : xs + | otherwise = x : xs + propSep [] = [] + + dropDots = filter ("." /=) + +normaliseDrive :: FilePath -> FilePath +normaliseDrive "" = "" +normaliseDrive _ | isPosix = [pathSeparator] +normaliseDrive drive = if isJust $ readDriveLetter x2 + then map toUpper x2 + else x2 + where + x2 = map repSlash drive + + repSlash x = if isPathSeparator x then pathSeparator else x + +-- Information for validity functions on Windows. See [1]. +isBadCharacter :: Char -> Bool +isBadCharacter x = x >= '\0' && x <= '\31' || x `elem` ":*?><|\"" + +badElements :: [FilePath] +badElements = + ["CON","PRN","AUX","NUL","CLOCK$" + ,"COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9" + ,"LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"] + + +-- | Is a FilePath valid, i.e. could you create a file like it? This function checks for invalid names, +-- and invalid characters, but does not check if length limits are exceeded, as these are typically +-- filesystem dependent. +-- +-- > isValid "" == False +-- > isValid "\0" == False +-- > Posix: isValid "/random_ path:*" == True +-- > Posix: isValid x == not (null x) +-- > Windows: isValid "c:\\test" == True +-- > Windows: isValid "c:\\test:of_test" == False +-- > Windows: isValid "test*" == False +-- > Windows: isValid "c:\\test\\nul" == False +-- > Windows: isValid "c:\\test\\prn.txt" == False +-- > Windows: isValid "c:\\nul\\file" == False +-- > Windows: isValid "\\\\" == False +-- > Windows: isValid "\\\\\\foo" == False +-- > Windows: isValid "\\\\?\\D:file" == False +-- > Windows: isValid "foo\tbar" == False +-- > Windows: isValid "nul .txt" == False +-- > Windows: isValid " nul.txt" == True +isValid :: FilePath -> Bool +isValid "" = False +isValid x | '\0' `elem` x = False +isValid _ | isPosix = True +isValid path = + not (any isBadCharacter x2) && + not (any f $ splitDirectories x2) && + not (isJust (readDriveShare x1) && all isPathSeparator x1) && + not (isJust (readDriveUNC x1) && not (hasTrailingPathSeparator x1)) + where + (x1,x2) = splitDrive path + f x = map toUpper (dropWhileEnd (== ' ') $ dropExtensions x) `elem` badElements + + +-- | Take a FilePath and make it valid; does not change already valid FilePaths. +-- +-- > isValid (makeValid x) +-- > isValid x ==> makeValid x == x +-- > makeValid "" == "_" +-- > makeValid "file\0name" == "file_name" +-- > Windows: makeValid "c:\\already\\/valid" == "c:\\already\\/valid" +-- > Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test" +-- > Windows: makeValid "test*" == "test_" +-- > Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_" +-- > Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt" +-- > Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt" +-- > Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file" +-- > Windows: makeValid "\\\\\\foo" == "\\\\drive" +-- > Windows: makeValid "\\\\?\\D:file" == "\\\\?\\D:\\file" +-- > Windows: makeValid "nul .txt" == "nul _.txt" +makeValid :: FilePath -> FilePath +makeValid "" = "_" +makeValid path + | isPosix = map (\x -> if x == '\0' then '_' else x) path + | isJust (readDriveShare drv) && all isPathSeparator drv = take 2 drv ++ "drive" + | isJust (readDriveUNC drv) && not (hasTrailingPathSeparator drv) = + makeValid (drv ++ [pathSeparator] ++ pth) + | otherwise = joinDrive drv $ validElements $ validChars pth + where + (drv,pth) = splitDrive path + + validChars = map f + f x = if isBadCharacter x then '_' else x + + validElements x = joinPath $ map g $ splitPath x + g x = h a ++ b + where (a,b) = break isPathSeparator x + h x = if map toUpper (dropWhileEnd (== ' ') a) `elem` badElements then a ++ "_" <.> b else x + where (a,b) = splitExtensions x + + +-- | Is a path relative, or is it fixed to the root? +-- +-- > Windows: isRelative "path\\test" == True +-- > Windows: isRelative "c:\\test" == False +-- > Windows: isRelative "c:test" == True +-- > Windows: isRelative "c:\\" == False +-- > Windows: isRelative "c:/" == False +-- > Windows: isRelative "c:" == True +-- > Windows: isRelative "\\\\foo" == False +-- > Windows: isRelative "\\\\?\\foo" == False +-- > Windows: isRelative "\\\\?\\UNC\\foo" == False +-- > Windows: isRelative "/foo" == True +-- > Windows: isRelative "\\foo" == True +-- > Posix: isRelative "test/path" == True +-- > Posix: isRelative "/test" == False +-- > Posix: isRelative "/" == False +-- +-- According to [1]: +-- +-- * "A UNC name of any format [is never relative]." +-- +-- * "You cannot use the "\\?\" prefix with a relative path." +isRelative :: FilePath -> Bool +isRelative x = null drive || isRelativeDrive drive + where drive = takeDrive x + + +{- c:foo -} +-- From [1]: "If a file name begins with only a disk designator but not the +-- backslash after the colon, it is interpreted as a relative path to the +-- current directory on the drive with the specified letter." +isRelativeDrive :: String -> Bool +isRelativeDrive x = + maybe False (not . hasTrailingPathSeparator . fst) (readDriveLetter x) + + +-- | @not . 'isRelative'@ +-- +-- > isAbsolute x == not (isRelative x) +isAbsolute :: FilePath -> Bool +isAbsolute = not . isRelative + + +----------------------------------------------------------------------------- +-- dropWhileEnd (>2) [1,2,3,4,1,2,3,4] == [1,2,3,4,1,2]) +-- Note that Data.List.dropWhileEnd is only available in base >= 4.5. +dropWhileEnd :: (a -> Bool) -> [a] -> [a] +dropWhileEnd p = reverse . dropWhile p . reverse + +-- takeWhileEnd (>2) [1,2,3,4,1,2,3,4] == [3,4]) +takeWhileEnd :: (a -> Bool) -> [a] -> [a] +takeWhileEnd p = reverse . takeWhile p . reverse + +-- spanEnd (>2) [1,2,3,4,1,2,3,4] = ([1,2,3,4,1,2], [3,4]) +spanEnd :: (a -> Bool) -> [a] -> ([a], [a]) +spanEnd p xs = (dropWhileEnd p xs, takeWhileEnd p xs) + +-- breakEnd (< 2) [1,2,3,4,1,2,3,4] == ([1,2,3,4,1],[2,3,4]) +breakEnd :: (a -> Bool) -> [a] -> ([a], [a]) +breakEnd p = spanEnd (not . p) + +-- | The stripSuffix function drops the given suffix from a list. It returns +-- Nothing if the list did not end with the suffix given, or Just the list +-- before the suffix, if it does. +stripSuffix :: Eq a => [a] -> [a] -> Maybe [a] +stripSuffix xs ys = fmap reverse $ stripPrefix (reverse xs) (reverse ys) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/534b39ee5c6d0c4f9dc279adcf5a11423279efb8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/534b39ee5c6d0c4f9dc279adcf5a11423279efb8 You're receiving 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 Sep 14 21:49:31 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 17:49:31 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: hadrian: Use a stamp file to record when a package is built in a certain way Message-ID: <63224c6b341e8_3b59a6195e331411858ab@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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) - - - - - 04a62461 by M Farkas-Dyck at 2022-09-14T17:49:15-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - 9369391a by Krzysztof Gogolewski at 2022-09-14T17:49:16-04:00 Fix typos - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/LiberateCase.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/RoughMap.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Platform/Ways.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/BaseDir.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b169e4a272479607529e995653c8c55a013146dd...9369391a7fa859ea791aeae1356baf1f9a7f5419 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b169e4a272479607529e995653c8c55a013146dd...9369391a7fa859ea791aeae1356baf1f9a7f5419 You're receiving 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 Sep 15 02:39:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 22:39:49 -0400 Subject: [Git][ghc/ghc][master] Unbreak Hadrian with Cabal 3.8. Message-ID: <63229075ecb97_3b59a651838122119c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - 1 changed file: - hadrian/src/Hadrian/Haskell/Cabal/Parse.hs Changes: ===================================== hadrian/src/Hadrian/Haskell/Cabal/Parse.hs ===================================== @@ -23,7 +23,11 @@ import qualified Distribution.ModuleName as C import qualified Distribution.Package as C import qualified Distribution.PackageDescription as C import qualified Distribution.PackageDescription.Configuration as C +#if MIN_VERSION_Cabal(3,8,0) +import qualified Distribution.Simple.PackageDescription as C +#else import qualified Distribution.PackageDescription.Parsec as C +#endif import qualified Distribution.Simple.Compiler as C import qualified Distribution.Simple.Program.Db as C import qualified Distribution.Simple as C View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bdd61cd63dff07a78b1364988b5a140806f79e38 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bdd61cd63dff07a78b1364988b5a140806f79e38 You're receiving 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 Sep 15 02:40:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Sep 2022 22:40:22 -0400 Subject: [Git][ghc/ghc][master] Fix typos Message-ID: <63229096e7076_3b59a619d991941224939@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/LiberateCase.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/RoughMap.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Platform/Ways.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/Expr.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/BaseDir.hs - compiler/GHC/Tc/Errors.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df04d6ec6a543d8bf1b953cf27c26e63ec6aab25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df04d6ec6a543d8bf1b953cf27c26e63ec6aab25 You're receiving 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 Sep 15 08:17:26 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 15 Sep 2022 04:17:26 -0400 Subject: [Git][ghc/ghc][wip/andreask/infer_exprs] 129 commits: EPA: DotFieldOcc does not have exact print annotations Message-ID: <6322df96ae7f_3b59a6194ff95c127459e@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/infer_exprs at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - 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/ac810f994792c79acef386136aafe4c3a0f1e1a1...7cce70073f5017cf5514f92a900c76e47a4292a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac810f994792c79acef386136aafe4c3a0f1e1a1...7cce70073f5017cf5514f92a900c76e47a4292a5 You're receiving 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 Sep 15 08:29:30 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 15 Sep 2022 04:29:30 -0400 Subject: [Git][ghc/ghc][wip/andreask/tidy-94] Fix a nasty loop in Tidy Message-ID: <6322e26a6378f_3b59a620aecbec127979d@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/tidy-94 at Glasgow Haskell Compiler / GHC Commits: 2cf828e8 by Simon Peyton Jones at 2022-09-15T10:28:17+02: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] This is the 9.4 packport based on commit 4945953823620b223a0b51b2b1275a1de8f4a851 - - - - - 6 changed files: - compiler/GHC/Core/Tidy.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Types/Id/Info.hs - + testsuite/tests/simplCore/should_compile/T22112.hs - + testsuite/tests/simplCore/should_compile/T22112.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -10,7 +10,7 @@ The code for *top-level* bindings is in GHC.Iface.Tidy. {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Core.Tidy ( - tidyExpr, tidyRules, tidyUnfolding, tidyCbvInfoTop + tidyExpr, tidyRules, tidyCbvInfoTop, tidyBndrs ) where import GHC.Prelude @@ -345,33 +345,36 @@ tidyLetBndr rec_tidy_env env@(tidy_env, var_env) id `setUnfoldingInfo` new_unf old_unf = realUnfoldingInfo old_info - new_unf | isStableUnfolding old_unf = tidyUnfolding rec_tidy_env old_unf old_unf - | otherwise = trimUnfolding old_unf - -- See Note [Preserve evaluatedness] + new_unf = tidyNestedUnfolding rec_tidy_env old_unf in ((tidy_env', var_env'), id') } ------------ Unfolding -------------- -tidyUnfolding :: TidyEnv -> Unfolding -> Unfolding -> Unfolding -tidyUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) _ +tidyNestedUnfolding :: TidyEnv -> Unfolding -> Unfolding +tidyNestedUnfolding _ NoUnfolding = NoUnfolding +tidyNestedUnfolding _ BootUnfolding = BootUnfolding +tidyNestedUnfolding _ (OtherCon {}) = evaldUnfolding + +tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } where (tidy_env', bndrs') = tidyBndrs tidy_env bndrs -tidyUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) - unf_from_rhs +tidyNestedUnfolding tidy_env + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) - - | otherwise - = unf_from_rhs - where seqIt unf = seqUnfolding unf `seq` unf -tidyUnfolding _ unf _ = unf -- NoUnfolding or OtherCon + -- This seqIt avoids a space leak: otherwise the uf_is_value, + -- uf_is_conlike, ... fields may retain a reference to the + -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + + -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] + | is_value = evaldUnfolding + | otherwise = noUnfolding + + where + seqIt unf = seqUnfolding unf `seq` unf {- Note [Tidy IdInfo] ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -24,13 +24,12 @@ import GHC.Tc.Utils.Env import GHC.Core import GHC.Core.Unfold -import GHC.Core.Unfold.Make import GHC.Core.FVs import GHC.Core.Tidy import GHC.Core.Seq (seqBinds) -import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe ) +import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe, typeArity ) import GHC.Core.InstEnv -import GHC.Core.Type ( tidyTopType ) +import GHC.Core.Type ( tidyTopType, Type ) import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Core.Class @@ -74,6 +73,7 @@ import Data.Function import Data.List ( sortBy, mapAccumL ) import qualified Data.Set as S import GHC.Types.CostCentre +import GHC.Core.Opt.OccurAnal (occurAnalyseExpr) {- Constructing the TypeEnv, Instances, Rules from which the @@ -384,8 +384,7 @@ tidyProgram opts (ModGuts { mg_module = mod (unfold_env, tidy_occ_env) <- chooseExternalIds opts mod binds implicit_binds imp_rules let (trimmed_binds, trimmed_rules) = findExternalRules opts binds imp_rules unfold_env - let uf_opts = opt_unfolding_opts opts - (tidy_env, tidy_binds) <- tidyTopBinds uf_opts unfold_env boot_exports tidy_occ_env trimmed_binds + (tidy_env, tidy_binds) <- tidyTopBinds unfold_env boot_exports tidy_occ_env trimmed_binds -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. (spt_entries, mcstub, tidy_binds') <- case opt_static_ptr_opts opts of @@ -1146,60 +1145,49 @@ tidyTopName mod name_cache maybe_ref occ_env id -- -- * subst_env: A Var->Var mapping that substitutes the new Var for the old -tidyTopBinds :: UnfoldingOpts - -> UnfoldEnv +tidyTopBinds :: UnfoldEnv -> NameSet -> TidyOccEnv -> CoreProgram -> IO (TidyEnv, CoreProgram) -tidyTopBinds uf_opts unfold_env boot_exports init_occ_env binds +tidyTopBinds unfold_env boot_exports init_occ_env binds = do let result = tidy init_env binds seqBinds (snd result) `seq` return result -- This seqBinds avoids a spike in space usage (see #13564) where init_env = (init_occ_env, emptyVarEnv) - tidy = mapAccumL (tidyTopBind uf_opts unfold_env boot_exports) + tidy = mapAccumL (tidyTopBind unfold_env boot_exports) ------------------------ -tidyTopBind :: UnfoldingOpts - -> UnfoldEnv +tidyTopBind :: UnfoldEnv -> NameSet -> TidyEnv -> CoreBind -> (TidyEnv, CoreBind) -tidyTopBind uf_opts unfold_env boot_exports +tidyTopBind unfold_env boot_exports (occ_env,subst1) (NonRec bndr rhs) = (tidy_env2, NonRec bndr' rhs') where - Just (name',show_unfold) = lookupVarEnv unfold_env bndr - (bndr', rhs') = tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (bndr, rhs) + (bndr', rhs') = tidyTopPair unfold_env boot_exports tidy_env2 (bndr, rhs) subst2 = extendVarEnv subst1 bndr bndr' tidy_env2 = (occ_env, subst2) -tidyTopBind uf_opts unfold_env boot_exports (occ_env, subst1) (Rec prs) +tidyTopBind unfold_env boot_exports (occ_env, subst1) (Rec prs) = (tidy_env2, Rec prs') where - prs' = [ tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (id,rhs) - | (id,rhs) <- prs, - let (name',show_unfold) = - expectJust "tidyTopBind" $ lookupVarEnv unfold_env id - ] - - subst2 = extendVarEnvList subst1 (bndrs `zip` map fst prs') + prs' = map (tidyTopPair unfold_env boot_exports tidy_env2) prs + subst2 = extendVarEnvList subst1 (map fst prs `zip` map fst prs') tidy_env2 = (occ_env, subst2) - - bndrs = map fst prs + -- This is where we "tie the knot": tidy_env2 is fed into tidyTopPair ----------------------------------------------------------- -tidyTopPair :: UnfoldingOpts - -> Bool -- show unfolding +tidyTopPair :: UnfoldEnv -> NameSet -> TidyEnv -- The TidyEnv is used to tidy the IdInfo -- It is knot-tied: don't look at it! - -> Name -- New name -> (Id, CoreExpr) -- Binder and RHS before tidying -> (Id, CoreExpr) -- This function is the heart of Step 2 @@ -1208,18 +1196,19 @@ tidyTopPair :: UnfoldingOpts -- group, a variable late in the group might be mentioned -- in the IdInfo of one early in the group -tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) +tidyTopPair unfold_env boot_exports rhs_tidy_env (bndr, rhs) = -- pprTrace "tidyTop" (ppr name' <+> ppr details <+> ppr rhs) $ (bndr1, rhs1) where + Just (name',show_unfold) = lookupVarEnv unfold_env bndr !cbv_bndr = tidyCbvInfoTop boot_exports bndr rhs bndr1 = mkGlobalId details name' ty' idinfo' details = idDetails cbv_bndr -- Preserve the IdDetails ty' = tidyTopType (idType cbv_bndr) rhs1 = tidyExpr rhs_tidy_env rhs - idinfo' = tidyTopIdInfo uf_opts rhs_tidy_env name' rhs rhs1 (idInfo cbv_bndr) - show_unfold + idinfo' = tidyTopIdInfo rhs_tidy_env name' ty' + rhs rhs1 (idInfo cbv_bndr) show_unfold -- tidyTopIdInfo creates the final IdInfo for top-level -- binders. The delicate piece: @@ -1228,9 +1217,9 @@ tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) -- Indeed, CorePrep must eta expand where necessary to make -- the manifest arity equal to the claimed arity. -- -tidyTopIdInfo :: UnfoldingOpts -> TidyEnv -> Name -> CoreExpr -> CoreExpr +tidyTopIdInfo :: TidyEnv -> Name -> Type -> CoreExpr -> CoreExpr -> IdInfo -> Bool -> IdInfo -tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold +tidyTopIdInfo rhs_tidy_env name rhs_ty orig_rhs tidy_rhs idinfo show_unfold | not is_external -- For internal Ids (not externally visible) = vanillaIdInfo -- we only need enough info for code generation -- Arity and strictness info are enough; @@ -1281,13 +1270,17 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold --------- Unfolding ------------ unf_info = realUnfoldingInfo idinfo - unfold_info - | isCompulsoryUnfolding unf_info || show_unfold - = tidyUnfolding rhs_tidy_env unf_info unf_from_rhs - | otherwise - = minimal_unfold_info - minimal_unfold_info = trimUnfolding unf_info - unf_from_rhs = mkFinalUnfolding uf_opts InlineRhs final_sig tidy_rhs + !minimal_unfold_info = trimUnfolding unf_info + + !unfold_info | isCompulsoryUnfolding unf_info || show_unfold + = tidyTopUnfolding rhs_tidy_env tidy_rhs unf_info + | otherwise + = minimal_unfold_info + + -- NB: use `orig_rhs` not `tidy_rhs` in this call to mkFinalUnfolding + -- else you get a black hole (#22122). Reason: mkFinalUnfolding + -- looks at IdInfo, and that is knot-tied in tidyTopBind (the Rec case) + -- NB: do *not* expose the worker if show_unfold is off, -- because that means this thing is a loop breaker or -- marked NOINLINE or something like that @@ -1311,4 +1304,54 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold -- did was to let-bind a non-atomic argument and then float -- it to the top level. So it seems more robust just to -- fix it here. - arity = exprArity orig_rhs + arity = exprArity orig_rhs `min` (length $ typeArity rhs_ty) + + +------------ Unfolding -------------- +tidyTopUnfolding :: TidyEnv -> CoreExpr -> Unfolding -> Unfolding +tidyTopUnfolding _ _ NoUnfolding = NoUnfolding +tidyTopUnfolding _ _ BootUnfolding = BootUnfolding +tidyTopUnfolding _ _ (OtherCon {}) = evaldUnfolding + +tidyTopUnfolding tidy_env _ df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) + = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } + where + (tidy_env', bndrs') = tidyBndrs tidy_env bndrs + +tidyTopUnfolding tidy_env tidy_rhs + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) + = -- See Note [tidyTopUnfolding: avoiding black holes] + unf { uf_tmpl = tidy_unf_rhs } + where + tidy_unf_rhs | isStableSource src + = tidyExpr tidy_env unf_rhs -- Preserves OccInfo in unf_rhs + | otherwise + = occurAnalyseExpr tidy_rhs -- Do occ-anal + +{- Note [tidyTopUnfolding: avoiding black holes] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we are exposing all unfoldings we don't want to tidy the unfolding +twice -- we just want to use the tidied RHS. That tidied RHS itself +contains fully-tidied Ids -- it is knot-tied. So the uf_tmpl for the +unfolding contains stuff we can't look at. Now consider (#22112) + foo = foo +If we freshly compute the uf_is_value field for foo's unfolding, +we'll call `exprIsValue`, which will look at foo's unfolding! +Whether or not the RHS is a value depends on whether foo is a value... +black hole. + +In the Simplifier we deal with this by not giving `foo` an unfolding +in its own RHS. And we could do that here. But it's qite nice +to common everything up to a single Id for foo, used everywhere. + +And it's not too hard: simply leave the unfolding undisturbed, except +tidy the uf_tmpl field. Hence tidyTopUnfolding does + unf { uf_tmpl = tidy_unf_rhs } + +Don't mess with uf_is_value, or guidance; in particular don't recompute +them from tidy_unf_rhs. + +And (unlike tidyNestedUnfolding) don't deep-seq the new unfolding, +because that'll cause a black hole (I /think/ because occurAnalyseExpr +looks in IdInfo). +-} \ No newline at end of file ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -834,7 +834,7 @@ zapFragileUnfolding unf trimUnfolding :: Unfolding -> Unfolding -- Squash all unfolding info, preserving only evaluated-ness trimUnfolding unf | isEvaldUnfolding unf = evaldUnfolding - | otherwise = noUnfolding + | otherwise = noUnfolding zapTailCallInfo :: IdInfo -> Maybe IdInfo zapTailCallInfo info ===================================== testsuite/tests/simplCore/should_compile/T22112.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Rec where + +-- This one created a black hole in Tidy, +-- when creating the tidied unfolding for foo +foo :: () -> () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T22112.stderr ===================================== @@ -0,0 +1,14 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 2, types: 2, coercions: 0, joins: 0/0} + +Rec { +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foo [Occ=LoopBreaker] :: () -> () +[GblId, Str=b, Cpr=b] +foo = foo +end Rec } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -393,4 +393,5 @@ test('OpaqueNoStrictArgWW', normal, compile, ['-O -fworker-wrapper-cbv -ddump-si test('OpaqueNoWW', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T21144', normal, compile, ['-O']) +test('T22112', normal, compile, ['-O -dsuppress-uniques -dno-typeable-binds -ddump-simpl']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2cf828e829011f103ea946756a0c53322fa238dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2cf828e829011f103ea946756a0c53322fa238dd You're receiving 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 Sep 15 08:42:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Sep 2022 04:42:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Unbreak Hadrian with Cabal 3.8. Message-ID: <6322e583d7b4_3b59a6195e33141284281@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 5e0fb41f by M Farkas-Dyck at 2022-09-15T03:39:06+00: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. - - - - - 8d8f2991 by Matthew Pickering at 2022-09-15T04:42:28-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 - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/LiberateCase.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/RoughMap.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9369391a7fa859ea791aeae1356baf1f9a7f5419...8d8f299106344aca32a0d97aac4a02296617c3a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9369391a7fa859ea791aeae1356baf1f9a7f5419...8d8f299106344aca32a0d97aac4a02296617c3a4 You're receiving 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 Sep 15 11:13:51 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 15 Sep 2022 07:13:51 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] Add job for testing ABI stability across builds Message-ID: <632308ef5c40b_3b59a619d9919413382ca@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: ade4a6aa by Matthew Pickering at 2022-09-15T12:13:42+01:00 Add job for testing ABI stability across builds The idea is that both the bindists should product libraries with the same ABI. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/ci.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -396,6 +396,37 @@ test-cabal-reinstall-x86_64-linux-deb10: rules: - if: $NIGHTLY +######################################## +# Testing ABI is invariant across builds +######################################## + +abi-test: + stage: full-build + needs: + - job: x86_64-linux-fedora33-release-hackage + - job: x86_64-linux-fedora33-release + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + dependencies: null + variables: + # Don't clone the git repo.. + GIT_STRATEGY: none + # Don't attempt to boot a source tarball + NO_BOOT: "1" + before_script: + - mkdir -p normal + - mkdir -p hackage + - tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C normal/ + - tar -xf ghc-x86_64-linux-fedora33-release-hackage_docs.tar.xz -C hackage/ + script: + - .gitlab/ci.sh abi_of "normal/ghc-*" > abi-normal + - .gitlab/ci.sh abi_of "hackage/ghc-*" > abi-hackage + - diff abi-normal abi-hackage + rules: + - if: $NIGHTLY + - if: '$RELEASE_JOB == "yes"' + ############################################################ # Packaging ############################################################ ===================================== .gitlab/ci.sh ===================================== @@ -720,6 +720,13 @@ function lint_author(){ done } +function abi_of(){ + DIR=$(realpath $1) + HC_PKG="$DIR/bin/ghc-pkg" + PKGS=$("$HC_PKG" list --global --simple | sort) + for p in $PKGS; do echo "$p: $("$HC_PKG" field $p abi --simple-output)"; done +} + setup_locale @@ -817,6 +824,7 @@ case $1 in perf_test) run_perf_test ;; cabal_test) cabal_test ;; lint_author) shift; lint_author "$@" ;; + abi_of) shift; abi_of "$@" ;; clean) clean ;; save_cache) save_cache ;; shell) shift; shell "$@" ;; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ade4a6aaa0b2d64c809bb6cb6ccf3706b848ebc6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ade4a6aaa0b2d64c809bb6cb6ccf3706b848ebc6 You're receiving 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 Sep 15 11:21:18 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 15 Sep 2022 07:21:18 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] Add job for testing ABI stability across builds Message-ID: <63230aaee92ab_3b59a65152c134442d@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 34df9071 by Matthew Pickering at 2022-09-15T12:21:07+01:00 Add job for testing ABI stability across builds The idea is that both the bindists should product libraries with the same ABI. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/ci.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -396,6 +396,37 @@ test-cabal-reinstall-x86_64-linux-deb10: rules: - if: $NIGHTLY +######################################## +# Testing ABI is invariant across builds +######################################## + +abi-test: + stage: full-build + needs: + - job: nightly-x86_64-linux-fedora33-release-hackage + - job: nightly-x86_64-linux-fedora33-release + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + dependencies: null + variables: + # Don't clone the git repo.. + GIT_STRATEGY: none + # Don't attempt to boot a source tarball + NO_BOOT: "1" + before_script: + - mkdir -p normal + - mkdir -p hackage + - tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C normal/ + - tar -xf ghc-x86_64-linux-fedora33-release-hackage_docs.tar.xz -C hackage/ + script: + - .gitlab/ci.sh abi_of "normal/ghc-*" > abi-normal + - .gitlab/ci.sh abi_of "hackage/ghc-*" > abi-hackage + - diff abi-normal abi-hackage + rules: + - if: $NIGHTLY + - if: '$RELEASE_JOB == "yes"' + ############################################################ # Packaging ############################################################ ===================================== .gitlab/ci.sh ===================================== @@ -720,6 +720,13 @@ function lint_author(){ done } +function abi_of(){ + DIR=$(realpath $1) + HC_PKG="$DIR/bin/ghc-pkg" + PKGS=$("$HC_PKG" list --global --simple | sort) + for p in $PKGS; do echo "$p: $("$HC_PKG" field $p abi --simple-output)"; done +} + setup_locale @@ -817,6 +824,7 @@ case $1 in perf_test) run_perf_test ;; cabal_test) cabal_test ;; lint_author) shift; lint_author "$@" ;; + abi_of) shift; abi_of "$@" ;; clean) clean ;; save_cache) save_cache ;; shell) shift; shell "$@" ;; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34df9071afd35983414c60bd4a1dba47c31ded9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34df9071afd35983414c60bd4a1dba47c31ded9a You're receiving 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 Sep 15 11:43:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Sep 2022 07:43:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <63230fd1b49_3b59a6d8c86081349523@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3828ed3c by Matthew Pickering at 2022-09-15T07:42:49-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 - - - - - c742e8e7 by Bodigrim at 2022-09-15T07:42:53-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 7 changed files: - compiler/GHC/Rename/Bind.hs - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d8f299106344aca32a0d97aac4a02296617c3a4...c742e8e7b2c13fec8ad15485c7ff44457f0fc7d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8d8f299106344aca32a0d97aac4a02296617c3a4...c742e8e7b2c13fec8ad15485c7ff44457f0fc7d6 You're receiving 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 Sep 15 12:10:48 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 15 Sep 2022 08:10:48 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.2-hasura Message-ID: <63231648a70d6_3b59a6195e331413571ec@gitlab.mail> Zubin pushed new branch wip/ghc-9.2-hasura at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.2-hasura You're receiving 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 Sep 15 12:58:37 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 15 Sep 2022 08:58:37 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.2-hasura] Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <6323217d307ed_3b59a6195e331413665e1@gitlab.mail> Zubin pushed to branch wip/ghc-9.2-hasura at Glasgow Haskell Compiler / GHC Commits: aee4c91a by Simon Peyton Jones at 2022-09-15T18:28:18+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 - - - - - 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/T21755.hs - + testsuite/tests/arityanal/should_compile/T21755.stderr - testsuite/tests/arityanal/should_compile/all.T - + testsuite/tests/concurrent/T2317/T21694a.hs - + testsuite/tests/concurrent/T2317/T21694a.stderr - + testsuite/tests/simplCore/should_compile/T21694.hs - + testsuite/tests/simplCore/should_compile/T21694b.hs - + testsuite/tests/simplCore/should_compile/T21694b.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -695,6 +695,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 ===================================== @@ -18,7 +18,7 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), mkBotArityType, mkTopArityType, expandableArityType + , ArityType(..), mkBotArityType, mkManifestArityType, expandableArityType , arityTypeArity, maxWithArity, idArityType -- ** Join points @@ -532,7 +532,8 @@ Then f :: \??.T -- 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]. @@ -579,11 +580,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 @@ -623,7 +629,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 @@ -763,6 +769,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) @@ -772,16 +779,32 @@ 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 (AT [] div1) at2 - | isDeadEndDiv div1 = at2 -- Note [ABot branches: max arity wins] - | otherwise = takeWhileOneShot at2 -- See Note [Combining case branches] -andArityType at1 (AT [] div2) - | isDeadEndDiv div2 = at1 -- Note [ABot branches: max arity wins] - | otherwise = takeWhileOneShot at1 -- 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 (map bogus_add_work lams2) topDiv -- We know div1 = topDiv + -- See Note [Combining case branches: andWithTail] + where + bogus_add_work = id -- TODO bogus + {- Note [ABot branches: max arity wins] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -792,9 +815,48 @@ 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] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider +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 @@ -872,22 +934,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 @@ -895,7 +956,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! @@ -914,32 +979,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 @@ -978,8 +1028,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 @@ -987,7 +1040,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] @@ -999,12 +1055,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 + = ASSERT2( (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) @@ -1041,50 +1098,104 @@ 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) + alts_type = foldr1 (andArityType env) (map arity_type_alt alts) + +arityType env (Let (NonRec b r) e) + = -- See Note [arityType for let-bindings] + floatIn cheap_rhs (arityType env' e) where - env' = extendJoinEnv env [j] + 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 [Eta-expansion and join points] - foldr (andArityType . do_one) (arityType env' body) pairs + = -- See Note [arityType for join bindings] + foldr (andArityType env . do_one) (arityType rec_env body) pairs where - env' = extendJoinEnv env (map fst pairs) + 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 env' $ snd $ collectNBinders arity rhs + = arityType rec_env $ snd $ collectNBinders arity rhs | otherwise = pprPanic "arityType:joinrec" (ppr pairs) -arityType env (Let (NonRec b r) e) - = floatIn cheap_rhs (arityType env' e) - where - cheap_rhs = myExprIsCheap env r (Just (idType b)) - env' = extendSigEnv env b (arityType env r) - 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 @@ -1097,42 +1208,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 ===================================== @@ -2064,19 +2064,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') } @@ -2183,6 +2196,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 ===================================== @@ -1697,9 +1697,7 @@ tryEtaExpandRhs :: SimplMode -> OutId -> OutExpr tryEtaExpandRhs mode 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/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 ===================================== @@ -21,3 +21,4 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn 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/concurrent/T2317/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/concurrent/T2317/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/simplCore/should_compile/T21694.hs ===================================== @@ -0,0 +1,91 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -Wall #-} +module Bug (go_fast_end) where + +import Control.Monad.ST (ST) +import qualified Data.ByteString.Internal as BS +import qualified Data.ByteString.Unsafe as BS +import Data.ByteString (ByteString) +import Foreign.ForeignPtr (withForeignPtr) +import Foreign.Ptr (plusPtr) +import GHC.Exts ( Int(..), Int#, Ptr(..), Word(..) + , (<#), (>#), indexWord64OffAddr#, isTrue#, orI# + ) +import GHC.Word (Word8(..), Word64(..)) +import System.IO.Unsafe (unsafeDupablePerformIO) + +#if MIN_VERSION_ghc_prim(0,8,0) +import GHC.Exts (word8ToWord#) +#endif + +#if __GLASGOW_HASKELL__ >= 904 +import GHC.Exts (byteSwap64#, int64ToInt#, word64ToInt64#, ltWord64#, wordToWord64#) +#else +import GHC.Exts (byteSwap#, ltWord#, word2Int#) +#endif + +go_fast_end :: ByteString -> DecodeAction s a -> ST s (SlowPath s a) +go_fast_end !bs (ConsumeInt32 k) = + case tryConsumeInt (BS.unsafeHead bs) bs of + DecodeFailure -> return $! SlowFail bs "expected int32" + DecodedToken sz (I# n#) -> + case (n# ># 0x7fffffff#) `orI#` (n# <# -0x80000000#) of + 0# -> k n# >>= go_fast_end (BS.unsafeDrop sz bs) + _ -> return $! SlowFail bs "expected int32" + +data SlowPath s a = SlowFail {-# UNPACK #-} !ByteString String + +data DecodeAction s a = ConsumeInt32 (Int# -> ST s (DecodeAction s a)) + +data DecodedToken a = DecodedToken !Int !a | DecodeFailure + +tryConsumeInt :: Word8 -> ByteString -> DecodedToken Int +tryConsumeInt hdr !bs = case word8ToWord hdr of + 0x17 -> DecodedToken 1 23 + 0x1b -> case word64ToInt (eatTailWord64 bs) of + Just n -> DecodedToken 9 n + Nothing -> DecodeFailure + _ -> DecodeFailure +{-# INLINE tryConsumeInt #-} + +eatTailWord64 :: ByteString -> Word64 +eatTailWord64 xs = withBsPtr grabWord64 (BS.unsafeTail xs) +{-# INLINE eatTailWord64 #-} + +word64ToInt :: Word64 -> Maybe Int +#if __GLASGOW_HASKELL__ >= 904 +word64ToInt (W64# w#) = + case isTrue# (w# `ltWord64#` wordToWord64# 0x80000000##) of + True -> Just (I# (int64ToInt# (word64ToInt64# w#))) + False -> Nothing +#else +word64ToInt (W64# w#) = + case isTrue# (w# `ltWord#` 0x8000000000000000##) of + True -> Just (I# (word2Int# w#)) + False -> Nothing +#endif +{-# INLINE word64ToInt #-} + +withBsPtr :: (Ptr b -> a) -> ByteString -> a +withBsPtr f (BS.PS x off _) = + unsafeDupablePerformIO $ withForeignPtr x $ + \(Ptr addr#) -> return $! (f (Ptr addr# `plusPtr` off)) +{-# INLINE withBsPtr #-} + +grabWord64 :: Ptr () -> Word64 +#if __GLASGOW_HASKELL__ >= 904 +grabWord64 (Ptr ip#) = W64# (byteSwap64# (indexWord64OffAddr# ip# 0#)) +#else +grabWord64 (Ptr ip#) = W64# (byteSwap# (indexWord64OffAddr# ip# 0#)) +#endif +{-# INLINE grabWord64 #-} + +word8ToWord :: Word8 -> Word +#if MIN_VERSION_ghc_prim(0,8,0) +word8ToWord (W8# w#) = W# (word8ToWord# w#) +#else +word8ToWord (W8# w#) = W# w# +#endif +{-# INLINE word8ToWord #-} ===================================== 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 + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -291,6 +291,7 @@ test('T16348', normal, compile, ['-O']) test('T16918', normal, compile, ['-O']) test('T16918a', normal, compile, ['-O']) test('T16978a', normal, compile, ['-O']) +test('T21694', [ req_profiling ] , compile, ['-O -prof -fprof-auto -funfolding-use-threshold=50 ']) test('T16978b', normal, compile, ['-O']) test('T16979a', normal, compile, ['-O']) test('T16979b', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aee4c91a15a0595f22be1f0bd496fe86e4296475 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aee4c91a15a0595f22be1f0bd496fe86e4296475 You're receiving 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 Sep 15 12:59:24 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 15 Sep 2022 08:59:24 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.2-hasura] RELEASE=NO Message-ID: <632321ace1894_3b59a6194ff95c136678@gitlab.mail> Zubin pushed to branch wip/ghc-9.2-hasura at Glasgow Haskell Compiler / GHC Commits: 1ebd4ddf by Zubin Duggal at 2022-09-15T18:29:13+05:30 RELEASE=NO - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -20,7 +20,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.4], [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 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ebd4ddf6e0a7435232fbfbc4797e0fc60762e17 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1ebd4ddf6e0a7435232fbfbc4797e0fc60762e17 You're receiving 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 Sep 15 13:28:33 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 15 Sep 2022 09:28:33 -0400 Subject: [Git][ghc/ghc][wip/andreask/ghci-tag-nullary] Fix GHCis interaction with tag inference. Message-ID: <632328814d76f_3b59a6d8c860813768db@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ghci-tag-nullary at Glasgow Haskell Compiler / GHC Commits: f3ccd63d by Andreas Klebinger at 2022-09-15T15:05:56+02: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 ------------------------- - - - - - 19 changed files: - compiler/GHC/Driver/GenerateCgIPEStub.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Stg/InferTags.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Stg/InferTags/TagSig.hs - compiler/GHC/Stg/Pipeline.hs - compiler/GHC/StgToByteCode.hs - compiler/GHC/StgToCmm/Types.hs - compiler/GHC/Types/Name/Set.hs - testsuite/tests/ghci.debugger/scripts/T12458.stdout - testsuite/tests/ghci.debugger/scripts/print018.stdout - testsuite/tests/simplStg/should_run/Makefile - + testsuite/tests/simplStg/should_run/T22042.hs - + testsuite/tests/simplStg/should_run/T22042.stdout - + testsuite/tests/simplStg/should_run/T22042a.hs - testsuite/tests/simplStg/should_run/all.T Changes: ===================================== compiler/GHC/Driver/GenerateCgIPEStub.hs ===================================== @@ -26,11 +26,9 @@ import GHC.Runtime.Heap.Layout (isStackRep) import GHC.Settings (Platform, platformUnregisterised) import GHC.StgToCmm.Monad (getCmm, initC, runC, initFCodeState) import GHC.StgToCmm.Prof (initInfoTableProv) -import GHC.StgToCmm.Types (CgInfos (..), ModuleLFInfos) -import GHC.Stg.InferTags.TagSig (TagSig) +import GHC.StgToCmm.Types (CmmCgInfos (..), ModuleLFInfos) import GHC.Types.IPE (InfoTableProvMap (provInfoTables), IpeSourceLocation) import GHC.Types.Name.Set (NonCaffySet) -import GHC.Types.Name.Env (NameEnv) import GHC.Types.Tickish (GenTickish (SourceNote)) import GHC.Unit.Types (Module) import GHC.Utils.Misc @@ -180,8 +178,8 @@ The find the tick: remembered in a `Maybe`. -} -generateCgIPEStub :: HscEnv -> Module -> InfoTableProvMap -> NameEnv TagSig -> Stream IO CmmGroupSRTs (NonCaffySet, ModuleLFInfos) -> Stream IO CmmGroupSRTs CgInfos -generateCgIPEStub hsc_env this_mod denv tag_sigs s = do +generateCgIPEStub :: HscEnv -> Module -> InfoTableProvMap -> Stream IO CmmGroupSRTs (NonCaffySet, ModuleLFInfos) -> Stream IO CmmGroupSRTs CmmCgInfos +generateCgIPEStub hsc_env this_mod denv s = do let dflags = hsc_dflags hsc_env platform = targetPlatform dflags logger = hsc_logger hsc_env @@ -200,7 +198,7 @@ generateCgIPEStub hsc_env this_mod denv tag_sigs s = do (_, ipeCmmGroupSRTs) <- liftIO $ cmmPipeline logger cmm_cfg (emptySRT this_mod) ipeCmmGroup Stream.yield ipeCmmGroupSRTs - return CgInfos {cgNonCafs = nonCaffySet, cgLFInfos = moduleLFInfos, cgIPEStub = ipeStub, cgTagSigs = tag_sigs} + return CmmCgInfos {cgNonCafs = nonCaffySet, cgLFInfos = moduleLFInfos, cgIPEStub = ipeStub} where collect :: Platform -> [(Label, CmmInfoTable, Maybe IpeSourceLocation)] -> CmmGroupSRTs -> IO ([(Label, CmmInfoTable, Maybe IpeSourceLocation)], CmmGroupSRTs) collect platform acc cmmGroupSRTs = do ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -186,15 +186,14 @@ import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Zonk ( ZonkFlexi (DefaultFlexi) ) import GHC.Stg.Syntax -import GHC.Stg.Pipeline ( stg2stg ) -import GHC.Stg.InferTags +import GHC.Stg.Pipeline ( stg2stg, StgCgInfos ) import GHC.Builtin.Utils import GHC.Builtin.Names import GHC.Builtin.Uniques ( mkPseudoUniqueE ) import qualified GHC.StgToCmm as StgToCmm ( codeGen ) -import GHC.StgToCmm.Types (CgInfos (..), ModuleLFInfos) +import GHC.StgToCmm.Types (CmmCgInfos (..), ModuleLFInfos) import GHC.Cmm import GHC.Cmm.Info.Build @@ -268,6 +267,8 @@ import Data.Functor import Control.DeepSeq (force) import Data.Bifunctor (first) import Data.List.NonEmpty (NonEmpty ((:|))) +import GHC.Stg.InferTags.TagSig (seqTagSig) +import GHC.Types.Unique.FM {- ********************************************************************** @@ -1669,7 +1670,7 @@ hscSimpleIface' tc_result summary = do -- | Compile to hard-code. hscGenHardCode :: HscEnv -> CgGuts -> ModLocation -> FilePath - -> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], Maybe CgInfos) + -> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], Maybe StgCgInfos, Maybe CmmCgInfos ) -- ^ @Just f@ <=> _stub.c is f hscGenHardCode hsc_env cgguts location output_filename = do let CgGuts{ -- This is the last use of the ModGuts in a compilation. @@ -1719,11 +1720,16 @@ hscGenHardCode hsc_env cgguts location output_filename = do this_mod location late_cc_binds data_tycons ----------------- Convert to STG ------------------ - (stg_binds, denv, (caf_ccs, caf_cc_stacks)) + (stg_binds, denv, (caf_ccs, caf_cc_stacks), stg_cg_infos) <- {-# SCC "CoreToStg" #-} withTiming logger (text "CoreToStg"<+>brackets (ppr this_mod)) - (\(a, b, (c,d)) -> a `seqList` b `seq` c `seqList` d `seqList` ()) + (\(a, b, (c,d), tag_env) -> + a `seqList` + b `seq` + c `seqList` + d `seqList` + (seqEltsUFM (seqTagSig) tag_env)) (myCoreToStg logger dflags (hsc_IC hsc_env) False this_mod location prepd_binds) let cost_centre_info = @@ -1762,11 +1768,12 @@ hscGenHardCode hsc_env cgguts location output_filename = do let foreign_stubs st = foreign_stubs0 `appendStubC` prof_init `appendStubC` cgIPEStub st - (output_filename, (_stub_h_exists, stub_c_exists), foreign_fps, cg_infos) + (output_filename, (_stub_h_exists, stub_c_exists), foreign_fps, cmm_cg_infos) <- {-# SCC "codeOutput" #-} codeOutput logger tmpfs llvm_config dflags (hsc_units hsc_env) this_mod output_filename location foreign_stubs foreign_files dependencies rawcmms1 - return (output_filename, stub_c_exists, foreign_fps, Just cg_infos) + return ( output_filename, stub_c_exists, foreign_fps + , Just stg_cg_infos, Just cmm_cg_infos) hscInteractive :: HscEnv @@ -1801,7 +1808,9 @@ hscInteractive hsc_env cgguts location = do (initCorePrepPgmConfig (hsc_dflags hsc_env) (interactiveInScope $ hsc_IC hsc_env)) this_mod location core_binds data_tycons - (stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks) + -- The stg cg info only provides a runtime benfit, but is not requires so we just + -- omit it here + (stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks, _ignore_stg_cg_infos) <- {-# SCC "CoreToStg" #-} myCoreToStg logger dflags (hsc_IC hsc_env) True this_mod location prepd_binds ----------------- Generate byte code ------------------ @@ -1895,7 +1904,7 @@ doCodeGen :: HscEnv -> Module -> InfoTableProvMap -> [TyCon] -> CollectedCCs -> [CgStgTopBinding] -- ^ Bindings come already annotated with fvs -> HpcInfo - -> IO (Stream IO CmmGroupSRTs CgInfos) + -> IO (Stream IO CmmGroupSRTs CmmCgInfos) -- Note we produce a 'Stream' of CmmGroups, so that the -- backend can be run incrementally. Otherwise it generates all -- the C-- up front, which has a significant space cost. @@ -1906,13 +1915,10 @@ doCodeGen hsc_env this_mod denv data_tycons hooks = hsc_hooks hsc_env tmpfs = hsc_tmpfs hsc_env platform = targetPlatform dflags - - -- Do tag inference on optimized STG - (!stg_post_infer,export_tag_info) <- - {-# SCC "StgTagFields" #-} inferTags dflags logger this_mod stg_binds_w_fvs + stg_ppr_opts = (initStgPprOpts dflags) putDumpFileMaybe logger Opt_D_dump_stg_final "Final STG:" FormatSTG - (pprGenStgTopBindings (initStgPprOpts dflags) stg_post_infer) + (pprGenStgTopBindings stg_ppr_opts stg_binds_w_fvs) let stg_to_cmm dflags mod = case stgToCmmHook hooks of Nothing -> StgToCmm.codeGen logger tmpfs (initStgToCmmConfig dflags mod) @@ -1920,8 +1926,8 @@ doCodeGen hsc_env this_mod denv data_tycons let cmm_stream :: Stream IO CmmGroup ModuleLFInfos -- See Note [Forcing of stg_binds] - cmm_stream = stg_post_infer `seqList` {-# SCC "StgToCmm" #-} - stg_to_cmm dflags this_mod denv data_tycons cost_centre_info stg_post_infer hpc_info + cmm_stream = stg_binds_w_fvs `seqList` {-# SCC "StgToCmm" #-} + stg_to_cmm dflags this_mod denv data_tycons cost_centre_info stg_binds_w_fvs hpc_info -- codegen consumes a stream of CmmGroup, and produces a new -- stream of CmmGroup (not necessarily synchronised: one @@ -1952,7 +1958,7 @@ doCodeGen hsc_env this_mod denv data_tycons putDumpFileMaybe logger Opt_D_dump_cmm "Output Cmm" FormatCMM (pdoc platform a) return a - return $ Stream.mapM dump2 $ generateCgIPEStub hsc_env this_mod denv export_tag_info pipeline_stream + return $ Stream.mapM dump2 $ generateCgIPEStub hsc_env this_mod denv pipeline_stream myCoreToStgExpr :: Logger -> DynFlags -> InteractiveContext -> Bool @@ -1960,7 +1966,8 @@ myCoreToStgExpr :: Logger -> DynFlags -> InteractiveContext -> IO ( Id , [CgStgTopBinding] , InfoTableProvMap - , CollectedCCs ) + , CollectedCCs + , StgCgInfos ) myCoreToStgExpr logger dflags ictxt for_bytecode this_mod ml prepd_expr = do {- Create a temporary binding (just because myCoreToStg needs a binding for the stg2stg step) -} @@ -1968,7 +1975,7 @@ myCoreToStgExpr logger dflags ictxt for_bytecode this_mod ml prepd_expr = do (mkPseudoUniqueE 0) Many (exprType prepd_expr) - (stg_binds, prov_map, collected_ccs) <- + (stg_binds, prov_map, collected_ccs, stg_cg_infos) <- myCoreToStg logger dflags ictxt @@ -1976,20 +1983,21 @@ myCoreToStgExpr logger dflags ictxt for_bytecode this_mod ml prepd_expr = do this_mod ml [NonRec bco_tmp_id prepd_expr] - return (bco_tmp_id, stg_binds, prov_map, collected_ccs) + return (bco_tmp_id, stg_binds, prov_map, collected_ccs, stg_cg_infos) myCoreToStg :: Logger -> DynFlags -> InteractiveContext -> Bool -> Module -> ModLocation -> CoreProgram -> IO ( [CgStgTopBinding] -- output program , InfoTableProvMap - , CollectedCCs ) -- CAF cost centre info (declared and used) + , CollectedCCs -- CAF cost centre info (declared and used) + , StgCgInfos ) myCoreToStg logger dflags ictxt for_bytecode this_mod ml prepd_binds = do let (stg_binds, denv, cost_centre_info) = {-# SCC "Core2Stg" #-} coreToStg dflags this_mod ml prepd_binds - stg_binds_with_fvs + (stg_binds_with_fvs,stg_cg_info) <- {-# SCC "Stg2Stg" #-} stg2stg logger (interactiveInScope ictxt) (initStgPipelineOpts dflags for_bytecode) this_mod stg_binds @@ -1997,7 +2005,7 @@ myCoreToStg logger dflags ictxt for_bytecode this_mod ml prepd_binds = do putDumpFileMaybe logger Opt_D_dump_stg_cg "CodeGenInput STG:" FormatSTG (pprGenStgTopBindings (initStgPprOpts dflags) stg_binds_with_fvs) - return (stg_binds_with_fvs, denv, cost_centre_info) + return (stg_binds_with_fvs, denv, cost_centre_info, stg_cg_info) {- ********************************************************************** %* * @@ -2148,7 +2156,7 @@ hscParsedDecls hsc_env decls = runInteractiveHsc hsc_env $ do (initCorePrepPgmConfig (hsc_dflags hsc_env) (interactiveInScope $ hsc_IC hsc_env)) this_mod iNTERACTIVELoc core_binds data_tycons - (stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks) + (stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks, _stg_cg_info) <- {-# SCC "CoreToStg" #-} liftIO $ myCoreToStg (hsc_logger hsc_env) (hsc_dflags hsc_env) @@ -2385,7 +2393,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr ml_hie_file = panic "hscCompileCoreExpr':ml_hie_file" } ; let ictxt = hsc_IC hsc_env - ; (binding_id, stg_expr, _, _) <- + ; (binding_id, stg_expr, _, _, _stg_cg_info) <- myCoreToStgExpr logger dflags ictxt ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -740,7 +740,7 @@ hscBackendPipeline pipe_env hsc_env mod_sum result = else case result of HscUpdate iface -> return (iface, Nothing) - HscRecomp {} -> (,) <$> liftIO (mkFullIface hsc_env (hscs_partial_iface result) Nothing) <*> pure Nothing + HscRecomp {} -> (,) <$> liftIO (mkFullIface hsc_env (hscs_partial_iface result) Nothing Nothing) <*> pure Nothing -- TODO: Why is there not a linkable? -- Interpreter -> (,) <$> use (T_IO (mkFullIface hsc_env (hscs_partial_iface result) Nothing)) <*> pure Nothing ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -537,9 +537,9 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do else if backendWritesFiles (backend dflags) then do output_fn <- phaseOutputFilenameNew next_phase pipe_env hsc_env (Just location) - (outputFilename, mStub, foreign_files, mb_cg_infos) <- + (outputFilename, mStub, foreign_files, mb_stg_infos, mb_cg_infos) <- hscGenHardCode hsc_env cgguts mod_location output_fn - final_iface <- mkFullIface hsc_env partial_iface mb_cg_infos + final_iface <- mkFullIface hsc_env partial_iface mb_stg_infos mb_cg_infos -- See Note [Writing interface files] hscMaybeWriteIface logger dflags False final_iface mb_old_iface_hash mod_location @@ -559,7 +559,7 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do -- In interpreted mode the regular codeGen backend is not run so we -- generate a interface without codeGen info. do - final_iface <- mkFullIface hsc_env partial_iface Nothing + final_iface <- mkFullIface hsc_env partial_iface Nothing Nothing hscMaybeWriteIface logger dflags True final_iface mb_old_iface_hash location (hasStub, comp_bc, spt_entries) <- hscInteractive hsc_env cgguts mod_location ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -23,7 +23,7 @@ import GHC.Prelude import GHC.Hs -import GHC.StgToCmm.Types (CgInfos (..)) +import GHC.StgToCmm.Types (CmmCgInfos (..)) import GHC.Tc.Utils.TcType import GHC.Tc.Utils.Monad @@ -99,6 +99,7 @@ import Data.Function import Data.List ( findIndex, mapAccumL, sortBy ) import Data.Ord import Data.IORef +import GHC.Stg.Pipeline (StgCgInfos) {- @@ -134,16 +135,16 @@ mkPartialIface hsc_env mod_details mod_summary -- | Fully instantiate an interface. Adds fingerprints and potentially code -- generator produced information. -- --- CgInfos is not available when not generating code (-fno-code), or when not +-- CmmCgInfos is not available when not generating code (-fno-code), or when not -- generating interface pragmas (-fomit-interface-pragmas). See also -- Note [Conveying CAF-info and LFInfo between modules] in GHC.StgToCmm.Types. -mkFullIface :: HscEnv -> PartialModIface -> Maybe CgInfos -> IO ModIface -mkFullIface hsc_env partial_iface mb_cg_infos = do +mkFullIface :: HscEnv -> PartialModIface -> Maybe StgCgInfos -> Maybe CmmCgInfos -> IO ModIface +mkFullIface hsc_env partial_iface mb_stg_infos mb_cmm_infos = do let decls | gopt Opt_OmitInterfacePragmas (hsc_dflags hsc_env) = mi_decls partial_iface | otherwise - = updateDecl (mi_decls partial_iface) mb_cg_infos + = updateDecl (mi_decls partial_iface) mb_stg_infos mb_cmm_infos full_iface <- {-# SCC "addFingerprints" #-} @@ -156,11 +157,16 @@ mkFullIface hsc_env partial_iface mb_cg_infos = do return full_iface -updateDecl :: [IfaceDecl] -> Maybe CgInfos -> [IfaceDecl] -updateDecl decls Nothing = decls -updateDecl decls (Just CgInfos{ cgNonCafs = NonCaffySet non_cafs, cgLFInfos = lf_infos, cgTagSigs = tag_sigs }) +updateDecl :: [IfaceDecl] -> Maybe StgCgInfos -> Maybe CmmCgInfos -> [IfaceDecl] +updateDecl decls Nothing Nothing = decls +updateDecl decls m_stg_infos m_cmm_infos = map update_decl decls where + (non_cafs,lf_infos) = maybe (mempty, mempty) + (\cmm_info -> (ncs_nameSet (cgNonCafs cmm_info), cgLFInfos cmm_info)) + m_cmm_infos + tag_sigs = fromMaybe mempty m_stg_infos + update_decl (IfaceId nm ty details infos) | let not_caffy = elemNameSet nm non_cafs , let mb_lf_info = lookupNameEnv lf_infos nm @@ -178,6 +184,9 @@ updateDecl decls (Just CgInfos{ cgNonCafs = NonCaffySet non_cafs, cgLFInfos = lf update_decl decl = decl + + + -- | Make an interface from the results of typechecking only. Useful -- for non-optimising compilation, or where we aren't generating any -- object code at all ('NoBackend'). @@ -235,7 +244,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary docs mod_summary mod_details - mkFullIface hsc_env partial_iface Nothing + mkFullIface hsc_env partial_iface Nothing Nothing mkIface_ :: HscEnv -> Module -> HscSource -> Bool -> Dependencies -> GlobalRdrEnv ===================================== compiler/GHC/Stg/InferTags.hs ===================================== @@ -27,7 +27,6 @@ import GHC.Stg.InferTags.Types import GHC.Stg.InferTags.Rewrite (rewriteTopBinds) import Data.Maybe import GHC.Types.Name.Env (mkNameEnv, NameEnv) -import GHC.Driver.Config.Stg.Ppr import GHC.Driver.Session import GHC.Utils.Logger import qualified GHC.Unit.Types @@ -217,17 +216,17 @@ the output of itself. -- -> CollectedCCs -- -> [CgStgTopBinding] -- ^ Bindings come already annotated with fvs -- -> HpcInfo --- -> IO (Stream IO CmmGroupSRTs CgInfos) +-- -> IO (Stream IO CmmGroupSRTs CmmCgInfos) -- -- Note we produce a 'Stream' of CmmGroups, so that the -- -- backend can be run incrementally. Otherwise it generates all -- -- the C-- up front, which has a significant space cost. -inferTags :: DynFlags -> Logger -> (GHC.Unit.Types.Module) -> [CgStgTopBinding] -> IO ([TgStgTopBinding], NameEnv TagSig) -inferTags dflags logger this_mod stg_binds = do +inferTags :: StgPprOpts -> Logger -> (GHC.Unit.Types.Module) -> [CgStgTopBinding] -> IO ([TgStgTopBinding], NameEnv TagSig) +inferTags ppr_opts logger this_mod stg_binds = do -- Annotate binders with tag information. let (!stg_binds_w_tags) = {-# SCC "StgTagFields" #-} inferTagsAnal stg_binds - putDumpFileMaybe logger Opt_D_dump_stg_tags "CodeGenAnal STG:" FormatSTG (pprGenStgTopBindings (initStgPprOpts dflags) stg_binds_w_tags) + putDumpFileMaybe logger Opt_D_dump_stg_tags "CodeGenAnal STG:" FormatSTG (pprGenStgTopBindings ppr_opts stg_binds_w_tags) let export_tag_info = collectExportInfo stg_binds_w_tags ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -26,7 +26,7 @@ import GHC.Types.Name import GHC.Types.Unique.Supply import GHC.Types.Unique.FM import GHC.Types.RepType -import GHC.Unit.Types (Module) +import GHC.Unit.Types (Module, isInteractiveModule) import GHC.Core.DataCon import GHC.Core (AltCon(..) ) @@ -212,16 +212,56 @@ withLcl fv act = do setFVs old_fvs return r +{- Note [Tag inference for interactive contexts] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When compiling bytecode we call myCoreToStg to get STG code first. +myCoreToStg in turn calls out to stg2stg which runs the STG to STG +passes followed by free variables analysis and the tag inference pass including +it's rewriting phase at the end. +Running tag inference is important as it upholds Note [Strict Field Invariant]. +While code executed by GHCi doesn't take advantage of the SFI it can call into +compiled code which does. So it must still make sure that the SFI is upheld. +See also #21083 and #22042. + +However there one important difference in code generation for GHCi and regular +compilation. When compiling an entire module (not a GHCi expression), we call +`stg2stg` on the entire module which allows us to build up a map which is guaranteed +to have an entry for every binder in the current module. +For non-interactive compilation the tag inference rewrite pass takes advantage +of this by building up a map from binders to their tag signatures. + +When compiling a GHCi expression on the other hand we invoke stg2stg separately +for each expression on the prompt. This means in GHCi for a sequence of: + > let x = True + > let y = StrictJust x +We first run stg2stg for `[x = True]`. And then again for [y = StrictJust x]`. + +While computing the tag signature for `y` during tag inference inferConTag will check +if `x` is already tagged by looking up the tagsig of `x` in the binder->signature mapping. +However since this mapping isn't persistent between stg2stg +invocations the lookup will fail. This isn't a correctness issue since it's always +safe to assume a binding isn't tagged and that's what we do in such cases. + +However for non-interactive mode we *don't* want to do this. Since in non-interactive mode +we have all binders of the module available for each invocation we can expect the binder->signature +mapping to be complete and all lookups to succeed. This means in non-interactive contexts a failed lookup +indicates a bug in the tag inference implementation. +For this reason we assert that we are running in interactive mode if a lookup fails. +-} isTagged :: Id -> RM Bool isTagged v = do this_mod <- getMod + -- See Note [Tag inference for interactive contexts] + let lookupDefault v = assertPpr (isInteractiveModule this_mod) + (text "unknown Id:" <> ppr this_mod <+> ppr v) + (TagSig TagDunno) case nameIsLocalOrFrom this_mod (idName v) of True | isUnliftedType (idType v) -> return True | otherwise -> do -- Local binding !s <- getMap - let !sig = lookupWithDefaultUFM s (pprPanic "unknown Id:" (ppr v)) v + let !sig = lookupWithDefaultUFM s (lookupDefault v) v return $ case sig of TagSig info -> case info of ===================================== compiler/GHC/Stg/InferTags/TagSig.hs ===================================== @@ -16,6 +16,7 @@ import GHC.Types.Var import GHC.Utils.Outputable import GHC.Utils.Binary import GHC.Utils.Panic.Plain +import Data.Coerce data TagInfo = TagDunno -- We don't know anything about the tag. @@ -64,3 +65,12 @@ isTaggedSig :: TagSig -> Bool isTaggedSig (TagSig TagProper) = True isTaggedSig (TagSig TagTagged) = True isTaggedSig _ = False + +seqTagSig :: TagSig -> () +seqTagSig = coerce seqTagInfo + +seqTagInfo :: TagInfo -> () +seqTagInfo TagTagged = () +seqTagInfo TagDunno = () +seqTagInfo TagProper = () +seqTagInfo (TagTuple tis) = foldl' (\_unit sig -> seqTagSig (coerce sig)) () tis \ No newline at end of file ===================================== compiler/GHC/Stg/Pipeline.hs ===================================== @@ -13,6 +13,7 @@ module GHC.Stg.Pipeline ( StgPipelineOpts (..) , StgToDo (..) , stg2stg + , StgCgInfos ) where import GHC.Prelude @@ -39,6 +40,9 @@ import Control.Monad import Control.Monad.IO.Class import Control.Monad.Trans.Reader import GHC.Settings (Platform) +import GHC.Stg.InferTags (inferTags) +import GHC.Types.Name.Env (NameEnv) +import GHC.Stg.InferTags.TagSig (TagSig) data StgPipelineOpts = StgPipelineOpts { stgPipeline_phases :: ![StgToDo] @@ -52,6 +56,10 @@ data StgPipelineOpts = StgPipelineOpts newtype StgM a = StgM { _unStgM :: ReaderT Char IO a } deriving (Functor, Applicative, Monad, MonadIO) +-- | Information to be exposed in interface files which is produced +-- by the stg2stg passes. +type StgCgInfos = NameEnv TagSig + instance MonadUnique StgM where getUniqueSupplyM = StgM $ do { mask <- ask ; liftIO $! mkSplitUniqSupply mask} @@ -66,7 +74,7 @@ stg2stg :: Logger -> StgPipelineOpts -> Module -- ^ module being compiled -> [StgTopBinding] -- ^ input program - -> IO [CgStgTopBinding] -- output program + -> IO ([CgStgTopBinding], StgCgInfos) -- output program stg2stg logger extra_vars opts this_mod binds = do { dump_when Opt_D_dump_stg_from_core "Initial STG:" binds ; showPass logger "Stg2Stg" @@ -85,7 +93,8 @@ stg2stg logger extra_vars opts this_mod binds -- This pass will also augment each closure with non-global free variables -- annotations (which is used by code generator to compute offsets into closures) ; let binds_sorted_with_fvs = depSortWithAnnotStgPgm this_mod binds' - ; return binds_sorted_with_fvs + -- See Note [Tag inference for interactive contexts] + ; inferTags (stgPipeline_pprOpts opts) logger this_mod binds_sorted_with_fvs } where ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -1669,10 +1669,21 @@ pushAtom d p (StgVarArg var) case lookupVarEnv topStrings var of Just ptr -> pushAtom d p $ StgLitArg $ mkLitWord platform $ fromIntegral $ ptrToWordPtr $ fromRemotePtr ptr - Nothing -> do - let sz = idSizeCon platform var - massert (sz == wordSize platform) - return (unitOL (PUSH_G (getName var)), sz) + Nothing + -- PUSH_G doesn't tag constructors. So we use PACK here + -- if we are dealing with nullary constructor. + | Just con <- isDataConWorkId_maybe var + -> do + massert (sz == wordSize platform) + massert (isNullaryRepDataCon con) + return (unitOL (PACK con 0), sz) + | otherwise + -> do + let + massert (sz == wordSize platform) + return (unitOL (PUSH_G (getName var)), sz) + where + !sz = idSizeCon platform var pushAtom _ _ (StgLitArg lit) = pushLiteral True lit ===================================== compiler/GHC/StgToCmm/Types.hs ===================================== @@ -1,7 +1,7 @@ module GHC.StgToCmm.Types - ( CgInfos (..) + ( CmmCgInfos (..) , LambdaFormInfo (..) , ModuleLFInfos , StandardFormInfo (..) @@ -13,8 +13,6 @@ import GHC.Prelude import GHC.Core.DataCon -import GHC.Stg.InferTags.TagSig - import GHC.Runtime.Heap.Layout import GHC.Types.Basic @@ -85,7 +83,7 @@ moving parts are: -- -- See also Note [Conveying CAF-info and LFInfo between modules] above. -- -data CgInfos = CgInfos +data CmmCgInfos = CmmCgInfos { cgNonCafs :: !NonCaffySet -- ^ Exported Non-CAFFY closures in the current module. Everything else is -- either not exported of CAFFY. @@ -93,7 +91,6 @@ data CgInfos = CgInfos -- ^ LambdaFormInfos of exported closures in the current module. , cgIPEStub :: !CStub -- ^ The C stub which is used for IPE information - , cgTagSigs :: !(NameEnv TagSig) } -------------------------------------------------------------------------------- ===================================== compiler/GHC/Types/Name/Set.hs ===================================== @@ -220,5 +220,5 @@ findUses dus uses -- | 'Id's which have no CAF references. This is a result of analysis of C--. -- It is always safe to use an empty 'NonCaffySet'. TODO Refer to Note. -newtype NonCaffySet = NonCaffySet NameSet +newtype NonCaffySet = NonCaffySet { ncs_nameSet :: NameSet } deriving (Semigroup, Monoid) ===================================== testsuite/tests/ghci.debugger/scripts/T12458.stdout ===================================== @@ -1,2 +1,2 @@ -d = (_t1::forall {k} {a :: k}. D a) +d = () ===================================== testsuite/tests/ghci.debugger/scripts/print018.stdout ===================================== @@ -1,9 +1,9 @@ Breakpoint 0 activated at Test.hs:40:10-17 Stopped in Test.Test2.poly, Test.hs:40:10-17 _result :: () = _ -x :: a = _ -x = (_t1::a) -x :: a +x :: Unary = Unary +x = Unary +x :: Unary () x = Unary x :: Unary ===================================== testsuite/tests/simplStg/should_run/Makefile ===================================== @@ -1,3 +1,12 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk + +T22042: T22042_clean + "$(TEST_HC)" $(TEST_HC_OPTS) -O T22042a.hs -dynamic -c + "$(TEST_HC)" $(TEST_HC_OPTS) -e ":main" T22042.hs T22042a.o + +T22042_clean: + rm -f T22042a.o T22042a.hi + +.PHONY: T22042 T22042_clean ===================================== testsuite/tests/simplStg/should_run/T22042.hs ===================================== @@ -0,0 +1,6 @@ +module Main where + +import T22042a + +main = do + putStrLn (foo $ SC A B C) ===================================== testsuite/tests/simplStg/should_run/T22042.stdout ===================================== @@ -0,0 +1 @@ +ABC ===================================== testsuite/tests/simplStg/should_run/T22042a.hs ===================================== @@ -0,0 +1,10 @@ +module T22042a where + +data A = A | AA deriving Show +data B = B | AB deriving Show +data C = C | AC deriving Show + +data SC = SC !A !B !C + +foo :: SC -> String +foo (SC a b c) = show a ++ show b ++ show c ===================================== testsuite/tests/simplStg/should_run/all.T ===================================== @@ -19,3 +19,4 @@ test('T13536a', ['']) test('inferTags001', normal, multimod_compile_and_run, ['inferTags001', 'inferTags001_a']) +test('T22042', [extra_files(['T22042a.hs']),only_ways('normal'),unless(have_dynamic(), skip)], makefile_test, ['T22042']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3ccd63ddfbb784b126571702c34e74ef25dbbd4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3ccd63ddfbb784b126571702c34e74ef25dbbd4 You're receiving 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 Sep 15 14:18:34 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 15 Sep 2022 10:18:34 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] 14 commits: Fix typos Message-ID: <6323343a2eabe_3b59a65152c139707d@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 40f16b66 by Matthew Pickering at 2022-09-15T15:18:21+01:00 fedora33-hackage job, make bindist name distinct from fedora33-release job See #22180 for the motivation. We want to compare the ABI of fedora33-release and fedora33-hackage but are unable to do so unless the artifacts have different names. - - - - - a33a7729 by Matthew Pickering at 2022-09-15T15:18:21+01:00 Add job for testing ABI stability across builds The idea is that both the bindists should product libraries with the same ABI. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph.hs - compiler/GHC/CmmToAsm/Reg/Graph/Base.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/AArch64.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34df9071afd35983414c60bd4a1dba47c31ded9a...a33a77294ebf412635446ffa8bf00c8b38a9aae6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34df9071afd35983414c60bd4a1dba47c31ded9a...a33a77294ebf412635446ffa8bf00c8b38a9aae6 You're receiving 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 Sep 15 16:55:58 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Thu, 15 Sep 2022 12:55:58 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Adjust derefnull test exit code for ghcjs Message-ID: <6323591e57ecc_3b59a6194ff95c1413068@gitlab.mail> Josh Meredith pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: be469255 by Josh Meredith at 2022-09-15T16:55:36+00:00 Adjust derefnull test exit code for ghcjs - - - - - 1 changed file: - testsuite/tests/rts/all.T Changes: ===================================== testsuite/tests/rts/all.T ===================================== @@ -42,6 +42,7 @@ test('derefnull', when(platform('aarch64-apple-darwin'), [ignore_stderr, exit_code(139)]), when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), when(opsys('mingw32'), [fragile(18548)]), + when(platform('js-unknown-ghcjs'), [ignore_stderr, exit_code(1)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), # since these test are supposed to crash the View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be469255d19351212aa0b5cc6cf97534b743f47f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be469255d19351212aa0b5cc6cf97534b743f47f You're receiving 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 Sep 15 18:13:55 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Sep 2022 14:13:55 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Clean up some. In particular: Message-ID: <63236b63c3c92_3b59a65152c1421786@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a0a6792d by M Farkas-Dyck at 2022-09-15T03:04:38-08: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. - - - - - 50b744a3 by Andreas Klebinger at 2022-09-15T14:13:21-04: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. - - - - - df62bbc3 by Andreas Klebinger at 2022-09-15T14:13:21-04:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 1509fc16 by Matthew Pickering at 2022-09-15T14:13:23-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 - - - - - 0eddfa9c by Cheng Shao at 2022-09-15T14:13:30-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - a60f5ce7 by Cheng Shao at 2022-09-15T14:13:30-04:00 hadrian: add late_ccs flavour transformer - - - - - b12131a8 by Cheng Shao at 2022-09-15T14:13:33-04:00 configure: remove unused program checks - - - - - c507ecd3 by Bodigrim at 2022-09-15T14:13:36-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - ead19a53 by Cheng Shao at 2022-09-15T14:13:37-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c742e8e7b2c13fec8ad15485c7ff44457f0fc7d6...ead19a53bcb051ad39e99846c53e418b7a4b816e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c742e8e7b2c13fec8ad15485c7ff44457f0fc7d6...ead19a53bcb051ad39e99846c53e418b7a4b816e You're receiving 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 Sep 15 20:44:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Sep 2022 16:44:39 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <63238eb7ec3ee_3b59a6194ff95c1472946@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - a08c2b93 by Matthew Pickering at 2022-09-15T16:43:56-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 - - - - - fc16444b by M Farkas-Dyck at 2022-09-15T16:44:00-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. - - - - - 7f2bc3f9 by M Farkas-Dyck at 2022-09-15T16:44:00-04:00 Make GADT constructor names `NonEmpty`. Closes #22070. - - - - - fa614c58 by Cheng Shao at 2022-09-15T16:44:02-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - 496c1fbf by Cheng Shao at 2022-09-15T16:44:02-04:00 hadrian: add late_ccs flavour transformer - - - - - 8d2bdc68 by Cheng Shao at 2022-09-15T16:44:05-04:00 configure: remove unused program checks - - - - - 7c7b66e7 by Pierre Le Marre at 2022-09-15T16:44:08-04:00 Update to Unicode 15.0 - - - - - 5bcdd573 by Bodigrim at 2022-09-15T16:44:11-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - b301c7ce by Cheng Shao at 2022-09-15T16:44:13-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - 3567157a by Alexis King at 2022-09-15T16:44:22-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Monad.hs - compiler/Language/Haskell/Syntax/Decls.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ead19a53bcb051ad39e99846c53e418b7a4b816e...3567157a507ed243f8c12b0395be36f5c62f5929 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ead19a53bcb051ad39e99846c53e418b7a4b816e...3567157a507ed243f8c12b0395be36f5c62f5929 You're receiving 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 Sep 15 21:58:01 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 15 Sep 2022 17:58:01 -0400 Subject: [Git][ghc/ghc][ghc-9.4] Fix a nasty loop in Tidy Message-ID: <63239fe996ab8_3b59a6518381523745@gitlab.mail> Andreas Klebinger pushed to branch ghc-9.4 at Glasgow Haskell Compiler / GHC Commits: 2cf828e8 by Simon Peyton Jones at 2022-09-15T10:28:17+02: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] This is the 9.4 packport based on commit 4945953823620b223a0b51b2b1275a1de8f4a851 - - - - - 6 changed files: - compiler/GHC/Core/Tidy.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Types/Id/Info.hs - + testsuite/tests/simplCore/should_compile/T22112.hs - + testsuite/tests/simplCore/should_compile/T22112.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -10,7 +10,7 @@ The code for *top-level* bindings is in GHC.Iface.Tidy. {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Core.Tidy ( - tidyExpr, tidyRules, tidyUnfolding, tidyCbvInfoTop + tidyExpr, tidyRules, tidyCbvInfoTop, tidyBndrs ) where import GHC.Prelude @@ -345,33 +345,36 @@ tidyLetBndr rec_tidy_env env@(tidy_env, var_env) id `setUnfoldingInfo` new_unf old_unf = realUnfoldingInfo old_info - new_unf | isStableUnfolding old_unf = tidyUnfolding rec_tidy_env old_unf old_unf - | otherwise = trimUnfolding old_unf - -- See Note [Preserve evaluatedness] + new_unf = tidyNestedUnfolding rec_tidy_env old_unf in ((tidy_env', var_env'), id') } ------------ Unfolding -------------- -tidyUnfolding :: TidyEnv -> Unfolding -> Unfolding -> Unfolding -tidyUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) _ +tidyNestedUnfolding :: TidyEnv -> Unfolding -> Unfolding +tidyNestedUnfolding _ NoUnfolding = NoUnfolding +tidyNestedUnfolding _ BootUnfolding = BootUnfolding +tidyNestedUnfolding _ (OtherCon {}) = evaldUnfolding + +tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } where (tidy_env', bndrs') = tidyBndrs tidy_env bndrs -tidyUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) - unf_from_rhs +tidyNestedUnfolding tidy_env + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) - - | otherwise - = unf_from_rhs - where seqIt unf = seqUnfolding unf `seq` unf -tidyUnfolding _ unf _ = unf -- NoUnfolding or OtherCon + -- This seqIt avoids a space leak: otherwise the uf_is_value, + -- uf_is_conlike, ... fields may retain a reference to the + -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + + -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] + | is_value = evaldUnfolding + | otherwise = noUnfolding + + where + seqIt unf = seqUnfolding unf `seq` unf {- Note [Tidy IdInfo] ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -24,13 +24,12 @@ import GHC.Tc.Utils.Env import GHC.Core import GHC.Core.Unfold -import GHC.Core.Unfold.Make import GHC.Core.FVs import GHC.Core.Tidy import GHC.Core.Seq (seqBinds) -import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe ) +import GHC.Core.Opt.Arity ( exprArity, exprBotStrictness_maybe, typeArity ) import GHC.Core.InstEnv -import GHC.Core.Type ( tidyTopType ) +import GHC.Core.Type ( tidyTopType, Type ) import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Core.Class @@ -74,6 +73,7 @@ import Data.Function import Data.List ( sortBy, mapAccumL ) import qualified Data.Set as S import GHC.Types.CostCentre +import GHC.Core.Opt.OccurAnal (occurAnalyseExpr) {- Constructing the TypeEnv, Instances, Rules from which the @@ -384,8 +384,7 @@ tidyProgram opts (ModGuts { mg_module = mod (unfold_env, tidy_occ_env) <- chooseExternalIds opts mod binds implicit_binds imp_rules let (trimmed_binds, trimmed_rules) = findExternalRules opts binds imp_rules unfold_env - let uf_opts = opt_unfolding_opts opts - (tidy_env, tidy_binds) <- tidyTopBinds uf_opts unfold_env boot_exports tidy_occ_env trimmed_binds + (tidy_env, tidy_binds) <- tidyTopBinds unfold_env boot_exports tidy_occ_env trimmed_binds -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. (spt_entries, mcstub, tidy_binds') <- case opt_static_ptr_opts opts of @@ -1146,60 +1145,49 @@ tidyTopName mod name_cache maybe_ref occ_env id -- -- * subst_env: A Var->Var mapping that substitutes the new Var for the old -tidyTopBinds :: UnfoldingOpts - -> UnfoldEnv +tidyTopBinds :: UnfoldEnv -> NameSet -> TidyOccEnv -> CoreProgram -> IO (TidyEnv, CoreProgram) -tidyTopBinds uf_opts unfold_env boot_exports init_occ_env binds +tidyTopBinds unfold_env boot_exports init_occ_env binds = do let result = tidy init_env binds seqBinds (snd result) `seq` return result -- This seqBinds avoids a spike in space usage (see #13564) where init_env = (init_occ_env, emptyVarEnv) - tidy = mapAccumL (tidyTopBind uf_opts unfold_env boot_exports) + tidy = mapAccumL (tidyTopBind unfold_env boot_exports) ------------------------ -tidyTopBind :: UnfoldingOpts - -> UnfoldEnv +tidyTopBind :: UnfoldEnv -> NameSet -> TidyEnv -> CoreBind -> (TidyEnv, CoreBind) -tidyTopBind uf_opts unfold_env boot_exports +tidyTopBind unfold_env boot_exports (occ_env,subst1) (NonRec bndr rhs) = (tidy_env2, NonRec bndr' rhs') where - Just (name',show_unfold) = lookupVarEnv unfold_env bndr - (bndr', rhs') = tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (bndr, rhs) + (bndr', rhs') = tidyTopPair unfold_env boot_exports tidy_env2 (bndr, rhs) subst2 = extendVarEnv subst1 bndr bndr' tidy_env2 = (occ_env, subst2) -tidyTopBind uf_opts unfold_env boot_exports (occ_env, subst1) (Rec prs) +tidyTopBind unfold_env boot_exports (occ_env, subst1) (Rec prs) = (tidy_env2, Rec prs') where - prs' = [ tidyTopPair uf_opts show_unfold boot_exports tidy_env2 name' (id,rhs) - | (id,rhs) <- prs, - let (name',show_unfold) = - expectJust "tidyTopBind" $ lookupVarEnv unfold_env id - ] - - subst2 = extendVarEnvList subst1 (bndrs `zip` map fst prs') + prs' = map (tidyTopPair unfold_env boot_exports tidy_env2) prs + subst2 = extendVarEnvList subst1 (map fst prs `zip` map fst prs') tidy_env2 = (occ_env, subst2) - - bndrs = map fst prs + -- This is where we "tie the knot": tidy_env2 is fed into tidyTopPair ----------------------------------------------------------- -tidyTopPair :: UnfoldingOpts - -> Bool -- show unfolding +tidyTopPair :: UnfoldEnv -> NameSet -> TidyEnv -- The TidyEnv is used to tidy the IdInfo -- It is knot-tied: don't look at it! - -> Name -- New name -> (Id, CoreExpr) -- Binder and RHS before tidying -> (Id, CoreExpr) -- This function is the heart of Step 2 @@ -1208,18 +1196,19 @@ tidyTopPair :: UnfoldingOpts -- group, a variable late in the group might be mentioned -- in the IdInfo of one early in the group -tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) +tidyTopPair unfold_env boot_exports rhs_tidy_env (bndr, rhs) = -- pprTrace "tidyTop" (ppr name' <+> ppr details <+> ppr rhs) $ (bndr1, rhs1) where + Just (name',show_unfold) = lookupVarEnv unfold_env bndr !cbv_bndr = tidyCbvInfoTop boot_exports bndr rhs bndr1 = mkGlobalId details name' ty' idinfo' details = idDetails cbv_bndr -- Preserve the IdDetails ty' = tidyTopType (idType cbv_bndr) rhs1 = tidyExpr rhs_tidy_env rhs - idinfo' = tidyTopIdInfo uf_opts rhs_tidy_env name' rhs rhs1 (idInfo cbv_bndr) - show_unfold + idinfo' = tidyTopIdInfo rhs_tidy_env name' ty' + rhs rhs1 (idInfo cbv_bndr) show_unfold -- tidyTopIdInfo creates the final IdInfo for top-level -- binders. The delicate piece: @@ -1228,9 +1217,9 @@ tidyTopPair uf_opts show_unfold boot_exports rhs_tidy_env name' (bndr, rhs) -- Indeed, CorePrep must eta expand where necessary to make -- the manifest arity equal to the claimed arity. -- -tidyTopIdInfo :: UnfoldingOpts -> TidyEnv -> Name -> CoreExpr -> CoreExpr +tidyTopIdInfo :: TidyEnv -> Name -> Type -> CoreExpr -> CoreExpr -> IdInfo -> Bool -> IdInfo -tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold +tidyTopIdInfo rhs_tidy_env name rhs_ty orig_rhs tidy_rhs idinfo show_unfold | not is_external -- For internal Ids (not externally visible) = vanillaIdInfo -- we only need enough info for code generation -- Arity and strictness info are enough; @@ -1281,13 +1270,17 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold --------- Unfolding ------------ unf_info = realUnfoldingInfo idinfo - unfold_info - | isCompulsoryUnfolding unf_info || show_unfold - = tidyUnfolding rhs_tidy_env unf_info unf_from_rhs - | otherwise - = minimal_unfold_info - minimal_unfold_info = trimUnfolding unf_info - unf_from_rhs = mkFinalUnfolding uf_opts InlineRhs final_sig tidy_rhs + !minimal_unfold_info = trimUnfolding unf_info + + !unfold_info | isCompulsoryUnfolding unf_info || show_unfold + = tidyTopUnfolding rhs_tidy_env tidy_rhs unf_info + | otherwise + = minimal_unfold_info + + -- NB: use `orig_rhs` not `tidy_rhs` in this call to mkFinalUnfolding + -- else you get a black hole (#22122). Reason: mkFinalUnfolding + -- looks at IdInfo, and that is knot-tied in tidyTopBind (the Rec case) + -- NB: do *not* expose the worker if show_unfold is off, -- because that means this thing is a loop breaker or -- marked NOINLINE or something like that @@ -1311,4 +1304,54 @@ tidyTopIdInfo uf_opts rhs_tidy_env name orig_rhs tidy_rhs idinfo show_unfold -- did was to let-bind a non-atomic argument and then float -- it to the top level. So it seems more robust just to -- fix it here. - arity = exprArity orig_rhs + arity = exprArity orig_rhs `min` (length $ typeArity rhs_ty) + + +------------ Unfolding -------------- +tidyTopUnfolding :: TidyEnv -> CoreExpr -> Unfolding -> Unfolding +tidyTopUnfolding _ _ NoUnfolding = NoUnfolding +tidyTopUnfolding _ _ BootUnfolding = BootUnfolding +tidyTopUnfolding _ _ (OtherCon {}) = evaldUnfolding + +tidyTopUnfolding tidy_env _ df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) + = df { df_bndrs = bndrs', df_args = map (tidyExpr tidy_env') args } + where + (tidy_env', bndrs') = tidyBndrs tidy_env bndrs + +tidyTopUnfolding tidy_env tidy_rhs + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src }) + = -- See Note [tidyTopUnfolding: avoiding black holes] + unf { uf_tmpl = tidy_unf_rhs } + where + tidy_unf_rhs | isStableSource src + = tidyExpr tidy_env unf_rhs -- Preserves OccInfo in unf_rhs + | otherwise + = occurAnalyseExpr tidy_rhs -- Do occ-anal + +{- Note [tidyTopUnfolding: avoiding black holes] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we are exposing all unfoldings we don't want to tidy the unfolding +twice -- we just want to use the tidied RHS. That tidied RHS itself +contains fully-tidied Ids -- it is knot-tied. So the uf_tmpl for the +unfolding contains stuff we can't look at. Now consider (#22112) + foo = foo +If we freshly compute the uf_is_value field for foo's unfolding, +we'll call `exprIsValue`, which will look at foo's unfolding! +Whether or not the RHS is a value depends on whether foo is a value... +black hole. + +In the Simplifier we deal with this by not giving `foo` an unfolding +in its own RHS. And we could do that here. But it's qite nice +to common everything up to a single Id for foo, used everywhere. + +And it's not too hard: simply leave the unfolding undisturbed, except +tidy the uf_tmpl field. Hence tidyTopUnfolding does + unf { uf_tmpl = tidy_unf_rhs } + +Don't mess with uf_is_value, or guidance; in particular don't recompute +them from tidy_unf_rhs. + +And (unlike tidyNestedUnfolding) don't deep-seq the new unfolding, +because that'll cause a black hole (I /think/ because occurAnalyseExpr +looks in IdInfo). +-} \ No newline at end of file ===================================== compiler/GHC/Types/Id/Info.hs ===================================== @@ -834,7 +834,7 @@ zapFragileUnfolding unf trimUnfolding :: Unfolding -> Unfolding -- Squash all unfolding info, preserving only evaluated-ness trimUnfolding unf | isEvaldUnfolding unf = evaldUnfolding - | otherwise = noUnfolding + | otherwise = noUnfolding zapTailCallInfo :: IdInfo -> Maybe IdInfo zapTailCallInfo info ===================================== testsuite/tests/simplCore/should_compile/T22112.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module Rec where + +-- This one created a black hole in Tidy, +-- when creating the tidied unfolding for foo +foo :: () -> () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T22112.stderr ===================================== @@ -0,0 +1,14 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 2, types: 2, coercions: 0, joins: 0/0} + +Rec { +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +foo [Occ=LoopBreaker] :: () -> () +[GblId, Str=b, Cpr=b] +foo = foo +end Rec } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -393,4 +393,5 @@ test('OpaqueNoStrictArgWW', normal, compile, ['-O -fworker-wrapper-cbv -ddump-si test('OpaqueNoWW', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T21144', normal, compile, ['-O']) +test('T22112', normal, compile, ['-O -dsuppress-uniques -dno-typeable-binds -ddump-simpl']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2cf828e829011f103ea946756a0c53322fa238dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2cf828e829011f103ea946756a0c53322fa238dd You're receiving 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 Sep 15 23:10:11 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 15 Sep 2022 19:10:11 -0400 Subject: [Git][ghc/ghc][wip/T21623] 13 commits: hadrian: Use a stamp file to record when a package is built in a certain way Message-ID: <6323b0d3990f0_3b59a6195e331415511a6@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 6adbbd15 by Simon Peyton Jones at 2022-09-16T00:10:27+01: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 - - - - - ca749440 by Simon Peyton Jones at 2022-09-16T00:10:27+01:00 Revert accidental changes in SameOccInfo fixes mod180, tcfail182 - - - - - eb3b7f72 by Simon Peyton Jones at 2022-09-16T00:10:27+01:00 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare - - - - - 21 changed files: - .gitlab/ci.sh - 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/Builtin/primops.txt.pp - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/770f2de936af9e5807af7bc2cc266a004a59de7f...eb3b7f722f48118d51c354bb60be948d5813ba48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/770f2de936af9e5807af7bc2cc266a004a59de7f...eb3b7f722f48118d51c354bb60be948d5813ba48 You're receiving 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 Sep 15 23:15:20 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Sep 2022 19:15:20 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <6323b208e2b54_3b59a6194ff95c1553754@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6e4cfe08 by Matthew Pickering at 2022-09-15T19:14:38-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 - - - - - 825bbb1a by Cheng Shao at 2022-09-15T19:14:41-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - 827269b1 by Cheng Shao at 2022-09-15T19:14:42-04:00 hadrian: add late_ccs flavour transformer - - - - - 62ea1fb9 by Cheng Shao at 2022-09-15T19:14:44-04:00 configure: remove unused program checks - - - - - ff45324b by Pierre Le Marre at 2022-09-15T19:14:46-04:00 Update to Unicode 15.0 - - - - - abd4276e by Bodigrim at 2022-09-15T19:14:49-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 62f8c7ea by Cheng Shao at 2022-09-15T19:14:51-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - 085bef68 by Alexis King at 2022-09-15T19:14:53-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 23 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Rename/Bind.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3567157a507ed243f8c12b0395be36f5c62f5929...085bef68c7f3c222dea202b5c1fe7c2651ecfac0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3567157a507ed243f8c12b0395be36f5c62f5929...085bef68c7f3c222dea202b5c1fe7c2651ecfac0 You're receiving 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 Sep 16 02:55:53 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Sep 2022 22:55:53 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <6323e5b941daf_3b59a620aecbec15966ce@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2efc35fe by Matthew Pickering at 2022-09-15T22:55:13-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 - - - - - 1a6838ca by Cheng Shao at 2022-09-15T22:55:17-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - a40e235a by Cheng Shao at 2022-09-15T22:55:17-04:00 hadrian: add late_ccs flavour transformer - - - - - 436f1faf by Cheng Shao at 2022-09-15T22:55:19-04:00 configure: remove unused program checks - - - - - 45c35e54 by Pierre Le Marre at 2022-09-15T22:55:21-04:00 Update to Unicode 15.0 - - - - - aa0ed6ab by Bodigrim at 2022-09-15T22:55:24-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 95747051 by Cheng Shao at 2022-09-15T22:55:26-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - 439772a1 by Alexis King at 2022-09-15T22:55:27-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 23 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Rename/Bind.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/085bef68c7f3c222dea202b5c1fe7c2651ecfac0...439772a12f10a53ae243c9d5dc5027ae0674f3ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/085bef68c7f3c222dea202b5c1fe7c2651ecfac0...439772a12f10a53ae243c9d5dc5027ae0674f3ac You're receiving 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 Sep 16 06:16:30 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 02:16:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <632414be5e291_3b59a65152c16391b8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 458cfe73 by Matthew Pickering at 2022-09-16T02:15:47-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 - - - - - 5112fb71 by Cheng Shao at 2022-09-16T02:15:51-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - a802bf3c by Cheng Shao at 2022-09-16T02:15:51-04:00 hadrian: add late_ccs flavour transformer - - - - - 501d6716 by Cheng Shao at 2022-09-16T02:15:53-04:00 configure: remove unused program checks - - - - - 5f8e31e0 by Pierre Le Marre at 2022-09-16T02:15:56-04:00 Update to Unicode 15.0 - - - - - 060eda04 by Bodigrim at 2022-09-16T02:15:59-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 91e3de76 by Cheng Shao at 2022-09-16T02:16:00-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - fb0a14fe by Alexis King at 2022-09-16T02:16:02-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 23 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Rename/Bind.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/439772a12f10a53ae243c9d5dc5027ae0674f3ac...fb0a14fe6dcd7324f5c292ffcb180b629fdc8980 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/439772a12f10a53ae243c9d5dc5027ae0674f3ac...fb0a14fe6dcd7324f5c292ffcb180b629fdc8980 You're receiving 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 Sep 16 09:31:17 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 05:31:17 -0400 Subject: [Git][ghc/ghc][wip/andreask/ghci-tag-nullary] 91 commits: Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Message-ID: <632442659af9a_3b59a619d99194172343c@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ghci-tag-nullary at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 2fa23b2f by Andreas Klebinger at 2022-09-16T11:30:07+02: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 ------------------------- - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f3ccd63ddfbb784b126571702c34e74ef25dbbd4...2fa23b2f586351d5a488f48caceaa540ccd2b780 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f3ccd63ddfbb784b126571702c34e74ef25dbbd4...2fa23b2f586351d5a488f48caceaa540ccd2b780 You're receiving 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 Sep 16 09:37:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 05:37:02 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <632443bed7640_3b59a6539301725785@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8168ada7 by Matthew Pickering at 2022-09-16T05:36:22-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 - - - - - e119cb77 by Cheng Shao at 2022-09-16T05:36:24-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - a9dc679e by Cheng Shao at 2022-09-16T05:36:24-04:00 hadrian: add late_ccs flavour transformer - - - - - b0f18e9c by Cheng Shao at 2022-09-16T05:36:27-04:00 configure: remove unused program checks - - - - - 75c9598f by Pierre Le Marre at 2022-09-16T05:36:30-04:00 Update to Unicode 15.0 - - - - - 4bc423f2 by Bodigrim at 2022-09-16T05:36:33-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 4b993759 by Cheng Shao at 2022-09-16T05:36:35-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - cc2edced by Alexis King at 2022-09-16T05:36:37-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 23 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Rename/Bind.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb0a14fe6dcd7324f5c292ffcb180b629fdc8980...cc2edced40854e169bd55b04e21470e0bb447bb5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb0a14fe6dcd7324f5c292ffcb180b629fdc8980...cc2edced40854e169bd55b04e21470e0bb447bb5 You're receiving 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 Sep 16 09:40:39 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Fri, 16 Sep 2022 05:40:39 -0400 Subject: [Git][ghc/ghc][wip/t22057] 113 commits: Implement Response File support for HPC Message-ID: <632444972ea72_3b59a65183817454b@gitlab.mail> sheaf pushed to branch wip/t22057 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - dd1a50ab by Matthew Pickering at 2022-09-16T09:40:33+00: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 - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04f464f99533083d979641d1db496bd0fba22eb5...dd1a50abb15178406da892dd388418c768bf8251 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/04f464f99533083d979641d1db496bd0fba22eb5...dd1a50abb15178406da892dd388418c768bf8251 You're receiving 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 Sep 16 09:49:19 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Fri, 16 Sep 2022 05:49:19 -0400 Subject: [Git][ghc/ghc][wip/t22057] -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <6324469f56c15_3b59a6d8c860817461d0@gitlab.mail> sheaf pushed to branch wip/t22057 at Glasgow Haskell Compiler / GHC Commits: bf890a74 by Matthew Pickering at 2022-09-16T11:48:27+02: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 - - - - - 5 changed files: - compiler/GHC/Rename/Bind.hs - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [GHC-61367] [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [GHC-61367] [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf890a74a5b400a626f6ccad54b8551c30e2d4da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf890a74a5b400a626f6ccad54b8551c30e2d4da You're receiving 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 Sep 16 10:39:34 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 06:39:34 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-bindersof] 126 commits: typo Message-ID: <63245266201e4_3b59a6518381765019@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-bindersof at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 4d7cc04a by Andreas Klebinger at 2022-09-16T12:37:42+02:00 Avoid allocating intermediate lists for non recursive bindings. We give `Bind` a fold instance that performs better than converting to a list and folding over that instead. - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64456eb20a691536c97643a71dbdc0f099ba9f68...4d7cc04a83f13a524f434a9feed423d0a05b5973 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/64456eb20a691536c97643a71dbdc0f099ba9f68...4d7cc04a83f13a524f434a9feed423d0a05b5973 You're receiving 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 Sep 16 10:40:21 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 06:40:21 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-bindersof] Avoid allocating intermediate lists for non recursive bindings. Message-ID: <63245295bcd2d_3b59a6194ff95c17652d@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-bindersof at Glasgow Haskell Compiler / GHC Commits: f087b26f by Andreas Klebinger at 2022-09-16T12:39:07+02:00 Avoid allocating intermediate lists for non recursive bindings. We give `Bind` a fold instance that performs better than converting to a list and folding over that instead. Fixes #22196 - - - - - 8 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Types/Var/Env.hs Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -42,6 +42,7 @@ module GHC.Core ( -- ** Simple 'Expr' access functions and predicates bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts, + foldBindersOfBindsStrict, collectBinders, collectTyBinders, collectTyAndValBinders, collectNBinders, collectNValBinders_maybe, collectArgs, stripNArgs, collectArgsTicks, flattenBinds, @@ -120,6 +121,7 @@ import GHC.Utils.Panic.Plain import Data.Data hiding (TyCon) import Data.Int import Data.Word +import Data.Foldable (Foldable(..)) infixl 4 `mkApps`, `mkTyApps`, `mkVarApps`, `App`, `mkCoApps` -- Left associative, so that we can say (f `mkTyApps` xs `mkVarApps` ys) @@ -315,6 +317,26 @@ data Bind b = NonRec b (Expr b) | Rec [(b, (Expr b))] deriving Data +instance Foldable Bind where + -- We want these to inline if the function is given as argument, so that the function + -- arguments will be a known function call. + {-# INLINE foldr #-} + foldr f = \r bind -> case bind of + NonRec b _ -> f b r + Rec pairs -> foldr f r . map fst $ pairs + {-# INLINE foldl' #-} + foldl' f = \r bind -> case bind of + NonRec b _ -> f r b + Rec pairs -> foldl' f r . map fst $ pairs + {-# INLINE foldMap #-} + foldMap f = \bind -> case bind of + NonRec b _ -> f b + Rec pairs -> foldMap f . map fst $ pairs + {-# INLINE foldMap' #-} + foldMap' f = \bind -> case bind of + NonRec b _ -> f b + Rec pairs -> foldMap' f . map fst $ pairs + {- Note [Shadowing] ~~~~~~~~~~~~~~~~ @@ -1943,6 +1965,7 @@ exprToType _bad = pprPanic "exprToType" empty -} -- | Extract every variable by this group +-- {-# INLINEABLE bindersOf #-} bindersOf :: Bind b -> [b] -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] in GHC.Core.Lint @@ -1953,6 +1976,10 @@ bindersOf (Rec pairs) = [binder | (binder, _) <- pairs] bindersOfBinds :: [Bind b] -> [b] bindersOfBinds binds = foldr ((++) . bindersOf) [] binds +{-# INLINE foldBindersOfBindsStrict #-} +foldBindersOfBindsStrict :: (a -> b -> a) -> a -> [Bind b] -> a +foldBindersOfBindsStrict f = \z binds -> foldl' (foldl' f) z binds + rhssOfBind :: Bind b -> [Expr b] rhssOfBind (NonRec _ rhs) = [rhs] rhssOfBind (Rec pairs) = [rhs | (_,rhs) <- pairs] ===================================== compiler/GHC/Core/Opt/Exitify.hs ===================================== @@ -62,7 +62,7 @@ exitifyProgram binds = map goTopLvl binds goTopLvl (Rec pairs) = Rec (map (second (go in_scope_toplvl)) pairs) -- Top-level bindings are never join points - in_scope_toplvl = emptyInScopeSet `extendInScopeSetList` bindersOfBinds binds + in_scope_toplvl = emptyInScopeSet `extendInScopeSetBndrs` binds go :: InScopeSet -> CoreExpr -> CoreExpr go _ e@(Var{}) = e @@ -94,7 +94,7 @@ exitifyProgram binds = map goTopLvl binds | otherwise = Let (Rec pairs') body' where is_join_rec = any (isJoinId . fst) pairs - in_scope' = in_scope `extendInScopeSetList` bindersOf (Rec pairs) + in_scope' = in_scope `extendInScopeSetBind` (Rec pairs) pairs' = mapSnd (go in_scope') pairs body' = go in_scope' body ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -82,7 +82,7 @@ import GHC.Core.Utils ( exprType, exprIsHNF , exprOkForSpeculation , exprIsTopLevelBindable , collectMakeStaticArgs - , mkLamTypes + , mkLamTypes, extendInScopeSetBndrs ) import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, isOneShotBndr ) import GHC.Core.FVs -- all of it @@ -1566,7 +1566,7 @@ initialEnv float_lams binds , le_subst = mkEmptySubst in_scope_toplvl , le_env = emptyVarEnv } where - in_scope_toplvl = emptyInScopeSet `extendInScopeSetList` bindersOfBinds binds + in_scope_toplvl = emptyInScopeSet `extendInScopeSetBndrs` binds -- 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 ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -812,10 +812,6 @@ addJoinFloats floats join_floats , sfInScope = foldlOL extendInScopeSetBind (sfInScope floats) join_floats } -extendInScopeSetBind :: InScopeSet -> CoreBind -> InScopeSet -extendInScopeSetBind in_scope bind - = extendInScopeSetList in_scope (bindersOf bind) - addFloats :: SimplFloats -> SimplFloats -> SimplFloats -- Add both let-floats and join-floats for env2 to env1; -- *plus* the in-scope set for env2, which is bigger ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -949,8 +949,10 @@ initScEnv guts sc_vals = emptyVarEnv, sc_annotations = anns }) } where - init_subst = mkEmptySubst $ mkInScopeSet $ mkVarSet $ - bindersOfBinds (mg_binds guts) + init_subst = mkEmptySubst $ mkInScopeSet $ + foldBindersOfBindsStrict extendVarSet emptyVarSet (mg_binds guts) + -- mkVarSet $ + -- bindersOfBinds (mg_binds guts) -- Acccount for top-level bindings that are not in dependency order; -- see Note [Glomming] in GHC.Core.Opt.OccurAnal -- Easiest thing is to bring all the top level binders into scope at once, ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -601,8 +601,10 @@ specProgram guts@(ModGuts { mg_module = this_mod -- accidentally re-use a unique that's already in use -- Easiest thing is to do it all at once, as if all the top-level -- decls were mutually recursive - ; let top_env = SE { se_subst = Core.mkEmptySubst $ mkInScopeSetList $ - bindersOfBinds binds + ; let top_env = SE { se_subst = Core.mkEmptySubst $ + foldBindersOfBindsStrict (extendInScopeSet) emptyInScopeSet binds + -- mkInScopeSetList $ + -- bindersOfBinds binds , se_module = this_mod , se_dflags = dflags } ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -47,6 +47,9 @@ module GHC.Core.Utils ( stripTicksTop, stripTicksTopE, stripTicksTopT, stripTicksE, stripTicksT, + -- InScopeSet things that can't live elsewhere because of import loops. + extendInScopeSetBind, extendInScopeSetBndrs, + -- * StaticPtr collectMakeStaticArgs, @@ -2336,6 +2339,23 @@ normSplitTyConApp_maybe fam_envs ty = Just (tc, tc_args, co) normSplitTyConApp_maybe _ _ = Nothing +{- +***************************************************** +* +* InScopeSet things +* +***************************************************** +-} + +extendInScopeSetBind :: InScopeSet -> CoreBind -> InScopeSet +extendInScopeSetBind (InScope in_scope) binds + = InScope $ foldl' extendVarSet in_scope binds + +extendInScopeSetBndrs :: InScopeSet -> [CoreBind] -> InScopeSet +extendInScopeSetBndrs (InScope in_scope) binds + = InScope $ foldBindersOfBindsStrict extendVarSet in_scope binds + + {- ***************************************************** * ===================================== compiler/GHC/Types/Var/Env.hs ===================================== @@ -47,7 +47,7 @@ module GHC.Types.Var.Env ( anyDVarEnv, -- * The InScopeSet type - InScopeSet, + InScopeSet(..), -- ** Operations on InScopeSets emptyInScopeSet, mkInScopeSet, mkInScopeSetList, delInScopeSet, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f087b26ff0be00f3b47bb63d2350d3eb316a3516 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f087b26ff0be00f3b47bb63d2350d3eb316a3516 You're receiving 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 Sep 16 10:43:15 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 06:43:15 -0400 Subject: [Git][ghc/ghc][wip/andreask/perf-test-binary] Apply 1 suggestion(s) to 1 file(s) Message-ID: <6324534358838_3b59a65152c1767740@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/perf-test-binary at Glasgow Haskell Compiler / GHC Commits: b357a16d by Bryan R at 2022-09-16T10:43:13+00:00 Apply 1 suggestion(s) to 1 file(s) - - - - - 1 changed file: - testsuite/tests/perf/should_run/T21839.hs Changes: ===================================== testsuite/tests/perf/should_run/T21839.hs ===================================== @@ -8,7 +8,7 @@ -- In benchmarks I found the resulting code for the Binary instance was running -- more than twice as fast! -- So we decided to merely document this change and add a test representing this behaviour --- rather than trying to coax ghc back into it's old behaviour. +-- rather than trying to coax ghc back into its old behaviour. {-# LANGUAGE DeriveGeneric #-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b357a16db28474272d977c1f793821fd27dad047 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b357a16db28474272d977c1f793821fd27dad047 You're receiving 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 Sep 16 10:53:20 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Fri, 16 Sep 2022 06:53:20 -0400 Subject: [Git][ghc/ghc][wip/hadrian-ar-merge] Hadrian: merge archives even in stage 0 Message-ID: <632455a0a9688_3b59a620aecbec177222b@gitlab.mail> sheaf pushed to branch wip/hadrian-ar-merge at Glasgow Haskell Compiler / GHC Commits: 3c6c2809 by sheaf at 2022-09-16T12:51:58+02: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). - - - - - 3 changed files: - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Builders/Ar.hs Changes: ===================================== hadrian/cfg/system.config.in ===================================== @@ -39,10 +39,11 @@ python = @PythonCmd@ # Information about builders: #============================ -ar-supports-at-file = @ArSupportsAtFile@ -ar-supports-dash-l = @ArSupportsDashL@ -cc-llvm-backend = @CcLlvmBackend@ -hs-cpp-args = @HaskellCPPArgs@ +ar-supports-at-file = @ArSupportsAtFile@ +ar-supports-dash-l = @ArSupportsDashL@ +system-ar-supports-dash-l = @ArSupportsDashL_STAGE0@ +cc-llvm-backend = @CcLlvmBackend@ +hs-cpp-args = @HaskellCPPArgs@ # Build options: #=============== ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -5,7 +5,8 @@ module Oracles.Flag ( platformSupportsSharedLibs, platformSupportsGhciObjects, targetSupportsSMP, - useLibffiForAdjustors + useLibffiForAdjustors, + arSupportsDashL ) where import Hadrian.Oracles.TextFile @@ -16,6 +17,7 @@ import Oracles.Setting data Flag = ArSupportsAtFile | ArSupportsDashL + | SystemArSupportsDashL | CrossCompiling | CcLlvmBackend | GhcUnregisterised @@ -39,6 +41,7 @@ flag f = do let key = case f of ArSupportsAtFile -> "ar-supports-at-file" ArSupportsDashL -> "ar-supports-dash-l" + SystemArSupportsDashL-> "system-ar-supports-dash-l" CrossCompiling -> "cross-compiling" CcLlvmBackend -> "cc-llvm-backend" GhcUnregisterised -> "ghc-unregisterised" @@ -69,6 +72,10 @@ platformSupportsGhciObjects :: Action Bool platformSupportsGhciObjects = not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand +arSupportsDashL :: Stage -> Action Bool +arSupportsDashL (Stage0 {}) = flag SystemArSupportsDashL +arSupportsDashL _ = flag ArSupportsDashL + platformSupportsSharedLibs :: Action Bool platformSupportsSharedLibs = do windows <- isWinTarget ===================================== hadrian/src/Settings/Builders/Ar.hs ===================================== @@ -6,7 +6,9 @@ import Settings.Builders.Common -- want to place these in a response file. This is handled in -- 'Hadrian.Builder.Ar.runAr'. arBuilderArgs :: Args -arBuilderArgs = mconcat +arBuilderArgs = do + stage <- getStage + mconcat [ builder (Ar Pack) ? mconcat [ -- When building on platforms which don't support object merging -- we must use the -L flag supported by llvm-ar, which ensures that @@ -14,7 +16,7 @@ arBuilderArgs = mconcat -- not added as a single file. This requires that we are using llvm-ar -- -- See Note [Object merging] in GHC.Driver.Pipeline.Execute for details. - ifM ((&&) <$> notStage0 <*> expr (flag ArSupportsDashL)) (arg "qL") (arg "q") + ifM (expr $ arSupportsDashL stage) (arg "qL") (arg "q") , arg =<< getOutput ] , builder (Ar Unpack) ? mconcat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c6c28096a59fddf467fb37cccf1239220197435 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c6c28096a59fddf467fb37cccf1239220197435 You're receiving 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 Sep 16 10:54:16 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Fri, 16 Sep 2022 06:54:16 -0400 Subject: [Git][ghc/ghc][wip/hadrian-ar-merge] Hadrian: merge archives even in stage 0 Message-ID: <632455d8deaec_3b59a6194ffb50177276@gitlab.mail> sheaf pushed to branch wip/hadrian-ar-merge at Glasgow Haskell Compiler / GHC Commits: 323cf052 by sheaf at 2022-09-16T12:54:09+02: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). - - - - - 4 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Builders/Ar.hs Changes: ===================================== configure.ac ===================================== @@ -201,6 +201,7 @@ if test "$WithGhc" != ""; then fi BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsDashL_STAGE0],[ar supports -L]) BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP]) BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) ===================================== hadrian/cfg/system.config.in ===================================== @@ -39,10 +39,11 @@ python = @PythonCmd@ # Information about builders: #============================ -ar-supports-at-file = @ArSupportsAtFile@ -ar-supports-dash-l = @ArSupportsDashL@ -cc-llvm-backend = @CcLlvmBackend@ -hs-cpp-args = @HaskellCPPArgs@ +ar-supports-at-file = @ArSupportsAtFile@ +ar-supports-dash-l = @ArSupportsDashL@ +system-ar-supports-dash-l = @ArSupportsDashL_STAGE0@ +cc-llvm-backend = @CcLlvmBackend@ +hs-cpp-args = @HaskellCPPArgs@ # Build options: #=============== ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -5,7 +5,8 @@ module Oracles.Flag ( platformSupportsSharedLibs, platformSupportsGhciObjects, targetSupportsSMP, - useLibffiForAdjustors + useLibffiForAdjustors, + arSupportsDashL ) where import Hadrian.Oracles.TextFile @@ -16,6 +17,7 @@ import Oracles.Setting data Flag = ArSupportsAtFile | ArSupportsDashL + | SystemArSupportsDashL | CrossCompiling | CcLlvmBackend | GhcUnregisterised @@ -39,6 +41,7 @@ flag f = do let key = case f of ArSupportsAtFile -> "ar-supports-at-file" ArSupportsDashL -> "ar-supports-dash-l" + SystemArSupportsDashL-> "system-ar-supports-dash-l" CrossCompiling -> "cross-compiling" CcLlvmBackend -> "cc-llvm-backend" GhcUnregisterised -> "ghc-unregisterised" @@ -69,6 +72,10 @@ platformSupportsGhciObjects :: Action Bool platformSupportsGhciObjects = not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand +arSupportsDashL :: Stage -> Action Bool +arSupportsDashL (Stage0 {}) = flag SystemArSupportsDashL +arSupportsDashL _ = flag ArSupportsDashL + platformSupportsSharedLibs :: Action Bool platformSupportsSharedLibs = do windows <- isWinTarget ===================================== hadrian/src/Settings/Builders/Ar.hs ===================================== @@ -6,7 +6,9 @@ import Settings.Builders.Common -- want to place these in a response file. This is handled in -- 'Hadrian.Builder.Ar.runAr'. arBuilderArgs :: Args -arBuilderArgs = mconcat +arBuilderArgs = do + stage <- getStage + mconcat [ builder (Ar Pack) ? mconcat [ -- When building on platforms which don't support object merging -- we must use the -L flag supported by llvm-ar, which ensures that @@ -14,7 +16,7 @@ arBuilderArgs = mconcat -- not added as a single file. This requires that we are using llvm-ar -- -- See Note [Object merging] in GHC.Driver.Pipeline.Execute for details. - ifM ((&&) <$> notStage0 <*> expr (flag ArSupportsDashL)) (arg "qL") (arg "q") + ifM (expr $ arSupportsDashL stage) (arg "qL") (arg "q") , arg =<< getOutput ] , builder (Ar Unpack) ? mconcat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/323cf052731fe55f6f124e0ffdb7cf9be6f205cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/323cf052731fe55f6f124e0ffdb7cf9be6f205cf You're receiving 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 Sep 16 11:06:03 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 07:06:03 -0400 Subject: [Git][ghc/ghc][wip/andreask/perf-test-binary] 195 commits: testsuite: Correctly set withNativeCodeGen Message-ID: <6324589b99bb0_3b59a65152c17791d5@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/perf-test-binary at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - aebfa2dd by Andreas Klebinger at 2022-09-16T13:04:49+02: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. - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/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/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b357a16db28474272d977c1f793821fd27dad047...aebfa2dd4e41d0fd3dc89e33781f9b845cbaa522 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b357a16db28474272d977c1f793821fd27dad047...aebfa2dd4e41d0fd3dc89e33781f9b845cbaa522 You're receiving 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 Sep 16 12:07:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 08:07:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: hadrian: enable -fprof-late only for profiling ways Message-ID: <632467087fc23_3b59a6d8c860818106d9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7a0380ae by Cheng Shao at 2022-09-16T08:06:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - 65529183 by Cheng Shao at 2022-09-16T08:06:56-04:00 hadrian: add late_ccs flavour transformer - - - - - 7a371ef2 by Cheng Shao at 2022-09-16T08:06:59-04:00 configure: remove unused program checks - - - - - f07fce6a by Pierre Le Marre at 2022-09-16T08:07:02-04:00 Update to Unicode 15.0 - - - - - b7a03077 by Bodigrim at 2022-09-16T08:07:05-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 52589b2b by Cheng Shao at 2022-09-16T08:07:07-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - 6ac52576 by Alexis King at 2022-09-16T08:07:09-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 18 changed files: - compiler/GHC/Builtin/primops.txt.pp - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc2edced40854e169bd55b04e21470e0bb447bb5...6ac525764bf1fa4fadd51f9c81cdeb45fa90f859 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc2edced40854e169bd55b04e21470e0bb447bb5...6ac525764bf1fa4fadd51f9c81cdeb45fa90f859 You're receiving 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 Sep 16 12:39:09 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 08:39:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/testsuite-tntc Message-ID: <63246e6dbeffc_3b59a6194ff95c1823975@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/testsuite-tntc at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/testsuite-tntc You're receiving 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 Sep 16 13:34:34 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 16 Sep 2022 09:34:34 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/class-layout-info Message-ID: <63247b6ab8f2e_3b59a65152c1841744@gitlab.mail> Vladislav Zavialov pushed new branch wip/class-layout-info at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/class-layout-info You're receiving 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 Sep 16 14:06:11 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 16 Sep 2022 10:06:11 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/stgLintFix Message-ID: <632482d3ee6cf_3b59a619d991941846273@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/stgLintFix You're receiving 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 Sep 16 14:32:56 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 16 Sep 2022 10:32:56 -0400 Subject: [Git][ghc/ghc][wip/class-layout-info] Remove unused imports Message-ID: <63248918dbba1_3b59a620aecc14186293a@gitlab.mail> Vladislav Zavialov pushed to branch wip/class-layout-info at Glasgow Haskell Compiler / GHC Commits: a48d9b05 by Vladislav Zavialov at 2022-09-16T17:32:51+03:00 Remove unused imports - - - - - 4 changed files: - compiler/Language/Haskell/Syntax/Concrete.hs - compiler/Language/Haskell/Syntax/Decls.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs Changes: ===================================== compiler/Language/Haskell/Syntax/Concrete.hs ===================================== @@ -13,7 +13,7 @@ module Language.Haskell.Syntax.Concrete ) where import GHC.Prelude -import GHC.TypeLits (Symbol, KnownSymbol, symbolVal) +import GHC.TypeLits (Symbol, KnownSymbol) import Data.Data import Language.Haskell.Syntax.Extension ===================================== compiler/Language/Haskell/Syntax/Decls.hs ===================================== @@ -97,7 +97,6 @@ import Language.Haskell.Syntax.Binds import Language.Haskell.Syntax.Concrete import Language.Haskell.Syntax.Extension import Language.Haskell.Syntax.Type -import Language.Haskell.Syntax.Extension import Language.Haskell.Syntax.Basic (Role) import GHC.Types.Basic (TopLevelFlag, OverlapMode, RuleName, Activation) ===================================== compiler/Language/Haskell/Syntax/Extension.hs ===================================== @@ -22,8 +22,6 @@ module Language.Haskell.Syntax.Extension where -- This module captures the type families to precisely identify the extension -- points for GHC.Hs syntax -import GHC.TypeLits (Symbol, KnownSymbol) - #if MIN_VERSION_GLASGOW_HASKELL(9,3,0,0) import Data.Type.Equality (type (~)) #endif ===================================== compiler/Language/Haskell/Syntax/Pat.hs ===================================== @@ -38,7 +38,6 @@ import Language.Haskell.Syntax.Basic import Language.Haskell.Syntax.Lit import Language.Haskell.Syntax.Concrete import Language.Haskell.Syntax.Extension -import Language.Haskell.Syntax.Lit import Language.Haskell.Syntax.Type -- libraries: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a48d9b05c5a86eac2b55469b9889533040d0ea0f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a48d9b05c5a86eac2b55469b9889533040d0ea0f You're receiving 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 Sep 16 15:10:38 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 16 Sep 2022 11:10:38 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: Fix Driver missing type signature warnings Message-ID: <632491ee87db3_3b59a619d9919418702e0@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 0c7be294 by doyougnu at 2022-09-16T11:10:17-04:00 Fix Driver missing type signature warnings - - - - - 8512800f by doyougnu at 2022-09-16T11:10:17-04:00 PipeLine.Execute: silence warnings on JS backend - - - - - 5519d574 by doyougnu at 2022-09-16T11:10:18-04:00 JS.Primops: Add Bit reverse ops - - - - - 4 changed files: - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/StgToJS/Prim.hs - rts/js/arith.js Changes: ===================================== compiler/GHC/Driver/Phases.hs ===================================== @@ -265,7 +265,7 @@ dynlib_suffixes platform = case platformOS platform of _ -> ["so"] isHaskellishSuffix, isBackpackishSuffix, isHaskellSrcSuffix, isCishSuffix, - isHaskellUserSrcSuffix, isHaskellSigSuffix + isHaskellUserSrcSuffix, isJsSuffix, isHaskellSigSuffix :: String -> Bool isHaskellishSuffix s = s `elem` haskellish_suffixes isBackpackishSuffix s = s `elem` backpackish_suffixes ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -131,7 +131,7 @@ runPhase (T_CmmCpp pipe_env hsc_env input_fn) = do input_fn output_fn return output_fn runPhase (T_Js pipe_env hsc_env mb_location js_src) = do - out_path <- phaseOutputFilenameNew StopLn pipe_env hsc_env Nothing + _out_path <- phaseOutputFilenameNew StopLn pipe_env hsc_env Nothing runJsPhase pipe_env hsc_env mb_location js_src runPhase (T_Cmm pipe_env hsc_env input_fn) = do let dflags = hsc_dflags hsc_env @@ -349,12 +349,11 @@ runAsPhase with_cpp pipe_env hsc_env location input_fn = do runJsPhase :: PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> IO FilePath -runJsPhase pipe_env hsc_env location input_fn = do +runJsPhase pipe_env hsc_env _location input_fn = do let dflags = hsc_dflags hsc_env let logger = hsc_logger hsc_env let tmpfs = hsc_tmpfs hsc_env let unit_env = hsc_unit_env hsc_env - let platform = ue_platform unit_env -- the header lets the linker recognize processed JavaScript files let header = "//JavaScript\n" @@ -383,7 +382,7 @@ runJsPhase pipe_env hsc_env location input_fn = do return output_fn jsFileNeedsCpp :: HscEnv -> FilePath -> IO Bool -jsFileNeedsCpp hsc_env fn = do +jsFileNeedsCpp _hsc_env fn = do opts <- JSHeader.getOptionsFromJsFile fn pure (JSHeader.CPP `elem` opts) ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -436,23 +436,31 @@ genPrim prof ty op = case op of BSwap64Op -> \[r1,r2] [x,y] -> PrimInline $ appT [r1,r2] "h$bswap64" [x,y] BSwapOp -> \[r] [x] -> genPrim prof ty BSwap32Op [r] [x] + BRevOp -> \[r] [w] -> genPrim prof ty BRev32Op [r] [w] + BRev8Op -> \[r] [w] -> PrimInline $ r |= (app "h$reverseWord" [w] .>>>. 24) + BRev16Op -> \[r] [w] -> PrimInline $ r |= (app "h$reverseWord" [w] .>>>. 16) + BRev32Op -> \[r] [w] -> PrimInline $ r |= app "h$reverseWord" [w] + BRev64Op -> \[rh,rl] [h,l] -> PrimInline $ mconcat [ rl |= app "h$reverseWord" [h] + , rh |= app "h$reverseWord" [l] + ] + ------------------------------ Narrow ------------------------------------------- - Narrow8IntOp -> \[r] [x] -> PrimInline $ r |= (BAnd x (Int 0x7F)) `Sub` (BAnd x (Int 0x80)) + Narrow8IntOp -> \[r] [x] -> PrimInline $ r |= (BAnd x (Int 0x7F )) `Sub` (BAnd x (Int 0x80)) Narrow16IntOp -> \[r] [x] -> PrimInline $ r |= (BAnd x (Int 0x7FFF)) `Sub` (BAnd x (Int 0x8000)) - Narrow32IntOp -> \[r] [x] -> PrimInline $ r |= i32 x - Narrow8WordOp -> \[r] [x] -> PrimInline $ r |= mask8 x + Narrow32IntOp -> \[r] [x] -> PrimInline $ r |= i32 x + Narrow8WordOp -> \[r] [x] -> PrimInline $ r |= mask8 x Narrow16WordOp -> \[r] [x] -> PrimInline $ r |= mask16 x - Narrow32WordOp -> \[r] [x] -> PrimInline $ r |= u32 x + Narrow32WordOp -> \[r] [x] -> PrimInline $ r |= u32 x ------------------------------ Double ------------------------------------------- - DoubleGtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>. y) - DoubleGeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>=. y) + DoubleGtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>. y) + DoubleGeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>=. y) DoubleEqOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .===. y) DoubleNeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .!==. y) - DoubleLtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<. y) - DoubleLeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<=. y) + DoubleLtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<. y) + DoubleLeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<=. y) DoubleAddOp -> \[r] [x,y] -> PrimInline $ r |= Add x y DoubleSubOp -> \[r] [x,y] -> PrimInline $ r |= Sub x y DoubleMulOp -> \[r] [x,y] -> PrimInline $ r |= Mul x y @@ -461,12 +469,12 @@ genPrim prof ty op = case op of DoubleFabsOp -> \[r] [x] -> PrimInline $ r |= math_abs [x] DoubleToIntOp -> \[r] [x] -> PrimInline $ r |= i32 x DoubleToFloatOp -> \[r] [x] -> PrimInline $ r |= app "h$fround" [x] - DoubleExpOp -> \[r] [x] -> PrimInline $ r |= math_exp [x] - DoubleLogOp -> \[r] [x] -> PrimInline $ r |= math_log [x] + DoubleExpOp -> \[r] [x] -> PrimInline $ r |= math_exp [x] + DoubleLogOp -> \[r] [x] -> PrimInline $ r |= math_log [x] DoubleSqrtOp -> \[r] [x] -> PrimInline $ r |= math_sqrt [x] - DoubleSinOp -> \[r] [x] -> PrimInline $ r |= math_sin [x] - DoubleCosOp -> \[r] [x] -> PrimInline $ r |= math_cos [x] - DoubleTanOp -> \[r] [x] -> PrimInline $ r |= math_tan [x] + DoubleSinOp -> \[r] [x] -> PrimInline $ r |= math_sin [x] + DoubleCosOp -> \[r] [x] -> PrimInline $ r |= math_cos [x] + DoubleTanOp -> \[r] [x] -> PrimInline $ r |= math_tan [x] DoubleAsinOp -> \[r] [x] -> PrimInline $ r |= math_asin [x] DoubleAcosOp -> \[r] [x] -> PrimInline $ r |= math_acos [x] DoubleAtanOp -> \[r] [x] -> PrimInline $ r |= math_atan [x] @@ -482,12 +490,12 @@ genPrim prof ty op = case op of ------------------------------ Float -------------------------------------------- - FloatGtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>. y) - FloatGeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>=. y) + FloatGtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>. y) + FloatGeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .>=. y) FloatEqOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .===. y) FloatNeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .!==. y) - FloatLtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<. y) - FloatLeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<=. y) + FloatLtOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<. y) + FloatLeOp -> \[r] [x,y] -> PrimInline $ r |= if10 (x .<=. y) FloatAddOp -> \[r] [x,y] -> PrimInline $ r |= Add x y FloatSubOp -> \[r] [x,y] -> PrimInline $ r |= Sub x y FloatMulOp -> \[r] [x,y] -> PrimInline $ r |= Mul x y @@ -1021,12 +1029,6 @@ genPrim prof ty op = case op of ------------------------------ Unhandled primops ------------------- - BRevOp -> unhandledPrimop op - BRev8Op -> unhandledPrimop op - BRev16Op -> unhandledPrimop op - BRev32Op -> unhandledPrimop op - BRev64Op -> unhandledPrimop op - DoubleExpM1Op -> unhandledPrimop op DoubleLog1POp -> unhandledPrimop op FloatExpM1Op -> unhandledPrimop op ===================================== rts/js/arith.js ===================================== @@ -507,6 +507,24 @@ function h$popCnt64(x1,x2) { h$popCntTab[(x2>>>24)&0xFF]; } +function h$reverseWord(w) { + /* Reverse the bits in a 32-bit word this trick comes from + * https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel This + * method should use a bit more memory than other methods, but we choose it + * because it does not rely on any 64bit multiplication or look up tables. + * Note that this could be expressed in the Haskell EDSL, but we choose to not + * do that for improved sharing in the JIT. Should be O(lg n) + */ + var r = w; + r = ((r >>> 1) & 0x55555555) | ((r & 0x55555555) << 1); // swap odd and even bits + r = ((r >>> 2) & 0x33333333) | ((r & 0x33333333) << 2); // swap consecutive pairs + r = ((r >>> 4) & 0x0F0F0F0F) | ((r & 0x0F0F0F0F) << 4); // swap nibbles + r = ((r >>> 8) & 0x00FF00FF) | ((r & 0x00FF00FF) << 8); // swap bytes + r = ( r >>> 16 ) | ( r << 16); // swap 2-byte long pairs + r = r >>> 0; // ensure w is unsigned + return r; +} + function h$bswap64(x1,x2) { RETURN_UBX_TUP2(UN((x2 >>> 24) | (x2 << 24) | ((x2 & 0xFF00) << 8) | ((x2 & 0xFF0000) >> 8)) ,UN((x1 >>> 24) | (x1 << 24) | ((x1 & 0xFF00) << 8) | ((x1 & 0xFF0000) >> 8))); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/be469255d19351212aa0b5cc6cf97534b743f47f...5519d574c0b3bed51fb01671de01302925c1240e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/be469255d19351212aa0b5cc6cf97534b743f47f...5519d574c0b3bed51fb01671de01302925c1240e You're receiving 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 Sep 16 17:02:07 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 16 Sep 2022 13:02:07 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/op-ws-value Message-ID: <6324ac0f14447_3b59a6194ffb50188545a@gitlab.mail> Vladislav Zavialov pushed new branch wip/op-ws-value at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/op-ws-value You're receiving 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 Sep 16 17:57:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 13:57:36 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <6324b91057c76_3b59a65152c189786e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 4 changed files: - compiler/GHC/Stg/InferTags/Rewrite.hs - testsuite/tests/simplStg/should_compile/all.T - + testsuite/tests/simplStg/should_compile/inferTags002.hs - + testsuite/tests/simplStg/should_compile/inferTags002.stderr Changes: ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -128,7 +128,7 @@ getMap :: RM (UniqFM Id TagSig) getMap = RM $ ((\(fst,_,_,_) -> fst) <$> get) setMap :: (UniqFM Id TagSig) -> RM () -setMap m = RM $ do +setMap !m = RM $ do (_,us,mod,lcls) <- get put (m, us,mod,lcls) @@ -139,7 +139,7 @@ getFVs :: RM IdSet getFVs = RM $ ((\(_,_,_,lcls) -> lcls) <$> get) setFVs :: IdSet -> RM () -setFVs fvs = RM $ do +setFVs !fvs = RM $ do (tag_map,us,mod,_lcls) <- get put (tag_map, us,mod,fvs) @@ -195,9 +195,9 @@ withBinders NotTopLevel sigs cont = do withClosureLcls :: DIdSet -> RM a -> RM a withClosureLcls fvs act = do old_fvs <- getFVs - let fvs' = nonDetStrictFoldDVarSet (flip extendVarSet) old_fvs fvs + let !fvs' = nonDetStrictFoldDVarSet (flip extendVarSet) old_fvs fvs setFVs fvs' - r <- act + !r <- act setFVs old_fvs return r @@ -206,9 +206,9 @@ withClosureLcls fvs act = do withLcl :: Id -> RM a -> RM a withLcl fv act = do old_fvs <- getFVs - let fvs' = extendVarSet old_fvs fv + let !fvs' = extendVarSet old_fvs fv setFVs fvs' - r <- act + !r <- act setFVs old_fvs return r @@ -222,7 +222,7 @@ isTagged v = do | otherwise -> do -- Local binding !s <- getMap let !sig = lookupWithDefaultUFM s (pprPanic "unknown Id:" (ppr v)) v - return $ case sig of + return $! case sig of TagSig info -> case info of TagDunno -> False @@ -234,7 +234,7 @@ isTagged v = do , isNullaryRepDataCon con -> return True | Just lf_info <- idLFInfo_maybe v - -> return $ + -> return $! -- Can we treat the thing as tagged based on it's LFInfo? case lf_info of -- Function, applied not entered. @@ -336,7 +336,7 @@ rewriteRhs (_id, _tagSig) (StgRhsCon ccs con cn ticks args) = {-# SCC rewriteRhs rewriteRhs _binding (StgRhsClosure fvs ccs flag args body) = do withBinders NotTopLevel args $ withClosureLcls fvs $ - StgRhsClosure fvs ccs flag (map fst args) <$> rewriteExpr False body + StgRhsClosure fvs ccs flag (map fst args) <$> rewriteExpr body -- return (closure) fvArgs :: [StgArg] -> RM DVarSet @@ -345,40 +345,36 @@ fvArgs args = do -- pprTraceM "fvArgs" (text "args:" <> ppr args $$ text "lcls:" <> pprVarSet (fv_lcls) (braces . fsep . map ppr) ) return $ mkDVarSet [ v | StgVarArg v <- args, elemVarSet v fv_lcls] -type IsScrut = Bool - rewriteArgs :: [StgArg] -> RM [StgArg] rewriteArgs = mapM rewriteArg rewriteArg :: StgArg -> RM StgArg rewriteArg (StgVarArg v) = StgVarArg <$!> rewriteId v rewriteArg (lit at StgLitArg{}) = return lit --- Attach a tagSig if it's tagged rewriteId :: Id -> RM Id rewriteId v = do - is_tagged <- isTagged v + !is_tagged <- isTagged v if is_tagged then return $! setIdTagSig v (TagSig TagProper) else return v -rewriteExpr :: IsScrut -> InferStgExpr -> RM TgStgExpr -rewriteExpr _ (e at StgCase {}) = rewriteCase e -rewriteExpr _ (e at StgLet {}) = rewriteLet e -rewriteExpr _ (e at StgLetNoEscape {}) = rewriteLetNoEscape e -rewriteExpr isScrut (StgTick t e) = StgTick t <$!> rewriteExpr isScrut e -rewriteExpr _ e@(StgConApp {}) = rewriteConApp e - -rewriteExpr isScrut e@(StgApp {}) = rewriteApp isScrut e -rewriteExpr _ (StgLit lit) = return $! (StgLit lit) -rewriteExpr _ (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do +rewriteExpr :: InferStgExpr -> RM TgStgExpr +rewriteExpr (e at StgCase {}) = rewriteCase e +rewriteExpr (e at StgLet {}) = rewriteLet e +rewriteExpr (e at StgLetNoEscape {}) = rewriteLetNoEscape e +rewriteExpr (StgTick t e) = StgTick t <$!> rewriteExpr e +rewriteExpr e@(StgConApp {}) = rewriteConApp e +rewriteExpr e@(StgApp {}) = rewriteApp e +rewriteExpr (StgLit lit) = return $! (StgLit lit) +rewriteExpr (StgOpApp op@(StgPrimOp DataToTagOp) args res_ty) = do (StgOpApp op) <$!> rewriteArgs args <*> pure res_ty -rewriteExpr _ (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty) +rewriteExpr (StgOpApp op args res_ty) = return $! (StgOpApp op args res_ty) rewriteCase :: InferStgExpr -> RM TgStgExpr rewriteCase (StgCase scrut bndr alt_type alts) = withBinder NotTopLevel bndr $ pure StgCase <*> - rewriteExpr True scrut <*> + rewriteExpr scrut <*> pure (fst bndr) <*> pure alt_type <*> mapM rewriteAlt alts @@ -388,7 +384,7 @@ rewriteCase _ = panic "Impossible: nodeCase" rewriteAlt :: InferStgAlt -> RM TgStgAlt rewriteAlt alt at GenStgAlt{alt_con=_, alt_bndrs=bndrs, alt_rhs=rhs} = withBinders NotTopLevel bndrs $ do - !rhs' <- rewriteExpr False rhs + !rhs' <- rewriteExpr rhs return $! alt {alt_bndrs = map fst bndrs, alt_rhs = rhs'} rewriteLet :: InferStgExpr -> RM TgStgExpr @@ -396,7 +392,7 @@ rewriteLet (StgLet xt bind expr) = do (!bind') <- rewriteBinds NotTopLevel bind withBind NotTopLevel bind $ do -- pprTraceM "withBindLet" (ppr $ bindersOfX bind) - !expr' <- rewriteExpr False expr + !expr' <- rewriteExpr expr return $! (StgLet xt bind' expr') rewriteLet _ = panic "Impossible" @@ -404,7 +400,7 @@ rewriteLetNoEscape :: InferStgExpr -> RM TgStgExpr rewriteLetNoEscape (StgLetNoEscape xt bind expr) = do (!bind') <- rewriteBinds NotTopLevel bind withBind NotTopLevel bind $ do - !expr' <- rewriteExpr False expr + !expr' <- rewriteExpr expr return $! (StgLetNoEscape xt bind' expr') rewriteLetNoEscape _ = panic "Impossible" @@ -424,19 +420,12 @@ rewriteConApp (StgConApp con cn args tys) = do rewriteConApp _ = panic "Impossible" --- Special case: Expressions like `case x of { ... }` -rewriteApp :: IsScrut -> InferStgExpr -> RM TgStgExpr -rewriteApp True (StgApp f []) = do - -- pprTraceM "rewriteAppScrut" (ppr f) - f_tagged <- isTagged f - -- isTagged looks at more than the result of our analysis. - -- So always update here if useful. - let f' = if f_tagged - -- TODO: We might consisder using a subst env instead of setting the sig only for select places. - then setIdTagSig f (TagSig TagProper) - else f +-- Special case: Atomic binders, usually in a case context like `case f of ...`. +rewriteApp :: InferStgExpr -> RM TgStgExpr +rewriteApp (StgApp f []) = do + f' <- rewriteId f return $! StgApp f' [] -rewriteApp _ (StgApp f args) +rewriteApp (StgApp f args) -- pprTrace "rewriteAppOther" (ppr f <+> ppr args) False -- = undefined | Just marks <- idCbvMarks_maybe f @@ -457,8 +446,8 @@ rewriteApp _ (StgApp f args) cbvArgIds = [x | StgVarArg x <- map fstOf3 cbvArgInfo] :: [Id] mkSeqs args cbvArgIds (\cbv_args -> StgApp f cbv_args) -rewriteApp _ (StgApp f args) = return $ StgApp f args -rewriteApp _ _ = panic "Impossible" +rewriteApp (StgApp f args) = return $ StgApp f args +rewriteApp _ = panic "Impossible" -- `mkSeq` x x' e generates `case x of x' -> e` -- We could also substitute x' for x in e but that's so rarely beneficial ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -11,3 +11,4 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) +test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) ===================================== testsuite/tests/simplStg/should_compile/inferTags002.hs ===================================== @@ -0,0 +1,7 @@ +module M where + +data T a = MkT !Bool !a + +-- The rhs of the case alternative should not result in a call std_ap_0_fast. +f x = case x of + MkT y z -> z ===================================== testsuite/tests/simplStg/should_compile/inferTags002.stderr ===================================== @@ -0,0 +1,171 @@ + +==================== Output Cmm ==================== +[M.$WMkT_entry() { // [R3, R2] + { info_tbls: [(cym, + label: block_cym_info + rep: StackRep [False] + srt: Nothing), + (cyp, + label: M.$WMkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cys, + label: block_cys_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cyp: // global + if ((Sp + -16) < SpLim) (likely: False) goto cyv; else goto cyw; + cyv: // global + R1 = M.$WMkT_closure; + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; + cyw: // global + I64[Sp - 16] = cym; + R1 = R2; + P64[Sp - 8] = R3; + Sp = Sp - 16; + if (R1 & 7 != 0) goto cym; else goto cyn; + cyn: // global + call (I64[R1])(R1) returns to cym, args: 8, res: 8, upd: 8; + cym: // global + I64[Sp] = cys; + _sy8::P64 = R1; + R1 = P64[Sp + 8]; + P64[Sp + 8] = _sy8::P64; + call stg_ap_0_fast(R1) returns to cys, args: 8, res: 8, upd: 8; + cys: // global + Hp = Hp + 24; + if (Hp > HpLim) (likely: False) goto cyA; else goto cyz; + cyA: // global + HpAlloc = 24; + call stg_gc_unpt_r1(R1) returns to cys, args: 8, res: 8, upd: 8; + cyz: // global + I64[Hp - 16] = M.MkT_con_info; + P64[Hp - 8] = P64[Sp + 8]; + P64[Hp] = R1; + R1 = Hp - 15; + Sp = Sp + 16; + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; + } + }, + section ""data" . M.$WMkT_closure" { + M.$WMkT_closure: + const M.$WMkT_info; + }] + + + +==================== Output Cmm ==================== +[M.f_entry() { // [R2] + { info_tbls: [(cyK, + label: block_cyK_info + rep: StackRep [] + srt: Nothing), + (cyN, + label: M.f_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cyN: // global + if ((Sp + -8) < SpLim) (likely: False) goto cyO; else goto cyP; + cyO: // global + R1 = M.f_closure; + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; + cyP: // global + I64[Sp - 8] = cyK; + R1 = R2; + Sp = Sp - 8; + if (R1 & 7 != 0) goto cyK; else goto cyL; + cyL: // global + call (I64[R1])(R1) returns to cyK, args: 8, res: 8, upd: 8; + cyK: // global + R1 = P64[R1 + 15]; + Sp = Sp + 8; + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; + } + }, + section ""data" . M.f_closure" { + M.f_closure: + const M.f_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_entry() { // [R3, R2] + { info_tbls: [(cz1, + label: block_cz1_info + rep: StackRep [False] + srt: Nothing), + (cz4, + label: M.MkT_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Nothing), + (cz7, + label: block_cz7_info + rep: StackRep [False] + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + cz4: // global + if ((Sp + -16) < SpLim) (likely: False) goto cza; else goto czb; + cza: // global + R1 = M.MkT_closure; + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; + czb: // global + I64[Sp - 16] = cz1; + R1 = R2; + P64[Sp - 8] = R3; + Sp = Sp - 16; + if (R1 & 7 != 0) goto cz1; else goto cz2; + cz2: // global + call (I64[R1])(R1) returns to cz1, args: 8, res: 8, upd: 8; + cz1: // global + I64[Sp] = cz7; + _tyf::P64 = R1; + R1 = P64[Sp + 8]; + P64[Sp + 8] = _tyf::P64; + call stg_ap_0_fast(R1) returns to cz7, args: 8, res: 8, upd: 8; + cz7: // global + Hp = Hp + 24; + if (Hp > HpLim) (likely: False) goto czf; else goto cze; + czf: // global + HpAlloc = 24; + call stg_gc_unpt_r1(R1) returns to cz7, args: 8, res: 8, upd: 8; + cze: // global + I64[Hp - 16] = M.MkT_con_info; + P64[Hp - 8] = P64[Sp + 8]; + P64[Hp] = R1; + R1 = Hp - 15; + Sp = Sp + 16; + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; + } + }, + section ""data" . M.MkT_closure" { + M.MkT_closure: + const M.MkT_info; + }] + + + +==================== Output Cmm ==================== +[M.MkT_con_entry() { // [] + { info_tbls: [(czl, + label: M.MkT_con_info + rep: HeapRep 2 ptrs { Con {tag: 0 descr:"main:M.MkT"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + czl: // global + R1 = R1 + 1; + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; + } + }] + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df04d6ec6a543d8bf1b953cf27c26e63ec6aab25...7cce70073f5017cf5514f92a900c76e47a4292a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/df04d6ec6a543d8bf1b953cf27c26e63ec6aab25...7cce70073f5017cf5514f92a900c76e47a4292a5 You're receiving 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 Sep 16 17:58:24 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 13:58:24 -0400 Subject: [Git][ghc/ghc][master] 2 commits: hadrian: enable -fprof-late only for profiling ways Message-ID: <6324b940d8f51_3b59a6194ff95c1901314@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 1 changed file: - hadrian/src/Flavour.hs Changes: ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7cce70073f5017cf5514f92a900c76e47a4292a5...d7235831724dffdc203b8d87bb4d376546eeb883 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7cce70073f5017cf5514f92a900c76e47a4292a5...d7235831724dffdc203b8d87bb4d376546eeb883 You're receiving 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 Sep 16 17:58:48 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 13:58:48 -0400 Subject: [Git][ghc/ghc][master] configure: remove unused program checks Message-ID: <6324b958215ab_3b59a6d8c860819047f1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce203753a88406cba95278506bba1b4e6ef169c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce203753a88406cba95278506bba1b4e6ef169c6 You're receiving 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 Sep 16 17:59:34 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 13:59:34 -0400 Subject: [Git][ghc/ghc][master] Update to Unicode 15.0 Message-ID: <6324b9865fd1c_3b59a6539301908340@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - 11 changed files: - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version Changes: ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b4c1056580df029865346ffcf1aa2fca85cdddc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b4c1056580df029865346ffcf1aa2fca85cdddc You're receiving 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 Sep 16 18:00:18 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 14:00:18 -0400 Subject: [Git][ghc/ghc][master] Avoid partial head and tail in ghc-heap; replace with total pattern-matching Message-ID: <6324b9b29cd87_3b59a6518381911950@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 2 changed files: - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6e9b89a8ad9bd155748fe177a23c8f4919d308f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6e9b89a8ad9bd155748fe177a23c8f4919d308f You're receiving 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 Sep 16 18:00:46 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 14:00:46 -0400 Subject: [Git][ghc/ghc][master] hadrian: relax Cabal upper bound to allow building with Cabal-3.8 Message-ID: <6324b9ce58a21_3b59a620aecbec191535b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - hadrian/hadrian.cabal Changes: ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/616afde3e2c6b733c8a44205a140ec8586853d3c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/616afde3e2c6b733c8a44205a140ec8586853d3c You're receiving 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 Sep 16 18:01:30 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 14:01:30 -0400 Subject: [Git][ghc/ghc][master] Add links to the continuations haddocks in the docs for each primop Message-ID: <6324b9fa98a6f_3b59a619d99194192082a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 2 changed files: - compiler/GHC/Builtin/primops.txt.pp - docs/users_guide/9.6.1-notes.rst Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df35d99465d1037b31cbd05aa3380fce6031af73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df35d99465d1037b31cbd05aa3380fce6031af73 You're receiving 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 Sep 16 18:32:29 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 14:32:29 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: hadrian: enable -fprof-late only for profiling ways Message-ID: <6324c13d289a3_3b59a6194ff95c19331c4@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 326234c4 by Matthew Pickering at 2022-09-16T14:31:57-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 - - - - - d14e3046 by sheaf at 2022-09-16T14:32:02-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. - - - - - 24 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Rename/Bind.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Rules/ToolArgs.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs - libraries/base/GHC/Unicode/Internal/Version.hs - libraries/base/changelog.md - libraries/base/tests/unicode001.hs - libraries/base/tests/unicode002.stdout - libraries/base/tests/unicode003.stdout - libraries/base/tools/ucd2haskell/README.md - libraries/base/tools/ucd2haskell/unicode_version - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2634,7 +2634,9 @@ primop MaskStatus "getMaskingState#" GenPrimOp ------------------------------------------------------------------------ section "Continuations" - { These operations provide access to first-class delimited continuations, + { #continuations# + + These operations provide access to first-class delimited continuations, which allow a computation to access and manipulate portions of its /current continuation/. Operationally, they are implemented by direct manipulation of the RTS call stack, which may provide significant @@ -2791,9 +2793,11 @@ section "Continuations" ------------------------------------------------------------------------ primtype PromptTag# a + { See "GHC.Prim#continuations". } primop NewPromptTagOp "newPromptTag#" GenPrimOp State# RealWorld -> (# State# RealWorld, PromptTag# a #) + { See "GHC.Prim#continuations". } with out_of_line = True has_side_effects = True @@ -2802,6 +2806,7 @@ primop PromptOp "prompt#" GenPrimOp PromptTag# a -> (State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, strictOnceApply1Dmd, topDmd] topDiv } out_of_line = True @@ -2813,6 +2818,7 @@ primop Control0Op "control0#" GenPrimOp -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, a #)) -> State# RealWorld -> (# State# RealWorld, p #) + { See "GHC.Prim#continuations". } with strictness = { \ _arity -> mkClosedDmdSig [topDmd, lazyApply2Dmd, topDmd] topDiv } out_of_line = True ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== configure.ac ===================================== @@ -745,11 +745,6 @@ dnl ** check for tar dnl if GNU tar is named gtar, look for it first. AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) -dnl ** check for compressors -AC_PATH_PROGS(Bzip2Cmd,bzip2, bzip2) -AC_PATH_PROGS(GzipCmd,gzip, gzip) -AC_PATH_PROGS(XzCmd,pxz xz, xz) - dnl ** check for patch dnl if GNU patch is named gpatch, look for it first AC_PATH_PROGS(PatchCmd,gpatch patch, patch) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -91,7 +91,7 @@ Runtime system no safe API to access this functionality is provided anywhere in ``base``. Instead, the ``prompt#`` and ``control0#`` primops are intended to be consumed by library authors directly, who may wrap them a safe API that maintains the - necessary invariants. See the documentation in ``GHC.Exts`` for more details. + necessary invariants. See the documentation in ``GHC.Prim`` for more details. ``base`` library ~~~~~~~~~~~~~~~~ ===================================== hadrian/hadrian.cabal ===================================== @@ -147,7 +147,7 @@ executable hadrian , BangPatterns other-extensions: MultiParamTypeClasses , TypeFamilies - build-depends: Cabal >= 3.2 && < 3.7 + build-depends: Cabal >= 3.2 && < 3.9 , base >= 4.8 && < 5 , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 ===================================== hadrian/src/Flavour.hs ===================================== @@ -56,6 +56,7 @@ flavourTransformers = M.fromList , "debug_stage1_ghc" =: debugGhc stage0InTree , "lint" =: enableLinting , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -237,6 +238,7 @@ enableIPE = addArgs enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs $ notStage0 ? builder (Ghc CompileHs) + ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" -- | Enable assertions for the stage2 compiler @@ -525,4 +527,3 @@ builderSetting = stages = map (\stg -> (stageString stg, stg)) allStages pkgs = map (\pkg -> (pkgName pkg, pkg)) (ghcPackages ++ userPackages) - ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -167,10 +167,9 @@ toolTargets = [ binary , time , templateHaskell , text - , terminfo , transformers , unlit -- # executable - ] ++ if windowsHost then [ win32 ] else [ unix ] + ] ++ if windowsHost then [ win32 ] else [ terminfo, unix ] -- | Create a mapping from files to which component it belongs to. dirMap :: Action [(FilePath, (Package, [String]))] ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/GeneralCategory.hs ===================================== The diff for this file was not included because it is too large. ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleLowerCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleTitleCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Char/UnicodeData/SimpleUpperCaseMapping.hs ===================================== @@ -1,5 +1,5 @@ -- DO NOT EDIT: This file is automatically generated by the internal tool ucd2haskell, --- with data from: https://www.unicode.org/Public/14.0.0/ucd/UnicodeData.txt. +-- with data from: https://www.unicode.org/Public/15.0.0/ucd/UnicodeData.txt. {-# LANGUAGE NoImplicitPrelude, LambdaCase #-} {-# OPTIONS_HADDOCK hide #-} ===================================== libraries/base/GHC/Unicode/Internal/Version.hs ===================================== @@ -19,8 +19,8 @@ where import {-# SOURCE #-} Data.Version -- | Version of Unicode standard used by @base@: --- [14.0.0](https://www.unicode.org/versions/Unicode14.0.0/). +-- [15.0.0](https://www.unicode.org/versions/Unicode15.0.0/). -- -- @since 4.15.0.0 unicodeVersion :: Version -unicodeVersion = makeVersion [14, 0, 0] +unicodeVersion = makeVersion [15, 0, 0] ===================================== libraries/base/changelog.md ===================================== @@ -29,6 +29,7 @@ is now exported from `Prelude`. See [CLC #50](https://github.com/haskell/core-libraries-committee/issues/50) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) + * Update to Unicode 15.0.0. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/unicode001.hs ===================================== @@ -12,7 +12,7 @@ main = do do_char char = s ++ (take (12-length s) (repeat ' ')) ++ concat (map f bs) where s = show char - bs = map ($char) functions + bs = map ($ char) functions f True = "X " f False = " " ===================================== libraries/base/tests/unicode002.stdout ===================================== @@ -3314,7 +3314,7 @@ Code C P S U L A D 3312 F F F F F F F 3313 F T F F F T F 3314 F T F F F T F -3315 F F F F F F F +3315 F T F F F F F 3316 F F F F F F F 3317 F F F F F F F 3318 F F F F F F F @@ -3789,7 +3789,7 @@ Code C P S U L A D 3787 F T F F F F F 3788 F T F F F F F 3789 F T F F F F F -3790 F F F F F F F +3790 F T F F F F F 3791 F F F F F F F 3792 F T F F F F F 3793 F T F F F F F ===================================== libraries/base/tests/unicode003.stdout ===================================== @@ -32,11 +32,11 @@ b54,-1748855834,-1637297928 bb8,-1397865929,883567028 c1c,-264170711,891256304 c80,2137024553,478728044 -ce4,-991366506,1583915976 +ce4,-1660460875,1583915976 d48,-651373686,-1004871068 dac,-1169615531,-988897408 e10,1814409961,155596444 -e74,135711270,-609427496 +e74,963650286,-609427496 ed8,-1416017146,-1439222892 f3c,1403902424,1433030608 fa0,299354809,273668620 @@ -692,7 +692,7 @@ ffdc,-2015459986,1906523440 10d88,-847508383,-1808919772 10dec,-847508383,538515008 10e50,-188198045,1503265372 -10eb4,-1034104055,-491064168 +10eb4,-1370226063,-491064168 10f18,-350286230,-1694282284 10f7c,1484313900,856053392 10fe0,-723679588,-588754868 @@ -701,7 +701,7 @@ ffdc,-2015459986,1906523440 1110c,1655903282,449049760 11170,-1051595,32149756 111d4,2109886511,1120445560 -11238,-337373458,1455451956 +11238,-659711824,1455451956 1129c,-1148635252,-368614032 11300,696218094,-2068618516 11364,-686461423,208748104 @@ -723,7 +723,7 @@ ffdc,-2015459986,1906523440 119a4,-1139814714,593543304 11a08,1795222972,-262351708 11a6c,307339100,1598197440 -11ad0,1613469971,-1283076388 +11ad0,-1522264485,-1283076388 11b34,-847508383,-177855464 11b98,-847508383,487104084 11bfc,-2065396652,888655120 @@ -733,8 +733,8 @@ ffdc,-2015459986,1906523440 11d8c,1348516795,1770597664 11df0,-847508383,1176409468 11e54,-847508383,-1707561992 -11eb8,-1502831374,1494051508 -11f1c,-847508383,367208176 +11eb8,2081578339,1494051508 +11f1c,-1149259987,367208176 11f80,1106256227,1888008812 11fe4,757618445,-1421783352 12048,657752308,332029284 @@ -787,8 +787,8 @@ ffdc,-2015459986,1906523440 132a4,657752308,-302543992 13308,657752308,-1755701852 1336c,657752308,-1080401472 -133d0,622961565,1547985372 -13434,1770698299,-189064936 +133d0,1375666284,1547985372 +13434,934320124,-189064936 13498,-847508383,-366597292 134fc,-847508383,-1290482672 13560,-847508383,410098124 @@ -1107,8 +1107,8 @@ ffdc,-2015459986,1906523440 1afa4,-826749161,1555287688 1b008,657752308,-1636146524 1b06c,657752308,-2023206720 -1b0d0,-993675331,-289721124 -1b134,-1949537464,1982839320 +1b0d0,-574234906,-289721124 +1b134,-1242452955,1982839320 1b198,657752308,1394012244 1b1fc,657752308,-1653165296 1b260,657752308,-137343284 @@ -1193,8 +1193,8 @@ ffdc,-2015459986,1906523440 1d13c,-898907559,-872375856 1d1a0,-1152492591,-1201120244 1d204,-1459916519,-1252799320 -1d268,-847508383,-14303932 -1d2cc,143940813,-646470432 +1d268,1804045749,-14303932 +1d2cc,-640919574,-646470432 1d330,-329414484,1932561468 1d394,-847508383,-1734110024 1d3f8,170379721,-333552908 @@ -1225,11 +1225,11 @@ ffdc,-2015459986,1906523440 1ddbc,-847508383,-868111280 1de20,-847508383,1044035212 1de84,-847508383,-1630701272 -1dee8,574970994,-117287484 +1dee8,1239944610,-117287484 1df4c,-847508383,387643232 1dfb0,-62539639,-1756483396 -1e014,906881201,-65223112 -1e078,-847508383,-1946563980 +1e014,702354581,-65223112 +1e078,1024183577,-1946563980 1e0dc,885955124,-210392528 1e140,590739849,1173406764 1e1a4,-847508383,644941960 @@ -1240,7 +1240,7 @@ ffdc,-2015459986,1906523440 1e398,-847508383,-478480812 1e3fc,-847508383,-503630576 1e460,-847508383,1606163660 -1e4c4,-847508383,180346728 +1e4c4,1412498216,180346728 1e528,-847508383,-1797992572 1e58c,-847508383,2096370976 1e5f0,-847508383,-2094838404 @@ -1286,17 +1286,17 @@ ffdc,-2015459986,1906523440 1f590,-1105473175,328132636 1f5f4,-1105473175,2066842712 1f658,-1105473175,-1920516332 -1f6bc,-439945135,1904745808 -1f720,-270299271,2006428044 -1f784,-1856991071,-343818712 +1f6bc,1645245961,1904745808 +1f720,-1162559895,2006428044 +1f784,-702101815,-343818712 1f7e8,1976628113,-898518844 1f84c,471140881,282876512 1f8b0,-10438759,-395554372 1f914,-1105473175,-679784648 1f978,-1105473175,1183875956 1f9dc,-1105473175,1885428528 -1fa40,-1534740639,2004332332 -1faa4,-1131042383,2017661832 +1fa40,923756505,2004332332 +1faa4,467344305,2017661832 1fb08,-1105473175,1091204516 1fb6c,1120513513,-117061184 1fbd0,1887269219,1232484828 @@ -1778,7 +1778,7 @@ ffdc,-2015459986,1906523440 2b5c0,657752308,1930785196 2b624,657752308,-149225208 2b688,657752308,-88958940 -2b6ec,-1998519121,728275264 +2b6ec,-324656038,728275264 2b750,657752308,-1891904164 2b7b4,657752308,58192280 2b818,-276965978,1939972820 @@ -2014,49 +2014,49 @@ ffdc,-2015459986,1906523440 311f0,657752308,360595836 31254,657752308,-488110088 312b8,657752308,-889624908 -3131c,-56393871,2019611376 -31380,-847508383,-1213041044 -313e4,-847508383,-1135936824 -31448,-847508383,1696461156 -314ac,-847508383,1125471872 -31510,-847508383,680032156 -31574,-847508383,1996493528 -315d8,-847508383,283544724 -3163c,-847508383,-1902150960 -316a0,-847508383,-962983156 -31704,-847508383,872440232 -31768,-847508383,212618308 -317cc,-847508383,-1056997408 -31830,-847508383,-296270532 -31894,-847508383,-1547695688 -318f8,-847508383,1004955636 -3195c,-847508383,621756848 -319c0,-847508383,1650466220 -31a24,-847508383,-408089336 -31a88,-847508383,-1063437276 -31aec,-847508383,1314628928 -31b50,-847508383,-807380644 -31bb4,-847508383,-1248342632 -31c18,-847508383,-319457580 -31c7c,-847508383,-1276547696 -31ce0,-847508383,1954980172 -31d44,-847508383,-1819820568 -31da8,-847508383,333403140 -31e0c,-847508383,-2025999968 -31e70,-847508383,1747736060 -31ed4,-847508383,-1470334600 -31f38,-847508383,-1433450956 -31f9c,-847508383,1476839536 -32000,-847508383,120898540 -32064,-847508383,-679398584 -320c8,-847508383,-782284572 -3212c,-847508383,1594699520 -32190,-847508383,562228252 -321f4,-847508383,1176514648 -32258,-847508383,-461262060 -322bc,-847508383,922315088 -32320,-847508383,-238903924 -32384,-847508383,-2021244376 +3131c,-15536511,2019611376 +31380,657752308,-1213041044 +313e4,657752308,-1135936824 +31448,657752308,1696461156 +314ac,657752308,1125471872 +31510,657752308,680032156 +31574,657752308,1996493528 +315d8,657752308,283544724 +3163c,657752308,-1902150960 +316a0,657752308,-962983156 +31704,657752308,872440232 +31768,657752308,212618308 +317cc,657752308,-1056997408 +31830,657752308,-296270532 +31894,657752308,-1547695688 +318f8,657752308,1004955636 +3195c,657752308,621756848 +319c0,657752308,1650466220 +31a24,657752308,-408089336 +31a88,657752308,-1063437276 +31aec,657752308,1314628928 +31b50,657752308,-807380644 +31bb4,657752308,-1248342632 +31c18,657752308,-319457580 +31c7c,657752308,-1276547696 +31ce0,657752308,1954980172 +31d44,657752308,-1819820568 +31da8,657752308,333403140 +31e0c,657752308,-2025999968 +31e70,657752308,1747736060 +31ed4,657752308,-1470334600 +31f38,657752308,-1433450956 +31f9c,657752308,1476839536 +32000,657752308,120898540 +32064,657752308,-679398584 +320c8,657752308,-782284572 +3212c,657752308,1594699520 +32190,657752308,562228252 +321f4,657752308,1176514648 +32258,657752308,-461262060 +322bc,657752308,922315088 +32320,657752308,-238903924 +32384,-696549012,-2021244376 323e8,-847508383,1145582788 3244c,-847508383,1664085600 324b0,-847508383,-2133158468 ===================================== libraries/base/tools/ucd2haskell/README.md ===================================== @@ -27,7 +27,7 @@ with Python. __Warning:__ A Python version with the _exact same Unicode version_ is required. -# GHC +## GHC Check the properties of all the characters. @@ -37,7 +37,7 @@ ghc -O2 tests/export_all_chars.hs python3 tests/check_all_chars.py tests/all_chars.csv ``` -# GHC tests data +## GHC tests data Check the Unicode test data (`unicodeNNN.stdout`). ===================================== libraries/base/tools/ucd2haskell/unicode_version ===================================== @@ -1 +1 @@ -VERSION="14.0.0" +VERSION="15.0.0" ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -71,7 +71,6 @@ import GHC.Exts.Heap.Utils import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI -import Control.Monad import Data.Bits import Foreign import GHC.Exts @@ -221,135 +220,119 @@ getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do t | t >= THUNK && t <= THUNK_STATIC -> do pure $ ThunkClosure itbl pts npts - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) + THUNK_SELECTOR -> case pts of + [] -> fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + hd : _ -> pure $ SelectorClosure itbl hd t | t >= FUN && t <= FUN_STATIC -> do pure $ FunClosure itbl pts npts - AP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl + AP -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - PAP -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to PAP" - -- We expect at least the arity, n_args, and fun fields - unless (length payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl + hd tl + _ -> fail "Expected at least 2 raw words to AP" + + PAP -> case pts of + [] -> fail "Expected at least 1 ptr argument to PAP" + hd : tl -> case payloadWords of + -- We expect at least the arity, n_args, and fun fields + splitWord : _ : _ -> + pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ show (length payloadWords) - let splitWord = payloadWords !! 3 - pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + hd tl + _ -> fail "Expected at least 2 raw words to PAP" + + AP_STACK -> case pts of + [] -> fail "Expected at least 1 ptr argument to AP_STACK" + hd : tl -> pure $ APStackClosure itbl hd tl + + IND -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND" + hd : _ -> pure $ IndClosure itbl hd + + IND_STATIC -> case pts of + [] -> fail "Expected at least 1 ptr argument to IND_STATIC" + hd : _ -> pure $ IndClosure itbl hd + + BLACKHOLE -> case pts of + [] -> fail "Expected at least 1 ptr argument to BLACKHOLE" + hd : _ -> pure $ BlackholeClosure itbl hd + + BCO -> case pts of + pts0 : pts1 : pts2 : _ -> case payloadWords of + _ : _ : _ : splitWord : payloadRest -> + pure $ BCOClosure itbl pts0 pts1 pts2 #if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) #else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 payloadWords) + payloadRest + _ -> fail $ "Expected at least 4 words to BCO, found " + ++ show (length payloadWords) + _ -> fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " + ARR_WORDS -> case payloadWords of + [] -> fail $ "Expected at least 1 words to ARR_WORDS, found " ++ show (length payloadWords) - pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) + hd : tl -> pure $ ArrWordsClosure itbl hd tl - t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + p0 : p1 : _ -> pure $ MutArrClosure itbl p0 p1 pts + _ -> fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts - t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> case payloadWords of + [] -> fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + hd : _ -> pure $ SmallMutArrClosure itbl hd pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do - unless (length pts >= 1) $ - fail $ "Expected at least 1 words to MUT_VAR, found " + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> case pts of + [] -> fail $ "Expected at least 1 words to MUT_VAR, found " ++ show (length pts) - pure $ MutVarClosure itbl (head pts) + hd : _ -> pure $ MutVarClosure itbl hd - t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " + t | t == MVAR_CLEAN || t == MVAR_DIRTY -> case pts of + pts0 : pts1 : pts2 : _ -> pure $ MVarClosure itbl pts0 pts1 pts2 + _ -> fail $ "Expected at least 3 ptrs to MVAR, found " ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure + WEAK -> case pts of + pts0 : pts1 : pts2 : pts3 : rest -> pure $ WeakClosure { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of + , cfinalizers = pts0 + , key = pts1 + , value = pts2 + , finalizer = pts3 + , weakLink = case rest of [] -> Nothing [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + _ -> error $ "Expected 4 or 5 words in WEAK, but found more: " ++ show (length pts) } + _ -> error $ "Expected 4 or 5 words in WEAK, but found less: " ++ show (length pts) TSO | ( u_lnk : u_gbl_lnk : tso_stack : u_trec : u_blk_ex : u_bq : other) <- pts -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields decodeCCS ptr ===================================== libraries/ghc-heap/GHC/Exts/Heap/Utils.hsc ===================================== @@ -110,11 +110,7 @@ parse (Ptr addr) = if not . all (>0) . fmap length $ [p,m,occ] (m, occ) = (intercalate "." $ reverse modWords, occWord) where - (modWords, occWord) = - if length rest1 < 1 -- XXXXXXXXx YUKX - --then error "getConDescAddress:parse:length rest1 < 1" - then parseModOcc [] [] - else parseModOcc [] (tail rest1) + (modWords, occWord) = parseModOcc [] (drop 1 rest1) -- We only look for dots if str could start with a module name, -- i.e. if it starts with an upper case character. -- Otherwise we might think that "X.:->" is the module name in ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [GHC-61367] [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [GHC-61367] [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ac525764bf1fa4fadd51f9c81cdeb45fa90f859...d14e3046f04cb4c2d5ed1be26d193bbaecc01286 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ac525764bf1fa4fadd51f9c81cdeb45fa90f859...d14e3046f04cb4c2d5ed1be26d193bbaecc01286 You're receiving 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 Sep 17 01:42:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 21:42:28 -0400 Subject: [Git][ghc/ghc][master] -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <63252604a47c1_3b59a620aecc142004812@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 5 changed files: - compiler/GHC/Rename/Bind.hs - + testsuite/tests/rename/should_compile/T22057.hs - + testsuite/tests/rename/should_compile/T22067.hs - + testsuite/tests/rename/should_compile/T22067.stderr - testsuite/tests/rename/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/Bind.hs ===================================== @@ -493,18 +493,10 @@ rnBind _ bind@(PatBind { pat_lhs = pat bind' = bind { pat_rhs = grhss' , pat_ext = fvs' } - ok_nobind_pat - = -- See Note [Pattern bindings that bind no variables] - case unLoc pat of - WildPat {} -> True - BangPat {} -> True -- #9127, #13646 - SplicePat {} -> True - _ -> False - -- Warn if the pattern binds no variables -- See Note [Pattern bindings that bind no variables] ; whenWOptM Opt_WarnUnusedPatternBinds $ - when (null bndrs && not ok_nobind_pat) $ + when (null bndrs && not (isOkNoBindPattern pat)) $ addTcRnDiagnostic (TcRnUnusedPatternBinds bind') ; fvs' `seq` -- See Note [Free-variable space leak] @@ -540,29 +532,66 @@ rnBind sig_fn (PatSynBind x bind) rnBind _ b = pprPanic "rnBind" (ppr b) + -- See Note [Pattern bindings that bind no variables] +isOkNoBindPattern :: LPat GhcRn -> Bool +isOkNoBindPattern (L _ pat) = + case pat of + WildPat{} -> True -- Exception (1) + BangPat {} -> True -- Exception (2) #9127, #13646 + p -> patternContainsSplice p -- Exception (3) + + where + lpatternContainsSplice :: LPat GhcRn -> Bool + lpatternContainsSplice (L _ p) = patternContainsSplice p + patternContainsSplice :: Pat GhcRn -> Bool + patternContainsSplice p = + case p of + -- A top-level splice has been evaluated by this point, so we know the pattern it is evaluated to + SplicePat (HsUntypedSpliceTop _ p) _ -> patternContainsSplice p + -- A nested splice isn't evaluated so we can't guess what it will expand to + SplicePat (HsUntypedSpliceNested {}) _ -> True + -- The base cases + VarPat {} -> False + WildPat {} -> False + LitPat {} -> False + NPat {} -> False + NPlusKPat {} -> False + -- Recursive cases + BangPat _ lp -> lpatternContainsSplice lp + LazyPat _ lp -> lpatternContainsSplice lp + AsPat _ _ _ lp -> lpatternContainsSplice lp + ParPat _ _ lp _ -> lpatternContainsSplice lp + ViewPat _ _ lp -> lpatternContainsSplice lp + SigPat _ lp _ -> lpatternContainsSplice lp + ListPat _ lps -> any lpatternContainsSplice lps + TuplePat _ lps _ -> any lpatternContainsSplice lps + SumPat _ lp _ _ -> lpatternContainsSplice lp + ConPat _ _ cpd -> any lpatternContainsSplice (hsConPatArgs cpd) + XPat (HsPatExpanded _orig new) -> patternContainsSplice new + {- Note [Pattern bindings that bind no variables] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally, we want to warn about pattern bindings like Just _ = e because they don't do anything! But we have three exceptions: -* A wildcard pattern +(1) A wildcard pattern _ = rhs which (a) is not that different from _v = rhs (b) is sometimes used to give a type sig for, or an occurrence of, a variable on the RHS -* A strict pattern binding; that is, one with an outermost bang +(2) A strict pattern binding; that is, one with an outermost bang !Just _ = e This can fail, so unlike the lazy variant, it is not a no-op. Moreover, #13646 argues that even for single constructor types, you might want to write the constructor. See also #9127. -* A splice pattern +(3) A splice pattern $(th-lhs) = rhs It is impossible to determine whether or not th-lhs really - binds any variable. We should disable the warning for any pattern - which contain splices, but that is a more expensive check. + binds any variable. You have to recurse all the way into the pattern to check + it doesn't contain any splices like this. See #22057. Note [Free-variable space leak] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/rename/should_compile/T22057.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# OPTIONS -Wall #-} +module Thing (thing) where + +import Language.Haskell.TH + +thing :: Q () +thing = do + name <- newName "x" + -- warning: + _ <- [| let ($(pure (VarP name)), _) = (3.0, 4.0) in $(pure (VarE name)) |] + -- warning: + _ <- [| let ($(pure (VarP name)) ) = 3.0 in $(pure (VarE name)) |] + -- no warning: + _ <- [| let $(pure (VarP name)) = 3.0 in $(pure (VarE name)) |] + return () ===================================== testsuite/tests/rename/should_compile/T22067.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module TTT where + +a :: () +a = let () = () in () + +b :: () +b = let $([p|()|]) = () in () + ===================================== testsuite/tests/rename/should_compile/T22067.stderr ===================================== @@ -0,0 +1,6 @@ + +T22067.hs:5:9: warning: [GHC-61367] [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: () = () + +T22067.hs:8:9: warning: [GHC-61367] [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)] + This pattern-binding binds no variables: (()) = () ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -188,3 +188,5 @@ test('T18862', normal, compile, ['']) test('unused_haddock', normal, compile, ['-haddock -Wall']) test('T19984', normal, compile, ['-fwarn-unticked-promoted-constructors']) test('T21654', normal, compile, ['-Wunused-top-binds']) +test('T22057', normal, compile, ['-Wall']) +test('T22067', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/383f75494a936bbc2f794a788141b103cd482913 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/383f75494a936bbc2f794a788141b103cd482913 You're receiving 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 Sep 17 01:43:01 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 21:43:01 -0400 Subject: [Git][ghc/ghc][master] Hadrian: Don't try to build terminfo on Windows Message-ID: <63252625f40c7_3b59a620aecc142008481@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - hadrian/src/Rules/ToolArgs.hs Changes: ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -167,10 +167,9 @@ toolTargets = [ binary , time , templateHaskell , text - , terminfo , transformers , unlit -- # executable - ] ++ if windowsHost then [ win32 ] else [ unix ] + ] ++ if windowsHost then [ win32 ] else [ terminfo, unix ] -- | Create a mapping from files to which component it belongs to. dirMap :: Action [(FilePath, (Package, [String]))] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5031bf49793f3470a9fd9036829a08e556584d8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5031bf49793f3470a9fd9036829a08e556584d8a You're receiving 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 Sep 17 02:13:58 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 16 Sep 2022 22:13:58 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice Message-ID: <63252d667e660_3b59a620aecbec20127fe@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - e81a14da by M Farkas-Dyck at 2022-09-16T22:13:38-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. - - - - - 9649b1a3 by Cheng Shao at 2022-09-16T22:13:41-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. - - - - - 8cc10629 by Cheng Shao at 2022-09-16T22:13:43-04:00 rts: remove legacy logging cabal flag - - - - - 3fe2c493 by Cheng Shao at 2022-09-16T22:13:43-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. - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d14e3046f04cb4c2d5ed1be26d193bbaecc01286...3fe2c493c27f4b873a9ebedc0f74bd0f97c750a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d14e3046f04cb4c2d5ed1be26d193bbaecc01286...3fe2c493c27f4b873a9ebedc0f74bd0f97c750a8 You're receiving 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 Sep 17 05:44:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 01:44:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Clean up some. In particular: Message-ID: <63255ebcc36fb_3b59a6539302036947@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9a0eda41 by M Farkas-Dyck at 2022-09-17T01:44:04-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. - - - - - f2cfc70a by Cheng Shao at 2022-09-17T01:44:07-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. - - - - - 66f513bf by Cheng Shao at 2022-09-17T01:44:09-04:00 rts: remove legacy logging cabal flag - - - - - 4bf3ae53 by Cheng Shao at 2022-09-17T01:44:09-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. - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fe2c493c27f4b873a9ebedc0f74bd0f97c750a8...4bf3ae534ce645dcdf9999ab21b29f4355a18246 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fe2c493c27f4b873a9ebedc0f74bd0f97c750a8...4bf3ae534ce645dcdf9999ab21b29f4355a18246 You're receiving 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 Sep 17 08:44:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 04:44:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Clean up some. In particular: Message-ID: <63258901a9df3_3b59a65183820854e8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 302abdae by M Farkas-Dyck at 2022-09-17T04:44:29-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. - - - - - 18199410 by Cheng Shao at 2022-09-17T04:44:32-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. - - - - - 58866583 by Cheng Shao at 2022-09-17T04:44:35-04:00 rts: remove legacy logging cabal flag - - - - - bb74d46e by Cheng Shao at 2022-09-17T04:44:35-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. - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4bf3ae534ce645dcdf9999ab21b29f4355a18246...bb74d46edf49a8ab8739245a5711d8984f2d9eac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4bf3ae534ce645dcdf9999ab21b29f4355a18246...bb74d46edf49a8ab8739245a5711d8984f2d9eac You're receiving 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 Sep 17 10:19:39 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sat, 17 Sep 2022 06:19:39 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghci-primcall Message-ID: <63259f3b8696f_3b59a620aecc1421046dd@gitlab.mail> Luite Stegeman pushed new branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghci-primcall You're receiving 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 Sep 17 10:45:01 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 06:45:01 -0400 Subject: [Git][ghc/ghc][master] Clean up some. In particular: Message-ID: <6325a52d7bdc3_3b59a6194ffb50211205e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9afe2216ccabd36e3083ec3b508310fcdb5eae3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9afe2216ccabd36e3083ec3b508310fcdb5eae3 You're receiving 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 Sep 17 10:45:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 06:45:43 -0400 Subject: [Git][ghc/ghc][master] driver: pass original Cmm filename in ModLocation Message-ID: <6325a5575d3dd_3b59a6194ff95c2121120@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - compiler/GHC/Driver/Main.hs Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1866,7 +1866,7 @@ hscCompileCmmFile hsc_env original_filename filename output_filename = runHsc hs rawCmms return stub_c_exists where - no_loc = ModLocation{ ml_hs_file = Just filename, + no_loc = ModLocation{ ml_hs_file = Just original_filename, ml_hi_file = panic "hscCompileCmmFile: no hi file", ml_obj_file = panic "hscCompileCmmFile: no obj file", ml_dyn_obj_file = panic "hscCompileCmmFile: no dyn obj file", View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85431ac363e77dd0f93d46ff1ed450b4833c2a40 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85431ac363e77dd0f93d46ff1ed450b4833c2a40 You're receiving 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 Sep 17 10:46:18 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 06:46:18 -0400 Subject: [Git][ghc/ghc][master] 2 commits: rts: remove legacy logging cabal flag Message-ID: <6325a57a7ac65_3b59a651838212473c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 2 changed files: - hadrian/src/Settings/Packages.hs - rts/rts.cabal.in Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -389,6 +389,7 @@ rtsPackageArgs = package rts ? do [ any (wayUnit Profiling) rtsWays `cabalFlag` "profiling" , any (wayUnit Debug) rtsWays `cabalFlag` "debug" , any (wayUnit Dynamic) rtsWays `cabalFlag` "dynamic" + , any (wayUnit Threaded) rtsWays `cabalFlag` "threaded" , useSystemFfi `cabalFlag` "use-system-libffi" , useLibffiForAdjustors `cabalFlag` "libffi-adjustors" , Debug `wayUnit` way `cabalFlag` "find-ptr" ===================================== rts/rts.cabal.in ===================================== @@ -49,10 +49,10 @@ flag profiling default: False flag debug default: False -flag logging - default: False flag dynamic default: False +flag threaded + default: False flag thread-sanitizer description: Enable checking for data races using the ThreadSanitizer (TSAN) @@ -80,17 +80,26 @@ library -- Here we declare several flavours to be available when passing the -- suitable (combination of) flag(s) when configuring the RTS from hadrian, -- using Cabal. - extra-library-flavours: _thr + if flag(threaded) + extra-library-flavours: _thr if flag(profiling) - extra-library-flavours: _p _thr_p + extra-library-flavours: _p + if flag(threaded) + extra-library-flavours: _thr_p if flag(debug) - extra-library-flavours: _debug_p _thr_debug_p + extra-library-flavours: _debug_p + if flag(threaded) + extra-library-flavours: _thr_debug_p if flag(debug) - extra-library-flavours: _debug _thr_debug + extra-library-flavours: _debug + if flag(threaded) + extra-library-flavours: _thr_debug if flag(dynamic) - extra-dynamic-library-flavours: _debug _thr_debug - if flag(dynamic) + extra-dynamic-library-flavours: _debug + if flag(threaded) + extra-dynamic-library-flavours: _thr_debug + if flag(dynamic) && flag(threaded) extra-dynamic-library-flavours: _thr if flag(thread-sanitizer) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85431ac363e77dd0f93d46ff1ed450b4833c2a40...bd0f418422a3ace8d05c8ce93850190e57321465 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/85431ac363e77dd0f93d46ff1ed450b4833c2a40...bd0f418422a3ace8d05c8ce93850190e57321465 You're receiving 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 Sep 17 13:19:04 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sat, 17 Sep 2022 09:19:04 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] fixups Message-ID: <6325c948ab90_3b59a6195e331421397f5@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 463548bf by Luite Stegeman at 2022-09-17T15:18:37+02:00 fixups - - - - - 3 changed files: - compiler/GHC/StgToByteCode.hs - rts/Disassembler.c - rts/StgMiscClosures.cmm Changes: ===================================== compiler/GHC/StgToByteCode.hs ===================================== @@ -649,7 +649,7 @@ schemeT d s p app -- Case 1 schemeT d s p (StgOpApp (StgFCallOp (CCall ccall_spec) _ty) args result_ty) = if isSupportedCConv ccall_spec - then generateCCall d s p ccall_spec result_ty args -- (reverse args) + then generateCCall d s p ccall_spec result_ty args else unsupportedCConvException schemeT d s p (StgOpApp (StgPrimOp op) args _ty) @@ -1280,7 +1280,7 @@ generatePrimCall d s p target _mb_unit _result_ty args the layoutTuple function? -} (args_info, args_offsets) = - layoutTuple profile 0 (primRepCmmType platform . argPrimRep) args + layoutTuple profile d (primRepCmmType platform . argPrimRep) args args_ptrs = map (\(r, off) -> (isFollowableArg (toArgRep platform . argPrimRep $ r), off)) ===================================== rts/Disassembler.c ===================================== @@ -84,7 +84,7 @@ disInstr ( StgBCO *bco, int pc ) literals[instrs[pc]] ); pc += 1; break; case bci_PRIMCALL: - debugBelch("PRIMCALL\n "); + debugBelch("PRIMCALL\n"); break; case bci_STKCHECK: { StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; ===================================== rts/StgMiscClosures.cmm ===================================== @@ -406,6 +406,33 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) } + /* + Note [GHCi prim calling convention] + + The stg_primcall frame is used by the bytecode interpreter to call + a Cmm function. The frame contains an args_info word that contains + a bitmap describing the register arguments. + + The register arguments are moved to registers first (they are on + the stack in the order that POP_TUPLE_REGS expects) while the + remaining arguments are left on the stack. + + When the target function is called, Sp points to the topmost stack + argument. + + ... + next_stack_frame + arg_1 + arg_2 + ... + arg_n + target_funptr (pointer to the function we're calling) + args_info (describes the registers containing the arguments) + primcall_BCO (contains bitmap describing pointers in args) + stg_primcall_info <- Sp + + */ + INFO_TABLE_RET ( stg_primcall, RET_BCO ) { W_ args_info, prim_fun; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/463548bf5ba8b6691648b0ef03578fd08e211dd9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/463548bf5ba8b6691648b0ef03578fd08e211dd9 You're receiving 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 Sep 17 14:55:49 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sat, 17 Sep 2022 10:55:49 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] add new note ref Message-ID: <6325dff55fc49_3b59a619d991942147540@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 38526890 by Luite Stegeman at 2022-09-17T16:55:19+02:00 add new note ref - - - - - 1 changed file: - testsuite/tests/linters/notes.stdout Changes: ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -55,6 +55,7 @@ ref hadrian/src/Expression.hs:130:30: Note [Linking ghc-bin against threa ref libraries/base/GHC/ST.hs:134:7: Note [Definition of runRW#] ref linters/lint-notes/Notes.hs:32:29: Note [" <> T.unpack x <> "] ref linters/lint-notes/Notes.hs:69:22: Note [...] +ref rts/StgMiscClosures.cmm:410:4: Note [GHCi prim calling convention] ref testsuite/config/ghc:243:10: Note [WayFlags] ref testsuite/driver/testlib.py:153:10: Note [Why is there no stage1 setup function?] ref testsuite/driver/testlib.py:157:2: Note [Why is there no stage1 setup function?] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38526890214602f486ea55a1fc67dd4b8ae38037 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38526890214602f486ea55a1fc67dd4b8ae38037 You're receiving 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 Sep 17 17:21:40 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sat, 17 Sep 2022 13:21:40 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] twiddle test options Message-ID: <6326022499a8f_3b59a653930216406c@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 0700541b by Luite Stegeman at 2022-09-17T19:21:19+02:00 twiddle test options - - - - - 1 changed file: - testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile Changes: ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -1,4 +1,4 @@ .PHONY: GHCiPrimCall GHCiPrimCall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -c GHCiPrimCall_cmm.cmm - -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 + '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm + -'$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0700541b427a64aed7c35be426315da602a13e4c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0700541b427a64aed7c35be426315da602a13e4c You're receiving 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 Sep 17 17:45:22 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sat, 17 Sep 2022 13:45:22 -0400 Subject: [Git][ghc/ghc][wip/wither-eq1-and-friends] 114 commits: Recognize file-header pragmas in GHCi (#21507) Message-ID: <632607b2bc62_3b59a6194ffb502173796@gitlab.mail> John Ericson pushed to branch wip/wither-eq1-and-friends at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 08280089 by John Ericson at 2022-09-17T13:44:00-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 08eca4ec by John Ericson at 2022-09-17T13:44:53-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. - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/171d6ff265ad804e33a3692bf3abeeeec80ee746...08eca4ec4025bb42666a318cca73ca73f1beac75 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/171d6ff265ad804e33a3692bf3abeeeec80ee746...08eca4ec4025bb42666a318cca73ca73f1beac75 You're receiving 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 Sep 17 18:48:14 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 17 Sep 2022 14:48:14 -0400 Subject: [Git][ghc/ghc][wip/T21623] Wibbles Message-ID: <6326166e2d5b3_3b59a65393021870a5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 5924c88f by Simon Peyton Jones at 2022-09-17T19:48:23+01:00 Wibbles - - - - - 12 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Type.hs - testsuite/tests/callarity/unittest/CallArity1.hs - testsuite/tests/roles/should_compile/Roles14.stderr - testsuite/tests/roles/should_compile/Roles3.stderr - testsuite/tests/roles/should_compile/Roles4.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/saks/should_compile/saks007.hs - testsuite/tests/stranal/should_compile/T18982.stderr - testsuite/tests/typecheck/should_compile/T17021a.hs Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -592,6 +592,31 @@ but dcRepArity does. For example: Note [DataCon user type variable binders] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A DataCon has two different sets of type variables: + +* dcUserTyVarBinders, for the type variables binders in the order in which they + originally arose in the user-written type signature. + + - They are the forall'd binders of the data con /wrapper/, which the user calls. + + - Their order *does* matter for TypeApplications, so they are full TyVarBinders, + complete with visibilities. + +* dcUnivTyVars and dcExTyCoVars, for the "true underlying" (i.e. of the data + con worker) universal type variable and existential type/coercion variables, + respectively. + + - They (i.e. univ ++ ex) are the forall'd variables of the data con /worker/ + + - Their order is irrelevant for the purposes of TypeApplications, + and as a consequence, they do not come equipped with visibilities + (that is, they are TyVars/TyCoVars instead of ForAllTyBinders). + +Often (dcUnivTyVars ++ dcExTyCoVars) = dcUserTyVarBinder; but they may differ +for two reasons, coming next: + +--- Reason (R1): Order of quantification in GADT syntax --- + In System FC, data constructor type signatures always quantify over all of their universal type variables, followed by their existential type variables. Normally, this isn't a problem, as most datatypes naturally quantify their type @@ -634,27 +659,27 @@ according to the rules of TypeApplications, in the absence of `forall` GHC performs a stable topological sort on the type variables in the user-written type signature, which would place `b` before `a`. -But as noted above, enacting this behavior is not entirely trivial, as System -FC demands the variables go in universal-then-existential order under the hood. -Our solution is thus to equip DataCon with two different sets of type -variables: +--- Reason (R2): GADTs introduce new existentials --- -* dcUnivTyVars and dcExTyCoVars, for the universal type variable and existential - type/coercion variables, respectively. Their order is irrelevant for the - purposes of TypeApplications, and as a consequence, they do not come equipped - with visibilities (that is, they are TyVars/TyCoVars instead of - ForAllTyBinders). +GADTs may also introduce extra existentials. Consider + data T a b where + MkT :: forall c d. c -> T [c] d -* dcUserTyVarBinders, for the type variables binders in the order in which they - originally arose in the user-written type signature. Their order *does* matter - for TypeApplications, so they are full TyVarBinders, complete with - visibilities. +Then we make up a fresh universal, say 'a', to be the first argument to T in +the result, and get this type for the "true underlying" worker data con: + + MkT :: forall a d. forall c. (a ~# [c]) => c -> T a d -This encoding has some redundancy. The set of tyvars in dcUserTyVarBinders +(We don't need to make up a fresh tyvar for the second arg; 'd' will do.) + +End of Reasons + +Invariant: the set of tyvars in dcUserTyVarBinders consists precisely of: * The set of tyvars in dcUnivTyVars whose type variables do not appear in dcEqSpec, unioned with: + * The set of tyvars (*not* covars) in dcExTyCoVars No covars here because because they're not user-written @@ -1687,7 +1712,6 @@ dataConUnconstrainedTyVars (MkData { dcUnivTyVars = univ_tvs , dcExTyCoVars = ex_tvs , dcEqSpec = eq_spec }) = [ univ_tv | univ_tv <- univ_tvs - , not (isConstraintLikeKind (typeKind (tyVarKind univ_tv))) , not (univ_tv `elemUnVarSet` eq_spec_tvs) ] ++ ex_tvs where ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -657,11 +657,11 @@ See #15710 about that. Note [Unused coercion variable in ForAllTy] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose we have - \(co:t1 ~ t2). e + \(co:t1 ~# t2). e -What type should we give to this expression? - (1) forall (co:t1 ~ t2) -> t - (2) (t1 ~ t2) -> t +What type should we give to the above expression? + (1) forall (co:t1 ~# t2) -> t + (2) (t1 ~# t2) -> t If co is used in t, (1) should be the right choice. if co is not used in t, we would like to have (1) and (2) equivalent. ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -2517,8 +2517,7 @@ seqTypes (ty:tys) = seqType ty `seq` seqTypes tys Note [Kinding rules for types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In typeKind we consider Constraint and (TYPE LiftedRep) to be identical. -We then have +Here are the kinding rules for types t1 : TYPE rep1 t2 : TYPE rep2 ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -115,6 +115,7 @@ import GHC.Types.Basic import GHC.Types.SrcLoc import GHC.Utils.Outputable import GHC.Utils.Misc (count) +import GHC.Utils.Trace import Data.Maybe import Data.Data (Data) @@ -1138,7 +1139,8 @@ ppr_mono_ty (HsQualTy { hst_ctxt = ctxt, hst_body = ty }) ppr_mono_ty (HsBangTy _ b ty) = ppr b <> ppr_mono_lty ty ppr_mono_ty (HsRecTy _ flds) = pprConDeclFields flds -ppr_mono_ty (HsTyVar _ prom (L _ name)) = pprOccWithTick Prefix prom name +ppr_mono_ty (HsTyVar _ prom (L _ name)) = pprTrace "ppr_mono" (ppr name) $ + pprOccWithTick Prefix prom name ppr_mono_ty (HsFunTy _ mult ty1 ty2) = ppr_fun_ty mult ty1 ty2 ppr_mono_ty (HsTupleTy _ con tys) -- Special-case unary boxed tuples so that they are pretty-printed as ===================================== testsuite/tests/callarity/unittest/CallArity1.hs ===================================== @@ -3,7 +3,7 @@ import GHC.Core import GHC.Core.Utils import GHC.Types.Id import GHC.Core.Type -import GHC.Core.Multiplicity ( pattern Many ) +import GHC.Core.Multiplicity ( pattern ManyTy ) import GHC.Core.Make import GHC.Core.Opt.CallArity (callArityRHS) import GHC.Types.Id.Make @@ -192,7 +192,7 @@ mkLApps v = mkApps (Var v) . map mkLit mkACase = mkIfThenElse (mkVarApps (Var scrutf) [scruta]) mkTestId :: Int -> String -> Type -> Id -mkTestId i s ty = mkSysLocal (mkFastString s) (mkBuiltinUnique i) Many ty +mkTestId i s ty = mkSysLocal (mkFastString s) (mkBuiltinUnique i) ManyTy ty mkTestIds :: [String] -> [Type] -> [Id] mkTestIds ns tys = zipWith3 mkTestId [0..] ns tys ===================================== testsuite/tests/roles/should_compile/Roles14.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom Roles12.N:C2 :: C2 a = a -> a Dependent modules: [] -Dependent packages: [base-4.16.0.0] +Dependent packages: [base-4.17.0.0] ==================== Typechecker ==================== Roles12.$tcC2 @@ -17,14 +17,13 @@ Roles12.$tc'C:C2 = GHC.Types.TyCon 7087988437584478859##64 11477953550142401435##64 Roles12.$trModule (GHC.Types.TrNameS "'C:C2"#) 1# $krep +$krep [InlPrag=[~]] + = GHC.Types.KindRepTyConApp Roles12.$tcC2 ((:) $krep []) $krep [InlPrag=[~]] = GHC.Types.KindRepVar 0 $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep -$krep [InlPrag=[~]] = GHC.Types.KindRepFun GHC.Types.krep$* $krep $krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp GHC.Types.$tcConstraint [] -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp Roles12.$tcC2 ((:) $krep []) + = GHC.Types.KindRepFun GHC.Types.krep$* GHC.Types.krep$Constraint Roles12.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "Roles12"#) ===================================== testsuite/tests/roles/should_compile/Roles3.stderr ===================================== @@ -21,7 +21,7 @@ COERCION AXIOMS axiom Roles3.N:C3 :: C3 a b = a -> F3 b -> F3 b axiom Roles3.N:C4 :: C4 a b = a -> F4 b -> F4 b Dependent modules: [] -Dependent packages: [base-4.16.0.0] +Dependent packages: [base-4.17.0.0] ==================== Typechecker ==================== Roles3.$tcC4 @@ -48,24 +48,23 @@ Roles3.$tc'C:C1 = GHC.Types.TyCon 4508088879886988796##64 13962145553903222779##64 Roles3.$trModule (GHC.Types.TrNameS "'C:C1"#) 1# $krep +$krep [InlPrag=[~]] + = GHC.Types.KindRepTyConApp + GHC.Types.$tc~ ((:) GHC.Types.krep$* ((:) $krep ((:) $krep []))) +$krep [InlPrag=[~]] + = GHC.Types.KindRepTyConApp Roles3.$tcC2 ((:) $krep ((:) $krep [])) +$krep [InlPrag=[~]] + = GHC.Types.KindRepTyConApp Roles3.$tcC1 ((:) $krep []) $krep [InlPrag=[~]] = GHC.Types.KindRepVar 0 $krep [InlPrag=[~]] = GHC.Types.KindRepVar 1 $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep -$krep [InlPrag=[~]] = GHC.Types.KindRepFun GHC.Types.krep$* $krep -$krep [InlPrag=[~]] = GHC.Types.KindRepFun GHC.Types.krep$* $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep +$krep [InlPrag=[~]] = GHC.Types.KindRepFun GHC.Types.krep$* $krep $krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp GHC.Types.$tcConstraint [] + = GHC.Types.KindRepFun GHC.Types.krep$* GHC.Types.krep$Constraint $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp - GHC.Types.$tc~ ((:) GHC.Types.krep$* ((:) $krep ((:) $krep []))) -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp Roles3.$tcC2 ((:) $krep ((:) $krep [])) -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp Roles3.$tcC1 ((:) $krep []) Roles3.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "Roles3"#) ===================================== testsuite/tests/roles/should_compile/Roles4.stderr ===================================== @@ -9,7 +9,7 @@ COERCION AXIOMS axiom Roles4.N:C1 :: C1 a = a -> a axiom Roles4.N:C3 :: C3 a = a -> Syn1 a Dependent modules: [] -Dependent packages: [base-4.16.0.0] +Dependent packages: [base-4.17.0.0] ==================== Typechecker ==================== Roles4.$tcC3 @@ -28,20 +28,19 @@ Roles4.$tc'C:C1 = GHC.Types.TyCon 3870707671502302648##64 10631907186261837450##64 Roles4.$trModule (GHC.Types.TrNameS "'C:C1"#) 1# $krep +$krep [InlPrag=[~]] + = GHC.Types.KindRepTyConApp Roles4.$tcC3 ((:) $krep []) +$krep [InlPrag=[~]] + = GHC.Types.KindRepTyConApp Roles4.$tcC1 ((:) $krep []) $krep [InlPrag=[~]] = GHC.Types.KindRepVar 0 $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep -$krep [InlPrag=[~]] = GHC.Types.KindRepFun GHC.Types.krep$* $krep -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp GHC.Types.$tcList ((:) $krep []) -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp GHC.Types.$tcConstraint [] $krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp Roles4.$tcC3 ((:) $krep []) + = GHC.Types.KindRepFun GHC.Types.krep$* GHC.Types.krep$Constraint $krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp Roles4.$tcC1 ((:) $krep []) + = GHC.Types.KindRepTyConApp GHC.Types.$tcList ((:) $krep []) Roles4.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "Roles4"#) ===================================== 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.0.0] +Dependent packages: [base-4.17.0.0] ==================== Typechecker ==================== T8958.$tcMap @@ -46,7 +46,8 @@ T8958.$tc'C:Nominal $krep [InlPrag=[~]] = GHC.Types.KindRepVar 0 $krep [InlPrag=[~]] = GHC.Types.KindRepVar 1 $krep [InlPrag=[~]] = GHC.Types.KindRepFun $krep $krep -$krep [InlPrag=[~]] = GHC.Types.KindRepFun GHC.Types.krep$* $krep +$krep [InlPrag=[~]] + = GHC.Types.KindRepFun GHC.Types.krep$* GHC.Types.krep$Constraint $krep [InlPrag=[~]] = GHC.Types.KindRepTyConApp GHC.Tuple.$tc(,) @@ -61,9 +62,6 @@ $krep [InlPrag=[~]] = GHC.Types.KindRepTyConApp GHC.Types.$tcList ((:) @GHC.Types.KindRep $krep [] @GHC.Types.KindRep) -$krep [InlPrag=[~]] - = GHC.Types.KindRepTyConApp - GHC.Types.$tcConstraint [] @GHC.Types.KindRep $krep [InlPrag=[~]] = GHC.Types.KindRepTyConApp T8958.$tcRepresentational ===================================== testsuite/tests/saks/should_compile/saks007.hs ===================================== @@ -13,3 +13,28 @@ type X :: forall k1 k2. (F k1 ~ G k2) => k1 -> k2 -> Type data X a b where MkX :: X Integer Maybe -- OK: F Type ~ G (Type -> Type) -- True ~ True + + +{- +Let co :: F Type ~ G (Type->Type) + +Wrapper data con type: + $WMkX :: X @Type @(Type->Type) @(Eq# co) Integer Maybe + +Worker data con's type: + MkX :: forall k1 k2 (c :: F k1 ~ G k2) (a :: k1) (b :: k2) + -> forall . -- No existentials + ( k1 ~# Type, k2 ~# Type->Type -- EqSpec + , a ~# Integer, b ~# Maybe ) + => X k1 k2 c a b + +f :: forall k. (k ~ Type) => forall (a::k). a->a + + +f :: forall (cv :: a ~# b) => ....ty|>co.... + + +X @kk1 @kk2 @(d :: F kk1 ~ G kk2) Integer Maybe + + +-} \ No newline at end of file ===================================== testsuite/tests/stranal/should_compile/T18982.stderr ===================================== @@ -4,15 +4,15 @@ Result size of Tidy Core = {terms: 311, types: 214, coercions: 4, joins: 0/0} -- RHS size: {terms: 8, types: 9, coercions: 1, joins: 0/0} T18982.$WExGADT :: forall e. (e ~ Int) => e %1 -> Int %1 -> ExGADT Int -T18982.$WExGADT = \ (@e) (dt :: e ~ Int) (dt :: e) (dt :: Int) -> T18982.ExGADT @Int @e @~(_N :: Int GHC.Prim.~# Int) dt dt dt +T18982.$WExGADT = \ (@e) (conrep :: e ~ Int) (conrep :: e) (conrep :: Int) -> T18982.ExGADT @Int @e @~(_N :: Int GHC.Prim.~# Int) conrep conrep conrep -- RHS size: {terms: 3, types: 2, coercions: 1, joins: 0/0} T18982.$WGADT :: Int %1 -> GADT Int -T18982.$WGADT = \ (dt :: Int) -> T18982.GADT @Int @~(_N :: Int GHC.Prim.~# Int) dt +T18982.$WGADT = \ (conrep :: Int) -> T18982.GADT @Int @~(_N :: Int GHC.Prim.~# Int) conrep -- RHS size: {terms: 7, types: 6, coercions: 0, joins: 0/0} T18982.$WEx :: forall e a. e %1 -> a %1 -> Ex a -T18982.$WEx = \ (@e) (@a) (dt :: e) (dt :: a) -> T18982.Ex @a @e dt dt +T18982.$WEx = \ (@e) (@a) (conrep :: e) (conrep :: a) -> T18982.Ex @a @e conrep conrep -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18982.$trModule4 :: GHC.Prim.Addr# @@ -72,7 +72,7 @@ T18982.$tcBox1 = GHC.Types.TrNameS T18982.$tcBox2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tcBox :: GHC.Types.TyCon -T18982.$tcBox = GHC.Types.TyCon 16948648223906549518## 2491460178135962649## T18982.$trModule T18982.$tcBox1 0# GHC.Types.krep$*Arr* +T18982.$tcBox = GHC.Types.TyCon 16948648223906549518##64 2491460178135962649##64 T18982.$trModule T18982.$tcBox1 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} $krep7 :: [GHC.Types.KindRep] @@ -96,7 +96,7 @@ T18982.$tc'Box2 = GHC.Types.TrNameS T18982.$tc'Box3 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tc'Box :: GHC.Types.TyCon -T18982.$tc'Box = GHC.Types.TyCon 1412068769125067428## 8727214667407894081## T18982.$trModule T18982.$tc'Box2 1# T18982.$tc'Box1 +T18982.$tc'Box = GHC.Types.TyCon 1412068769125067428##64 8727214667407894081##64 T18982.$trModule T18982.$tc'Box2 1# T18982.$tc'Box1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18982.$tcEx2 :: GHC.Prim.Addr# @@ -108,7 +108,7 @@ T18982.$tcEx1 = GHC.Types.TrNameS T18982.$tcEx2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tcEx :: GHC.Types.TyCon -T18982.$tcEx = GHC.Types.TyCon 4376661818164435927## 18005417598910668817## T18982.$trModule T18982.$tcEx1 0# GHC.Types.krep$*Arr* +T18982.$tcEx = GHC.Types.TyCon 4376661818164435927##64 18005417598910668817##64 T18982.$trModule T18982.$tcEx1 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} $krep9 :: [GHC.Types.KindRep] @@ -136,7 +136,7 @@ T18982.$tc'Ex2 = GHC.Types.TrNameS T18982.$tc'Ex3 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tc'Ex :: GHC.Types.TyCon -T18982.$tc'Ex = GHC.Types.TyCon 14609381081172201359## 3077219645053200509## T18982.$trModule T18982.$tc'Ex2 2# T18982.$tc'Ex1 +T18982.$tc'Ex = GHC.Types.TyCon 14609381081172201359##64 3077219645053200509##64 T18982.$trModule T18982.$tc'Ex2 2# T18982.$tc'Ex1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18982.$tcGADT2 :: GHC.Prim.Addr# @@ -148,7 +148,7 @@ T18982.$tcGADT1 = GHC.Types.TrNameS T18982.$tcGADT2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tcGADT :: GHC.Types.TyCon -T18982.$tcGADT = GHC.Types.TyCon 9243924476135839950## 5096619276488416461## T18982.$trModule T18982.$tcGADT1 0# GHC.Types.krep$*Arr* +T18982.$tcGADT = GHC.Types.TyCon 9243924476135839950##64 5096619276488416461##64 T18982.$trModule T18982.$tcGADT1 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} $krep12 :: GHC.Types.KindRep @@ -168,7 +168,7 @@ T18982.$tc'GADT2 = GHC.Types.TrNameS T18982.$tc'GADT3 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tc'GADT :: GHC.Types.TyCon -T18982.$tc'GADT = GHC.Types.TyCon 2077850259354179864## 16731205864486799217## T18982.$trModule T18982.$tc'GADT2 0# T18982.$tc'GADT1 +T18982.$tc'GADT = GHC.Types.TyCon 2077850259354179864##64 16731205864486799217##64 T18982.$trModule T18982.$tc'GADT2 0# T18982.$tc'GADT1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18982.$tcExGADT2 :: GHC.Prim.Addr# @@ -180,7 +180,7 @@ T18982.$tcExGADT1 = GHC.Types.TrNameS T18982.$tcExGADT2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tcExGADT :: GHC.Types.TyCon -T18982.$tcExGADT = GHC.Types.TyCon 6470898418160489500## 10361108917441214060## T18982.$trModule T18982.$tcExGADT1 0# GHC.Types.krep$*Arr* +T18982.$tcExGADT = GHC.Types.TyCon 6470898418160489500##64 10361108917441214060##64 T18982.$trModule T18982.$tcExGADT1 0# GHC.Types.krep$*Arr* -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} $krep13 :: GHC.Types.KindRep @@ -208,10 +208,10 @@ T18982.$tc'ExGADT2 = GHC.Types.TrNameS T18982.$tc'ExGADT3 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T18982.$tc'ExGADT :: GHC.Types.TyCon -T18982.$tc'ExGADT = GHC.Types.TyCon 8468257409157161049## 5503123603717080600## T18982.$trModule T18982.$tc'ExGADT2 1# T18982.$tc'ExGADT1 +T18982.$tc'ExGADT = GHC.Types.TyCon 8468257409157161049##64 5503123603717080600##64 T18982.$trModule T18982.$tc'ExGADT2 1# T18982.$tc'ExGADT1 -- RHS size: {terms: 11, types: 10, coercions: 0, joins: 0/0} -T18982.$wi :: forall {a} {e}. (a GHC.Prim.~# Int) -> e -> GHC.Prim.Int# -> GHC.Prim.Int# +T18982.$wi :: forall {a} {e}. (a GHC.Prim.~# Int) => e -> GHC.Prim.Int# -> GHC.Prim.Int# T18982.$wi = \ (@a) (@e) (ww :: a GHC.Prim.~# Int) (ww1 :: e) (ww2 :: GHC.Prim.Int#) -> case ww1 of { __DEFAULT -> GHC.Prim.+# ww2 1# } -- RHS size: {terms: 15, types: 22, coercions: 1, joins: 0/0} @@ -219,7 +219,7 @@ i :: forall a. ExGADT a -> Int i = \ (@a) (ds :: ExGADT a) -> case ds of { ExGADT @e ww ww1 ww2 ww3 -> case ww3 of { GHC.Types.I# ww4 -> case T18982.$wi @a @e @~(ww :: a GHC.Prim.~# Int) ww2 ww4 of ww5 { __DEFAULT -> GHC.Types.I# ww5 } } } -- RHS size: {terms: 6, types: 7, coercions: 0, joins: 0/0} -T18982.$wh :: forall {a}. (a GHC.Prim.~# Int) -> GHC.Prim.Int# -> GHC.Prim.Int# +T18982.$wh :: forall {a}. (a GHC.Prim.~# Int) => GHC.Prim.Int# -> GHC.Prim.Int# T18982.$wh = \ (@a) (ww :: a GHC.Prim.~# Int) (ww1 :: GHC.Prim.Int#) -> GHC.Prim.+# ww1 1# -- RHS size: {terms: 14, types: 15, coercions: 1, joins: 0/0} ===================================== testsuite/tests/typecheck/should_compile/T17021a.hs ===================================== @@ -9,8 +9,16 @@ import GHC.Exts type family Id x where Id x = x -type LevId :: TYPE (Id LiftedRep) -> TYPE (Id LiftedRep) -newtype LevId x = MkLevId x +--type LevId :: TYPE (Id LiftedRep) -> TYPE (Id LiftedRep) +--newtype LevId x = MkLevId x -type LevId2 :: (r ~ Id LiftedRep) => TYPE r -> TYPE r +otype LevId2 :: (r ~ Id LiftedRep) => TYPE r -> TYPE r newtype LevId2 x = MkLevId2 x + +{- +MkLevId2 :: forall (r :: RuntimeRep). + forall (c :: r ~ Id LiftedRep) -> -- c is a TyVar + forall (x :: TYPE r). + x -> LevId2 @r @c x + +-} \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5924c88f91db71653fb83ffe2bd7afa828605c5e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5924c88f91db71653fb83ffe2bd7afa828605c5e You're receiving 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 Sep 17 19:15:49 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Sat, 17 Sep 2022 15:15:49 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] untwiddle a test option Message-ID: <63261ce5970ab_3b59a619d99194218993d@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 6cca1ebb by Luite Stegeman at 2022-09-17T21:15:17+02:00 untwiddle a test option - - - - - 1 changed file: - testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile Changes: ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/Makefile ===================================== @@ -1,4 +1,4 @@ .PHONY: GHCiPrimCall GHCiPrimCall: '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -v0 -c GHCiPrimCall_cmm.cmm - -'$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 + -'$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -e main GHCiPrimCall.hs GHCiPrimCall_cmm.o || echo $$? >&2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6cca1ebbdf31950c7c0a58a2ec032c6407a247e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6cca1ebbdf31950c7c0a58a2ec032c6407a247e9 You're receiving 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 Sep 17 20:48:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 16:48:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Clean up some. In particular: Message-ID: <632632b1b1b60_3b59a6194ffb5021921ad@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 08280089 by John Ericson at 2022-09-17T13:44:00-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 08eca4ec by John Ericson at 2022-09-17T13:44:53-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. - - - - - b62d7c1d by Ryan Scott at 2022-09-17T16:48:42-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. - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb74d46edf49a8ab8739245a5711d8984f2d9eac...b62d7c1d8e25fc254c68f1416070701d7c64fc17 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb74d46edf49a8ab8739245a5711d8984f2d9eac...b62d7c1d8e25fc254c68f1416070701d7c64fc17 You're receiving 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 Sep 17 23:19:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 17 Sep 2022 19:19:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] DeriveFunctor: Check for last type variables using dataConUnivTyVars Message-ID: <632655f1a96ad_3b59a6518382224583@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3763e72b by Ryan Scott at 2022-09-17T19:18:57-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. - - - - - 5 changed files: - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Infer.hs - + testsuite/tests/deriving/should_compile/T22167.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -538,8 +538,36 @@ functorLikeTraverse var (FT { ft_triv = caseTrivial, ft_var = caseVar go _ _ = (caseTrivial,False) --- Return all syntactic subterms of ty that contain var somewhere --- These are the things that should appear in instance constraints +-- | Return all syntactic subterms of a 'Type' that are applied to the 'TyVar' +-- argument. This determines what constraints should be inferred for derived +-- 'Functor', 'Foldable', and 'Traversable' instances in "GHC.Tc.Deriv.Infer". +-- For instance, if we have: +-- +-- @ +-- data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a)) +-- @ +-- +-- Then the following would hold: +-- +-- * @'deepSubtypesContaining' a Int@ would return @[]@, since @Int@ does not +-- contain the type variable @a@ at all. +-- +-- * @'deepSubtypesContaining' a a@ would return @[]@. Although the type @a@ +-- contains the type variable @a@, it is not /applied/ to @a@, which is the +-- criterion that 'deepSubtypesContaining' checks for. +-- +-- * @'deepSubtypesContaining' a (Maybe a)@ would return @[Maybe]@, as @Maybe@ +-- is applied to @a at . +-- +-- * @'deepSubtypesContaining' a (Either Int (Maybe a))@ would return +-- @[Either Int, Maybe]@. Both of these types are applied to @a@ through +-- composition. +-- +-- As used in "GHC.Tc.Deriv.Infer", the 'Type' argument will always come from +-- 'derivDataConInstArgTys', so it is important that the 'TyVar' comes from +-- 'dataConUnivTyVars' to match. Make sure /not/ to take the 'TyVar' from +-- 'tyConTyVars', as these differ from the 'dataConUnivTyVars' when the data +-- type is a GADT. (See #22167 for what goes wrong if 'tyConTyVars' is used.) deepSubtypesContaining :: TyVar -> Type -> [TcType] deepSubtypesContaining tv = functorLikeTraverse tv ===================================== compiler/GHC/Tc/Deriv/Generics.hs ===================================== @@ -93,10 +93,25 @@ gen_Generic_binds gk loc dit = do ************************************************************************ -} +-- | Called by 'GHC.Tc.Deriv.Infer.inferConstraints'; generates a list of +-- types, each of which must be a 'Functor' in order for the 'Generic1' +-- instance to work. For instance, if we have: +-- +-- @ +-- data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a)) +-- @ +-- +-- Then @'get_gen1_constrained_tys' a (f (g a))@ would return @[Either Int]@, +-- as a derived 'Generic1' instance would need to call 'fmap' at that type. +-- Invoking @'get_gen1_constrained_tys' a@ on any of the other fields would +-- return @[]@. +-- +-- 'get_gen1_constrained_tys' is very similar in spirit to +-- 'deepSubtypesContaining' in "GHC.Tc.Deriv.Functor". Just like with +-- 'deepSubtypesContaining', it is important that the 'TyVar' argument come +-- from 'dataConUnivTyVars'. (See #22167 for what goes wrong if 'tyConTyVars' +-- is used.) get_gen1_constrained_tys :: TyVar -> Type -> [Type] --- called by GHC.Tc.Deriv.Infer.inferConstraints; generates a list of --- types, each of which must be a Functor in order for the Generic1 instance to --- work. get_gen1_constrained_tys argVar = argTyFold argVar $ ArgTyAlg { ata_rec0 = const [] , ata_par1 = [], ata_rec1 = const [] ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -178,9 +178,10 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys -- Constraints arising from the arguments of each constructor con_arg_constraints - :: (CtOrigin -> TypeOrKind - -> Type - -> [(ThetaSpec, Maybe Subst)]) + :: ([TyVar] -> CtOrigin + -> TypeOrKind + -> Type + -> [(ThetaSpec, Maybe Subst)]) -> (ThetaSpec, [TyVar], [TcType], DerivInstTys) con_arg_constraints get_arg_constraints = let -- Constraints from the fields of each data constructor. @@ -195,7 +196,8 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys , not (isUnliftedType arg_ty) , let orig = DerivOriginDC data_con arg_n wildcard , preds_and_mbSubst - <- get_arg_constraints orig arg_t_or_k arg_ty + <- get_arg_constraints (dataConUnivTyVars data_con) + orig arg_t_or_k arg_ty ] -- Stupid constraints from DatatypeContexts. Note that we -- must gather these constraints from the data constructors, @@ -237,21 +239,39 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys is_functor_like = tcTypeKind inst_ty `tcEqKind` typeToTypeKind || is_generic1 - get_gen1_constraints :: Class -> CtOrigin -> TypeOrKind -> Type - -> [(ThetaSpec, Maybe Subst)] - get_gen1_constraints functor_cls orig t_or_k ty + get_gen1_constraints :: + Class + -> [TyVar] -- The universally quantified type variables for the + -- data constructor + -> CtOrigin -> TypeOrKind -> Type + -> [(ThetaSpec, Maybe Subst)] + get_gen1_constraints functor_cls dc_univs orig t_or_k ty = mk_functor_like_constraints orig t_or_k functor_cls $ - get_gen1_constrained_tys last_tv ty - - get_std_constrained_tys :: CtOrigin -> TypeOrKind -> Type - -> [(ThetaSpec, Maybe Subst)] - get_std_constrained_tys orig t_or_k ty + get_gen1_constrained_tys last_dc_univ ty + where + -- If we are deriving an instance of 'Generic1' and have made + -- it this far, then there should be at least one universal type + -- variable, making this use of 'last' safe. + last_dc_univ = assert (not (null dc_univs)) $ + last dc_univs + + get_std_constrained_tys :: + [TyVar] -- The universally quantified type variables for the + -- data constructor + -> CtOrigin -> TypeOrKind -> Type + -> [(ThetaSpec, Maybe Subst)] + get_std_constrained_tys dc_univs orig t_or_k ty | is_functor_like = mk_functor_like_constraints orig t_or_k main_cls $ - deepSubtypesContaining last_tv ty + deepSubtypesContaining last_dc_univ ty | otherwise = [( [mk_cls_pred orig t_or_k main_cls ty] , Nothing )] + where + -- If 'is_functor_like' holds, then there should be at least one + -- universal type variable, making this use of 'last' safe. + last_dc_univ = assert (not (null dc_univs)) $ + last dc_univs mk_functor_like_constraints :: CtOrigin -> TypeOrKind -> Class -> [Type] @@ -279,9 +299,6 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys , tcUnifyTy ki typeToTypeKind ) - rep_tc_tvs = tyConTyVars rep_tc - last_tv = last rep_tc_tvs - -- Extra Data constraints -- The Data class (only) requires that for -- instance (...) => Data (T t1 t2) @@ -320,7 +337,7 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys -- Generic1 needs Functor -- See Note [Getting base classes] | is_generic1 - -> assert (rep_tc_tvs `lengthExceeds` 0) $ + -> assert (tyConTyVars rep_tc `lengthExceeds` 0) $ -- Generic1 has a single kind variable assert (cls_tys `lengthIs` 1) $ do { functorClass <- lift $ tcLookupClass functorClassName ===================================== testsuite/tests/deriving/should_compile/T22167.hs ===================================== @@ -0,0 +1,24 @@ +module T22167 where + +import GHC.Generics (Generic1) + +data T1 f a = MkT1 (f a) + deriving (Functor, Foldable, Traversable) + +data T2 f a where + MkT2 :: f a -> T2 f a + deriving (Functor, Foldable, Traversable) + +-- A slightly more complicated example from the `syntactic` library +data (sym1 :+: sym2) sig + where + InjL :: sym1 a -> (sym1 :+: sym2) a + InjR :: sym2 a -> (sym1 :+: sym2) a + deriving (Functor, Foldable, Traversable) + +-- Test Generic1 instances with inferred Functor constraints +data G1 f g a = MkG1 (f (g a)) deriving Generic1 + +data G2 f g a where + MkG2 :: f (g a) -> G2 f g a + deriving Generic1 ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -139,3 +139,4 @@ test('T20387', normal, compile, ['']) test('T20501', normal, compile, ['']) test('T20719', normal, compile, ['']) test('T20994', normal, compile, ['']) +test('T22167', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3763e72b4c951669ebb79a6760fe390a9f9d41dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3763e72b4c951669ebb79a6760fe390a9f9d41dd You're receiving 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 Sep 17 23:50:54 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 17 Sep 2022 19:50:54 -0400 Subject: [Git][ghc/ghc][wip/T21623] More wibbles Message-ID: <63265d5ef0f67_3b59a620aecc142231994@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 883cb479 by Simon Peyton Jones at 2022-09-18T00:47:11+01:00 More wibbles Reaedy for RAE review - - - - - 12 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/RoughMap.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Types/Id/Make.hs Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1901,8 +1901,8 @@ doubleDataCon = pcDataCon doubleDataConName [] [doublePrimTy] doubleTyCon * * ********************************************************************* -} -{- Note [Boxing constructors} - +{- Note [Boxing constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In ghc-prim:GHC.Types we have a family of data types, one for each RuntimeRep that "box" unlifted values into a (boxed, lifted) value of kind Type. For example @@ -1913,6 +1913,9 @@ that "box" unlifted values into a (boxed, lifted) value of kind Type. For exampl Then we can package an `Int#` into an `IntBox` with `MkIntBox`. We can also package up a (lifted) Constraint as a value of kind Type. +There are a fixed number of RuntimeReps, so we only need a fixed number +of boxing types. (For TupleRep we need to box recursively; not yet done.) + This is used: * In desugaring, when we need to package up a bunch of values into a tuple, ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -742,13 +742,19 @@ So for example: a ~ b :: CONSTRAINT (BoxedRep Lifted) a ~# b :: CONSTRAINT (TupleRep []) -Note that: +Constraints are mostly lifted, but unlifted ones are useful too. +Specifically (a ~# b) :: CONSTRAINT (TupleRep []) -* Type and Constraint are considered distinct throughout GHC. But they - are not /apart/: see Note [Type and Constraint are not apart] +Wrinkles -* Constraints are mostly lifted, but unlifted ones are useful too. - Specifically (a ~# b) :: CONSTRAINT (TupleRep []) +(W1) Type and Constraint are considered distinct throughout GHC. But they + are not /apart/: see Note [Type and Constraint are not apart] + +(W2) 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]. + +(W3) We need a TypeOrConstraint flag in LitRubbish. Note [Type and Constraint are not apart] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -782,6 +788,13 @@ irretrievably overlap with: instance C (Proxy @Constraint a) where ... +Wrinkles + +(W1) In GHC.Core.RoughMap.roughMapTyConName we are careful to map + TYPE and CONSTRAINT to the same rough-map key. + **ToDo**: explain why + + Note [RuntimeRep polymorphism] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generally speaking, you can't be polymorphic in `RuntimeRep`. E.g ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -704,7 +704,6 @@ of Coercion, and they perform very basic optimizations. Note [Role twiddling functions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - There are a plethora of functions for twiddling roles: mkSubCo: Requires a nominal input coercion and always produces a ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -430,16 +430,16 @@ data DataCon -- Existentially-quantified type and coercion vars [x,y] -- For an example involving coercion variables, - -- Why tycovars? See Note [Existential coercion variables] + -- Why TyCoVars? See Note [Existential coercion variables] dcExTyCoVars :: [TyCoVar], -- INVARIANT: the UnivTyVars and ExTyCoVars all have distinct OccNames -- Reason: less confusing, and easier to generate Iface syntax -- The type/coercion vars in the order the user wrote them [c,y,x,b] - -- INVARIANT: the set of tyvars in dcUserTyVarBinders is exactly the set - -- of tyvars (*not* covars) of dcExTyCoVars unioned with the - -- set of dcUnivTyVars whose tyvars do not appear in dcEqSpec + -- INVARIANT(dataConTyVars: the set of tyvars in dcUserTyVarBinders is + -- exactly the set of tyvars (*not* covars) of dcExTyCoVars unioned + -- with the set of dcUnivTyVars whose tyvars do not appear in dcEqSpec -- See Note [DataCon user type variable binders] dcUserTyVarBinders :: [InvisTVBinder], @@ -672,9 +672,9 @@ the result, and get this type for the "true underlying" worker data con: (We don't need to make up a fresh tyvar for the second arg; 'd' will do.) -End of Reasons +--- End of Reasons --- -Invariant: the set of tyvars in dcUserTyVarBinders +INVARIANT(dataConTyVars): the set of tyvars in dcUserTyVarBinders consists precisely of: * The set of tyvars in dcUnivTyVars whose type variables do not appear in ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1599,19 +1599,25 @@ lintBinder site var linterF lintTyBndr :: TyVar -> (LintedTyCoVar -> LintM a) -> LintM a lintTyBndr = lintTyCoBndr -- We could specialise it, I guess --- lintCoBndr :: CoVar -> (LintedTyCoVar -> LintM a) -> LintM a --- lintCoBndr = lintTyCoBndr -- We could specialise it, I guess - lintTyCoBndr :: TyCoVar -> (LintedTyCoVar -> LintM a) -> LintM a lintTyCoBndr tcv thing_inside = do { subst <- getSubst - ; kind' <- lintType (varType tcv) + ; tcv_type' <- lintType (varType tcv) ; let tcv' = uniqAway (getSubstInScope subst) $ - setVarType tcv kind' + setVarType tcv tcv_type' subst' = extendTCvSubstWithClone subst tcv tcv' - ; when (isCoVar tcv) $ - lintL (isCoVarType kind') - (text "CoVar with non-coercion type:" <+> pprTyVar tcv) + + -- See (FORALL1) and (FORALL2) in GHC.Core.Type + ; if (isTyVar tcv) + then -- Check that in (forall (a:ki). blah) we have ki:Type + lintL (tcIsLiftedTypeKind (typeKind tcv_type')) $ + hang (text "TyCoVar whose kind does not have kind Type") + 2 (ppr tcv' <+> dcolon <+> ppr (typeKind tcv_type')) + else -- Check that in (forall (cv::ty). blah), + -- then ty looks like (t1 ~# t2) + lintL (isCoVarType tcv_type') $ + text "CoVar with non-coercion type:" <+> pprTyVar tcv + ; updateSubst subst' (thing_inside tcv') } lintIdBndrs :: forall a. TopLevelFlag -> [Id] -> ([LintedId] -> LintM a) -> LintM a @@ -1693,7 +1699,7 @@ lintValueType ty = addLoc (InType ty) $ do { ty' <- lintType ty ; let sk = typeKind ty' - ; lintL (classifiesTypeWithValues sk) $ + ; lintL (isTYPEorCONSTRAINT sk) $ hang (text "Ill-kinded type:" <+> ppr ty) 2 (text "has kind:" <+> ppr sk) ; return ty' } @@ -1854,7 +1860,7 @@ lintTySynFamApp report_unsat ty tc tys -- Confirms that a type is really TYPE r or Constraint checkValueType :: LintedType -> SDoc -> LintM () checkValueType ty doc - = lintL (classifiesTypeWithValues kind) + = lintL (isTYPEorCONSTRAINT kind) (text "Non-Type-like kind when Type-like expected:" <+> ppr kind $$ text "when checking" <+> doc) where @@ -1866,8 +1872,8 @@ lintArrow :: SDoc -> LintedType -> LintedType -> LintedType -> LintM () -- See Note [GHC Formalism] lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw -- or lintArrow "coercion `blah'" k1 k2 kw - = do { unless (classifiesTypeWithValues k1) (report (text "argument") k1) - ; unless (classifiesTypeWithValues k2) (report (text "result") k2) + = do { unless (isTYPEorCONSTRAINT k1) (report (text "argument") k1) + ; unless (isTYPEorCONSTRAINT k2) (report (text "result") k2) ; unless (isMultiplicityTy kw) (report (text "multiplicity") kw) } where k1 = typeKind t1 @@ -2206,8 +2212,8 @@ lintCoercion co@(UnivCo prov r ty1 ty2) k2 = typeKind ty2' ; prov' <- lint_prov k1 k2 prov - ; when (r /= Phantom && classifiesTypeWithValues k1 - && classifiesTypeWithValues k2) + ; when (r /= Phantom && isTYPEorCONSTRAINT k1 + && isTYPEorCONSTRAINT k2) (checkTypes ty1 ty2) ; return (UnivCo prov' r ty1' ty2') } ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -331,33 +331,7 @@ mkStringExprFSWith ids str ************************************************************************ -} -{- Note [Big tuples] -~~~~~~~~~~~~~~~~~~~~ -GHCs built-in tuples can only go up to 'mAX_TUPLE_SIZE' in arity, but -we might conceivably want to build such a massive tuple as part of the -output of a desugaring stage (notably that for list comprehensions). - -We call tuples above this size "big tuples", and emulate them by -creating and pattern matching on >nested< tuples that are expressible -by GHC. - -Nesting policy: it's better to have a 2-tuple of 10-tuples (3 objects) -than a 10-tuple of 2-tuples (11 objects), so we want the leaves of any -construction to be big. - -If you just use the 'mkBigCoreTup', 'mkBigCoreVarTupTy', 'mkBigTupleSelector' -and 'mkBigTupleCase' functions to do all your work with tuples you should be -fine, and not have to worry about the arity limitation at all. - - -`mkBigCoreVarTup` builds a tuple; the inverse to `mkBigTupleSelector`. - -* If it has only one element, it is the identity function. - -* If there are more elements than a big tuple can have, it nests - the tuples. See Note [Big tuples] - -Note [Flattening one-tuples] +{- Note [Flattening one-tuples] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This family of functions creates a tuple of variables/expressions/types. mkCoreTup [e1,e2,e3] = (e1,e2,e3) @@ -387,6 +361,7 @@ This arose from discussions in #16881. One-tuples that arise internally depend on the circumstance; often flattening is a good idea. Decisions are made on a case-by-case basis. +'mkCoreTupSolo` and `mkBigCoreVarTupSolo` build tuples without flattening. -} -- | Build the type of a small tuple that holds the specified variables @@ -435,6 +410,39 @@ mkCoreUbxSum arity alt tys exp ++ map Type tys ++ [exp]) +{- Note [Big tuples] +~~~~~~~~~~~~~~~~~~~~ +"Big" tuples (`mkBigCoreTup` and friends) are more general than "small" +ones (`mkCoreTup` and friend) in two ways. + +1. GHCs built-in tuples can only go up to 'mAX_TUPLE_SIZE' in arity, but + we might conceivably want to build such a massive tuple as part of the + output of a desugaring stage (notably that for list comprehensions). + + `mkBigCoreTup` encodes such big tuples by creating and pattern + matching on /nested/ small tuples that are directly expressible by + GHC. + + Nesting policy: it's better to have a 2-tuple of 10-tuples (3 objects) + than a 10-tuple of 2-tuples (11 objects), so we want the leaves of any + construction to be big. + +2. When desugaring arrows we gather up a tuple of free variables, which + may include dictionries (of kind Constraint) and unboxed values. + + These can't live in a tuple. `mkBigCoreTup` encodes such tuples by + boxing up the offending arguments: see Note [Boxing constructors] + in GHC.Builtin.Types. + +If you just use the 'mkBigCoreTup', 'mkBigCoreVarTupTy', 'mkBigTupleSelector' +and 'mkBigTupleCase' functions to do all your work with tuples you should be +fine, and not have to worry about the arity limitation, or kind limitation at +all. + +The "big" tuple operations flatten 1-tuples just like "small" tuples. +But see Note [Don't flatten tuples from HsSyn] +-} + mkBigCoreVarTupSolo :: [Id] -> CoreExpr -- Same as mkBigCoreVarTup, but -- - one-tuples are not flattened ===================================== compiler/GHC/Core/RoughMap.hs ===================================== @@ -286,7 +286,7 @@ roughMatchTyConName tc = tYPETyConName -- TYPE and CONSTRAINT are not apart, so they must use -- the same rough-map key. We arbitrarily use TYPE. -- See Note [Type and Constraint are not apart] - -- in GHC.Builtin.Types.Prim + -- wrinkle (W1) in GHC.Builtin.Types.Prim | otherwise = assertPpr (isGenerativeTyCon tc Nominal) (ppr tc) tc_name where ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -1401,8 +1401,8 @@ All data constructors can be promoted to become a type constructor, via the PromotedDataCon alternative in GHC.Core.TyCon. * The TyCon promoted from a DataCon has the *same* Name and Unique as - the DataCon. Eg. If the data constructor Data.Maybe.Just(unique 78, - say) is promoted to a TyCon whose name is Data.Maybe.Just(unique 78) + the DataCon. Eg. If the data constructor Data.Maybe.Just(unique 78) + is promoted to a TyCon whose name is Data.Maybe.Just(unique 78) * We promote the *user* type of the DataCon. Eg data T = MkT {-# UNPACK #-} !(Bool, Bool) ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -231,7 +231,7 @@ module GHC.Core.Type ( tidyForAllTyBinder, tidyForAllTyBinders, -- * Kinds - classifiesTypeWithValues, + isTYPEorCONSTRAINT, isConcrete, isFixedRuntimeRepKind, ) where @@ -2519,10 +2519,12 @@ Note [Kinding rules for types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here are the kinding rules for types - t1 : TYPE rep1 - t2 : TYPE rep2 + torc1 is TYPE or CONSTRAINT + torc2 is TYPE or CONSTRAINT + t1 : torc1 rep1 + t2 : torc2 rep2 (FUN) ---------------- - t1 -> t2 : Type + t1 -> t2 : torc2 LiftedRep ty : TYPE rep `a` is not free in rep @@ -2544,18 +2546,32 @@ Here are the kinding rules for types (PRED2) --------------------- t1 => t2 : Constraint - ty : TYPE rep + torc is TYPE or CONSTRAINT + ty : body_torc rep + ki : Type + `a` is a type variable `a` is not free in rep (FORALL1) ----------------------- - forall a. ty : TYPE rep + forall (a::ki). ty : torc rep - ty : Constraint + torc is TYPE or CONSTRAINT + ty : body_torc rep + `c` is not free in rep + `c` is free in ty -- Surprise 1! (FORALL2) ------------------------- - forall a. ty : Constraint + forall (cv::k1 ~#{N,R} k2). ty : body_torc LiftedRep + -- Surprise 2! Note that: -* The only way we distinguish '->' from '=>' is by the fact - that the argument is a PredTy. Both are FunTys +* (FORALL1) rejects (forall (a::Maybe). blah) + +* (FORALL2) Surprise 1: + See GHC.Core.TyCo.Rep Note [Unused coercion variable in ForAllTy] + +* (FORALL2) Surprise 2: coercion abstractions are not erased, so + this must be LiftedRep, just liike (FUN). (FORALL2) is just a + dependent form of (FUN). + Note [Phantom type variables in kinds] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2578,6 +2594,7 @@ occCheckExpand to expand any type synonyms in the kind of 'ty' to eliminate 'a'. See kinding rule (FORALL) in Note [Kinding rules for types] + See also * GHC.Core.Type.occCheckExpand * GHC.Core.Utils.coreAltsType @@ -2613,16 +2630,21 @@ typeKind ty@(ForAllTy {}) -- We must make sure tv does not occur in kind -- As it is already out of scope! -- See Note [Phantom type variables in kinds] - Just k' -> k' Nothing -> pprPanic "typeKind" (ppr ty $$ ppr tvs $$ ppr body <+> dcolon <+> ppr body_kind) + + Just k' | all isTyVar tvs -> k' -- Rule (FORALL1) + | otherwise -> lifted_kind_from_body -- Rule (FORALL2) where (tvs, body) = splitForAllTyVars ty body_kind = typeKind body ---------------------------------------------- --- Utilities to be used in GHC.Core.Unify, --- which uses "tc" functions + lifted_kind_from_body -- Implements (FORALL2) + = case sORTKind_maybe body_kind of + Just (ConstraintLike, _) -> constraintKind + Just (TypeLike, _) -> liftedTypeKind + Nothing -> pprPanic "typeKind" (ppr body_kind) + --------------------------------------------- sORTKind_maybe :: Kind -> Maybe (TypeOrConstraint, Type) @@ -2651,7 +2673,7 @@ typeTypeOrConstraint ty isPredTy :: HasDebugCallStack => Type -> Bool -- Precondition: expects a type that classifies values -- See Note [Types for coercions, predicates, and evidence] in GHC.Core.TyCo.Rep --- Returns True for types of kind Constraint, False for ones of kind Type +-- Returns True for types of kind (CONSTRAINT _), False for ones of kind (TYPE _) isPredTy ty = case typeTypeOrConstraint ty of TypeLike -> False ConstraintLike -> True @@ -2659,9 +2681,9 @@ isPredTy ty = case typeTypeOrConstraint ty of ----------------------------------------- -- | Does this classify a type allowed to have values? Responds True to things -- like *, TYPE Lifted, TYPE IntRep, TYPE v, Constraint. -classifiesTypeWithValues :: Kind -> Bool +isTYPEorCONSTRAINT :: Kind -> Bool -- ^ True of a kind `TYPE _` or `CONSTRAINT _` -classifiesTypeWithValues k = isJust (sORTKind_maybe k) +isTYPEorCONSTRAINT k = isJust (sORTKind_maybe k) isConstraintLikeKind :: Kind -> Bool -- True of (CONSTRAINT _) @@ -2679,20 +2701,14 @@ isConstraintKind kind tcIsLiftedTypeKind :: Kind -> Bool -- ^ Is this kind equivalent to 'Type' i.e. TYPE LiftedRep? --- --- This considers 'Constraint' to be distinct from 'Type'. For a version that --- treats them as the same type, see 'isLiftedTypeKind'. tcIsLiftedTypeKind kind | Just (TypeLike, rep) <- sORTKind_maybe kind = isLiftedRuntimeRep rep | otherwise = False --- | Is this kind equivalent to @TYPE (BoxedRep l)@ for some @l :: Levity@? --- --- This considers 'Constraint' to be distinct from 'Type'. For a version that --- treats them as the same type, see 'isLiftedTypeKind'. tcIsBoxedTypeKind :: Kind -> Bool +-- ^ Is this kind equivalent to @TYPE (BoxedRep l)@ for some @l :: Levity@? tcIsBoxedTypeKind kind | Just (TypeLike, rep) <- sORTKind_maybe kind = isBoxedRuntimeRep rep @@ -2760,7 +2776,7 @@ argsHaveFixedRuntimeRep ty -- __Precondition:__ The type has kind `TYPE blah` or `CONSTRAINT blah` isFixedRuntimeRepKind :: HasDebugCallStack => Kind -> Bool isFixedRuntimeRepKind k - = assertPpr (classifiesTypeWithValues k) (ppr k) $ + = assertPpr (isTYPEorCONSTRAINT k) (ppr k) $ -- the isLiftedTypeKind check is necessary b/c of Constraint isConcrete k ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -369,6 +369,7 @@ instStupidTheta orig theta -- | Given ty::forall k1 k2. k, instantiate all the invisible forall-binders -- returning ty @kk1 @kk2 :: k[kk1/k1, kk2/k1] +-- Called only to instantiate kinds, in user-written type signatures tcInstInvisibleTyBinders :: TcType -> TcKind -> TcM (TcType, TcKind) tcInstInvisibleTyBinders ty kind = do { (extra_args, kind') <- tcInstInvisibleTyBindersN n_invis kind @@ -377,6 +378,7 @@ tcInstInvisibleTyBinders ty kind n_invis = invisibleTyBndrCount kind tcInstInvisibleTyBindersN :: Int -> TcKind -> TcM ([TcType], TcKind) +-- Called only to instantiate kinds, in user-written type signatures tcInstInvisibleTyBindersN 0 kind = return ([], kind) tcInstInvisibleTyBindersN n ty @@ -394,20 +396,22 @@ tcInstInvisibleTyBindersN n ty | otherwise = return ([], substTy subst kind) --- | Used only in *types* tcInstInvisibleTyBinder :: Subst -> PiTyVarBinder -> TcM (Subst, TcType) +-- Called only to instantiate kinds, in user-written type signatures + tcInstInvisibleTyBinder subst (Named (Bndr 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)) - -- Equality is the *only* constraint currently handled in types. + -- 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 (isInvisibleAnonArg af) $ do { co <- unifyKind Nothing k1 k2 - ; arg' <- mk co - ; return (subst, arg') } + ; return (subst, mk co) } | otherwise -- This should never happen -- See GHC.Core.TyCo.Rep Note [Constraints in kinds] @@ -415,8 +419,8 @@ tcInstInvisibleTyBinder subst (Anon ty af) ------------------------------- get_eq_tys_maybe :: Type - -> Maybe ( Coercion -> TcM Type - -- given a coercion proving t1 ~# t2, produce the + -> Maybe ( Coercion -> Type + -- Given a coercion proving t1 ~# t2, produce the -- right instantiation for the PiTyVarBinder at hand , Type -- t1 , Type -- t2 @@ -426,30 +430,27 @@ get_eq_tys_maybe ty -- Lifted heterogeneous equality (~~) | Just (tc, [_, _, k1, k2]) <- splitTyConApp_maybe ty , tc `hasKey` heqTyConKey - = Just (\co -> mkHEqBoxTy co k1 k2, k1, k2) + = Just (mkHEqBoxTy k1 k2, k1, k2) -- Lifted homogeneous equality (~) | Just (tc, [_, k1, k2]) <- splitTyConApp_maybe ty , tc `hasKey` eqTyConKey - = Just (\co -> mkEqBoxTy co k1 k2, k1, k2) + = Just (mkEqBoxTy k1 k2, k1, k2) | otherwise = Nothing -- | This takes @a ~# b@ and returns @a ~~ b at . -mkHEqBoxTy :: TcCoercion -> Type -> Type -> TcM Type --- monadic just for convenience with mkEqBoxTy -mkHEqBoxTy co ty1 ty2 - = return $ - mkTyConApp (promoteDataCon heqDataCon) [k1, k2, ty1, ty2, mkCoercionTy co] +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 :: TcCoercion -> Type -> Type -> TcM Type -mkEqBoxTy co ty1 ty2 - = return $ - mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] +mkEqBoxTy :: Type -> Type -> TcCoercion -> Type +mkEqBoxTy ty1 ty2 co + = mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] where k = typeKind ty1 {- ********************************************************************* ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -128,7 +128,7 @@ module GHC.Tc.Utils.TcType ( -------------------------------- -- Reexported from Kind Kind, liftedTypeKind, constraintKind, - isLiftedTypeKind, isUnliftedTypeKind, classifiesTypeWithValues, + isLiftedTypeKind, isUnliftedTypeKind, isTYPEorCONSTRAINT, -------------------------------- -- Reexported from Type ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -1744,24 +1744,24 @@ But actually we give 'noinline' a wired-in name for three distinct reasons: noinline (f x y) ==> noinline f x y This is done in GHC.HsToCore.Utils.mkCoreAppDs. This is only needed for noinlineId, not noInlineConstraintId (wrinkle - (a) below), because the latter never shows up in user code. + (W1) below), because the latter never shows up in user code. Wrinkles -a) Sometimes case (2) above needs to apply `noinline` to a type of kind - Constraint; e.g. +(W1) Sometimes case (2) above needs to apply `noinline` to a type of kind + Constraint; e.g. noinline @(Eq Int) $dfEqInt - We don't have type-or-kind polymorphism, so we simply have two `inline` - Ids, namely `noinlineId` and `noinlineConstraintId`. - -b) Note that noinline as currently implemented can hide some simplifications - since it hides strictness from the demand analyser. Specifically, the - demand analyser will treat 'noinline f x' as lazy in 'x', even if the - demand signature of 'f' specifies that it is strict in its argument. We - considered fixing this this by adding a special case to the demand - analyser to address #16588. However, the special case seemed like a large - and expensive hammer to address a rare case and consequently we rather - opted to use a more minimal solution. + We don't have type-or-kind polymorphism, so we simply have two `inline` + Ids, namely `noinlineId` and `noinlineConstraintId`. + +(W2) Note that noinline as currently implemented can hide some simplifications + since it hides strictness from the demand analyser. Specifically, the + demand analyser will treat 'noinline f x' as lazy in 'x', even if the + demand signature of 'f' specifies that it is strict in its argument. We + considered fixing this this by adding a special case to the demand + analyser to address #16588. However, the special case seemed like a large + and expensive hammer to address a rare case and consequently we rather + opted to use a more minimal solution. Note [nospecId magic] ~~~~~~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/883cb4793c9f65f82dec512a28639dacec77dc39 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/883cb4793c9f65f82dec512a28639dacec77dc39 You're receiving 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 Sep 18 01:28:19 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Sat, 17 Sep 2022 21:28:19 -0400 Subject: [Git][ghc/ghc][wip/wither-eq1-and-friends] Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking Message-ID: <6326743325c08_3b59a6194ffb5022452d0@gitlab.mail> sheaf pushed to branch wip/wither-eq1-and-friends at Glasgow Haskell Compiler / GHC Commits: f53f0f1f by John Ericson at 2022-09-18T03:28:06+02: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. - - - - - 6 changed files: - libraries/base/Data/Functor/Classes.hs - libraries/base/Data/Functor/Compose.hs - libraries/base/Data/Functor/Product.hs - libraries/base/Data/Functor/Sum.hs - libraries/base/changelog.md - utils/haddock Changes: ===================================== libraries/base/Data/Functor/Classes.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE QuantifiedConstraints #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Classes @@ -91,8 +94,18 @@ import Text.Show (showListWith) -- | Lifting of the 'Eq' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftEq (==)@ = @(==)@ +-- +-- This class therefore represents the generalization of 'Eq' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Eq1 f where +class (forall a. Eq a => Eq (f a)) => Eq1 f where -- | Lift an equality test through the type constructor. -- -- The function will usually be applied to an equality function, @@ -102,6 +115,10 @@ class Eq1 f where -- -- @since 4.9.0.0 liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool + default liftEq + :: (f ~ f' c, Eq2 f', Eq c) + => (a -> b -> Bool) -> f a -> f b -> Bool + liftEq = liftEq2 (==) -- | Lift the standard @('==')@ function through the type constructor. -- @@ -111,8 +128,18 @@ eq1 = liftEq (==) -- | Lifting of the 'Ord' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftCompare compare@ = 'compare' +-- +-- This class therefore represents the generalization of 'Ord' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class (Eq1 f) => Ord1 f where +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where -- | Lift a 'compare' function through the type constructor. -- -- The function will usually be applied to a comparison function, @@ -122,6 +149,10 @@ class (Eq1 f) => Ord1 f where -- -- @since 4.9.0.0 liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + default liftCompare + :: (f ~ f' c, Ord2 f', Ord c) + => (a -> b -> Ordering) -> f a -> f b -> Ordering + liftCompare = liftCompare2 compare -- | Lift the standard 'compare' function through the type constructor. -- @@ -131,6 +162,22 @@ compare1 = liftCompare compare -- | Lifting of the 'Read' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftReadsPrec readsPrec readList@ = 'readsPrec' +-- +-- @liftReadList readsPrec readList@ = 'readList' +-- +-- @liftReadPrec readPrec readListPrec@ = 'readPrec' +-- +-- @liftReadListPrec readPrec readListPrec@ = 'readListPrec' +-- +-- This class therefore represents the generalization of 'Read' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- Both 'liftReadsPrec' and 'liftReadPrec' exist to match the interface -- provided in the 'Read' type class, but it is recommended to implement -- 'Read1' instances using 'liftReadPrec' as opposed to 'liftReadsPrec', since @@ -145,7 +192,7 @@ compare1 = liftCompare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read1 f where +class (forall a. Read a => Read (f a)) => Read1 f where {-# MINIMAL liftReadsPrec | liftReadPrec #-} -- | 'readsPrec' function for an application of the type constructor @@ -219,14 +266,30 @@ liftReadListPrecDefault rp rl = list (liftReadPrec rp rl) -- | Lifting of the 'Show' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftShowsPrec showsPrec showList@ = 'showsPrec' +-- +-- @liftShowList showsPrec showList@ = 'showList' +-- +-- This class therefore represents the generalization of 'Show' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Show1 f where +class (forall a. Show a => Show (f a)) => Show1 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. -- -- @since 4.9.0.0 liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + default liftShowsPrec + :: (f ~ f' b, Show2 f', Show b) + => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + liftShowsPrec = liftShowsPrec2 showsPrec showList -- | 'showList' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. @@ -248,7 +311,7 @@ showsPrec1 = liftShowsPrec showsPrec showList -- | Lifting of the 'Eq' class to binary type constructors. -- -- @since 4.9.0.0 -class Eq2 f where +class (forall a. Eq a => Eq1 (f a)) => Eq2 f where -- | Lift equality tests through the type constructor. -- -- The function will usually be applied to equality functions, @@ -268,7 +331,7 @@ eq2 = liftEq2 (==) (==) -- | Lifting of the 'Ord' class to binary type constructors. -- -- @since 4.9.0.0 -class (Eq2 f) => Ord2 f where +class (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 f where -- | Lift 'compare' functions through the type constructor. -- -- The function will usually be applied to comparison functions, @@ -302,7 +365,7 @@ compare2 = liftCompare2 compare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read2 f where +class (forall a. Read a => Read1 (f a)) => Read2 f where {-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-} -- | 'readsPrec' function for an application of the type constructor @@ -385,7 +448,7 @@ liftReadListPrec2Default rp1 rl1 rp2 rl2 = list (liftReadPrec2 rp1 rl1 rp2 rl2) -- | Lifting of the 'Show' class to binary type constructors. -- -- @since 4.9.0.0 -class Show2 f where +class (forall a. Show a => Show1 (f a)) => Show2 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument types. -- ===================================== libraries/base/Data/Functor/Compose.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | @@ -32,7 +33,7 @@ import Data.Coerce (coerce) import Data.Data (Data) import Data.Type.Equality (TestEquality(..), (:~:)(..)) import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () infixr 9 `Compose` @@ -47,6 +48,17 @@ newtype Compose f g a = Compose { getCompose :: f (g a) } , Monoid -- ^ @since 4.16.0.0 ) +-- Instances of Prelude classes + +-- | @since 4.18.0.0 +deriving instance Eq (f (g a)) => Eq (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Ord (f (g a)) => Ord (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Read (f (g a)) => Read (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Show (f (g a)) => Show (Compose f g a) + -- Instances of lifted Prelude classes -- | @since 4.9.0.0 @@ -77,27 +89,6 @@ instance (Show1 f, Show1 g) => Show1 (Compose f g) where sp' = liftShowsPrec sp sl sl' = liftShowList sp sl --- Instances of Prelude classes - --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where - (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Compose f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where - showsPrec = showsPrec1 - -- Functor instances -- | @since 4.9.0.0 ===================================== libraries/base/Data/Functor/Product.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Product @@ -28,7 +29,7 @@ import Control.Monad.Zip (MonadZip(mzipWith)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted product of functors. data Product f g a = Pair (f a) (g a) @@ -37,6 +38,15 @@ data Product f g a = Pair (f a) (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Product f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Product f g) where liftEq eq (Pair x1 y1) (Pair x2 y2) = liftEq eq x1 x2 && liftEq eq y1 y2 @@ -59,25 +69,6 @@ instance (Show1 f, Show1 g) => Show1 (Product f g) where liftShowsPrec sp sl d (Pair x y) = showsBinaryWith (liftShowsPrec sp sl) (liftShowsPrec sp sl) "Pair" d x y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) - where (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Product f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Product f g) where fmap f (Pair x y) = Pair (fmap f x) (fmap f y) ===================================== libraries/base/Data/Functor/Sum.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Sum @@ -25,7 +26,7 @@ import Control.Applicative ((<|>)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted sum of functors. data Sum f g a = InL (f a) | InR (g a) @@ -34,6 +35,15 @@ data Sum f g a = InL (f a) | InR (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Sum f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Sum f g) where liftEq eq (InL x1) (InL x2) = liftEq eq x1 x2 @@ -64,22 +74,6 @@ instance (Show1 f, Show1 g) => Show1 (Sum f g) where liftShowsPrec sp sl d (InR y) = showsUnaryWith (liftShowsPrec sp sl) "InR" d y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) where - (==) = eq1 --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) where - compare = compare1 --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Sum f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Sum f g) where fmap f (InL x) = InL (fmap f x) ===================================== libraries/base/changelog.md ===================================== @@ -31,6 +31,11 @@ as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) * Update to Unicode 15.0.0. * Add `Eq` and `Ord` instances for `Generically1`. + * Relax instances for Functor combinators; put superclass on Class1 and Class2 + to make non-breaking. See [CLC + #10](https://github.com/haskell/core-libraries-committee/issues/10) for the + related discussion, as well as [the migration + guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). ## 4.17.0.0 *August 2022* ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 43f478af894b5173b4f1087c6d92c41a64250be8 +Subproject commit 7e4326f999056fb7b0b955ccadf5eab86b755a0d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f53f0f1f8679552007545da4993e42580dcb3212 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f53f0f1f8679552007545da4993e42580dcb3212 You're receiving 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 Sep 18 08:50:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 18 Sep 2022 04:50:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: DeriveFunctor: Check for last type variables using dataConUnivTyVars Message-ID: <6326dbe9c2adc_3b59a6d8c8608228667b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d555c9f2 by Ryan Scott at 2022-09-18T04:50:38-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. - - - - - 70860d42 by Vladislav Zavialov at 2022-09-18T04:50:39-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. - - - - - 3f0c994c by Vladislav Zavialov at 2022-09-18T04:50:39-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. - - - - - 6 changed files: - compiler/GHC/Parser/Lexer.x - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Infer.hs - + testsuite/tests/deriving/should_compile/T22167.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -490,20 +490,12 @@ $tab { warnTab } @conid "#"+ / { ifExtension MagicHashBit } { idtoken conid } } --- Operators classified into prefix, suffix, tight infix, and loose infix. --- See Note [Whitespace-sensitive operator parsing] -<0> { - @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } - @varsym / { followedByOpeningToken } { varsym_prefix } - @varsym / { precededByClosingToken } { varsym_suffix } - @varsym { varsym_loose_infix } -} - -- ToDo: - move `var` and (sym) into lexical syntax? -- - remove backquote from $special? <0> { @qvarsym { idtoken qvarsym } @qconsym { idtoken qconsym } + @varsym { with_op_ws varsym } @consym { consym } } @@ -707,6 +699,14 @@ $tab { warnTab } { +-- Operator whitespace occurrence. See Note [Whitespace-sensitive operator parsing]. +data OpWs + = OpWsPrefix -- a !b + | OpWsSuffix -- a! b + | OpWsTightInfix -- a!b + | OpWsLooseInfix -- a ! b + deriving Show + -- ----------------------------------------------------------------------------- -- The token type @@ -1093,60 +1093,61 @@ reservedSymsFM = listToUFM $ -- ----------------------------------------------------------------------------- -- Lexer actions -type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) +type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) special :: Token -> Action -special tok span _buf _len = return (L span tok) +special tok span _buf _len _buf2 = return (L span tok) token, layout_token :: Token -> Action -token t span _buf _len = return (L span t) -layout_token t span _buf _len = pushLexState layout >> return (L span t) +token t span _buf _len _buf2 = return (L span t) +layout_token t span _buf _len _buf2 = pushLexState layout >> return (L span t) idtoken :: (StringBuffer -> Int -> Token) -> Action -idtoken f span buf len = return (L span $! (f buf len)) +idtoken f span buf len _buf2 = return (L span $! (f buf len)) qdo_token :: (Maybe FastString -> Token) -> Action -qdo_token con span buf len = do +qdo_token con span buf len _buf2 = do maybe_layout token return (L span $! token) where !token = con $! Just $! fst $! splitQualName buf len False skip_one_varid :: (FastString -> Token) -> Action -skip_one_varid f span buf len +skip_one_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn buf) (len-1))) skip_two_varid :: (FastString -> Token) -> Action -skip_two_varid f span buf len +skip_two_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn (stepOn buf)) (len-2))) strtoken :: (String -> Token) -> Action -strtoken f span buf len = +strtoken f span buf len _buf2 = return (L span $! (f $! lexemeToString buf len)) begin :: Int -> Action -begin code _span _str _len = do pushLexState code; lexToken +begin code _span _str _len _buf2 = do pushLexState code; lexToken pop :: Action -pop _span _buf _len = do _ <- popLexState - lexToken +pop _span _buf _len _buf2 = + do _ <- popLexState + lexToken -- See Note [Nested comment line pragmas] failLinePrag1 :: Action -failLinePrag1 span _buf _len = do +failLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else lexError LexErrorInPragma -- See Note [Nested comment line pragmas] popLinePrag1 :: Action -popLinePrag1 span _buf _len = do +popLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else do _ <- popLexState lexToken hopefully_open_brace :: Action -hopefully_open_brace span buf len +hopefully_open_brace span buf len buf2 = do relaxed <- getBit RelaxedLayoutBit ctx <- getContext (AI l _) <- getInput @@ -1155,17 +1156,23 @@ hopefully_open_brace span buf len case ctx of Layout prev_off _ : _ -> prev_off < offset _ -> True - if isOK then pop_and open_brace span buf len + if isOK then pop_and open_brace span buf len buf2 else addFatalError $ mkPlainErrorMsgEnvelope (mkSrcSpanPs span) PsErrMissingBlock pop_and :: Action -> Action -pop_and act span buf len = do _ <- popLexState - act span buf len +pop_and act span buf len buf2 = + do _ <- popLexState + act span buf len buf2 -- See Note [Whitespace-sensitive operator parsing] -followedByOpeningToken :: AlexAccPred ExtsBitmap -followedByOpeningToken _ _ _ (AI _ buf) +followedByOpeningToken, precededByClosingToken :: AlexAccPred ExtsBitmap +followedByOpeningToken _ _ _ (AI _ buf) = followedByOpeningToken' buf +precededByClosingToken _ (AI _ buf) _ _ = precededByClosingToken' buf + +-- The input is the buffer *after* the token. +followedByOpeningToken' :: StringBuffer -> Bool +followedByOpeningToken' buf | atEnd buf = False | otherwise = case nextChar buf of @@ -1179,9 +1186,9 @@ followedByOpeningToken _ _ _ (AI _ buf) ('⦇', _) -> True (c, _) -> isAlphaNum c --- See Note [Whitespace-sensitive operator parsing] -precededByClosingToken :: AlexAccPred ExtsBitmap -precededByClosingToken _ (AI _ buf) _ _ = +-- The input is the buffer *before* the token. +precededByClosingToken' :: StringBuffer -> Bool +precededByClosingToken' buf = case prevChar buf '\n' of '}' -> decodePrevNChars 1 buf /= "-" ')' -> True @@ -1193,6 +1200,19 @@ precededByClosingToken _ (AI _ buf) _ _ = '⦈' -> True c -> isAlphaNum c +get_op_ws :: StringBuffer -> StringBuffer -> OpWs +get_op_ws buf1 buf2 = + mk_op_ws (precededByClosingToken' buf1) (followedByOpeningToken' buf2) + where + mk_op_ws False True = OpWsPrefix + mk_op_ws True False = OpWsSuffix + mk_op_ws True True = OpWsTightInfix + mk_op_ws False False = OpWsLooseInfix + +{-# INLINE with_op_ws #-} +with_op_ws :: (OpWs -> Action) -> Action +with_op_ws act span buf len buf2 = act (get_op_ws buf buf2) span buf len buf2 + {-# INLINE nextCharIs #-} nextCharIs :: StringBuffer -> (Char -> Bool) -> Bool nextCharIs buf p = not (atEnd buf) && p (currentChar buf) @@ -1289,7 +1309,7 @@ alexOrPred p1 p2 userState in1 len in2 = p1 userState in1 len in2 || p2 userState in1 len in2 multiline_doc_comment :: Action -multiline_doc_comment span buf _len = {-# SCC "multiline_doc_comment" #-} withLexedDocType worker +multiline_doc_comment span buf _len _buf2 = {-# SCC "multiline_doc_comment" #-} withLexedDocType worker where worker input@(AI start_loc _) docType checkNextLine = go start_loc "" [] input where @@ -1335,11 +1355,11 @@ multiline_doc_comment span buf _len = {-# SCC "multiline_doc_comment" #-} withLe Nothing -> input lineCommentToken :: Action -lineCommentToken span buf len = do +lineCommentToken span buf len buf2 = do b <- getBit RawTokenStreamBit if b then do lt <- getLastLocComment - strtoken (\s -> ITlineComment s lt) span buf len + strtoken (\s -> ITlineComment s lt) span buf len buf2 else lexToken @@ -1348,7 +1368,7 @@ lineCommentToken span buf len = do using regular expressions. -} nested_comment :: Action -nested_comment span buf len = {-# SCC "nested_comment" #-} do +nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do l <- getLastLocComment let endComment input (L _ comment) = commentEnd lexToken input (Nothing, ITblockComment comment l) buf span input <- getInput @@ -1357,7 +1377,7 @@ nested_comment span buf len = {-# SCC "nested_comment" #-} do nested_comment_logic endComment start_decorator input span nested_doc_comment :: Action -nested_doc_comment span buf _len = {-# SCC "nested_doc_comment" #-} withLexedDocType worker +nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLexedDocType worker where worker input docType _checkNextLine = nested_comment_logic endComment "" input span where @@ -1496,7 +1516,7 @@ mkHdkCommentSection loc n mkDS = (HdkCommentSection n ds, ITdocComment ds loc) -- RULES pragmas turn on the forall and '.' keywords, and we turn them -- off again at the end of the pragma. rulePrag :: Action -rulePrag span buf len = do +rulePrag span buf len _buf2 = do setExts (.|. xbit InRulePragBit) let !src = lexemeToString buf len return (L span (ITrules_prag (SourceText src))) @@ -1504,26 +1524,26 @@ rulePrag span buf len = do -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' linePrag :: Action -linePrag span buf len = do +linePrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit if usePosPrags - then begin line_prag2 span buf len + then begin line_prag2 span buf len buf2 else let !src = lexemeToString buf len in return (L span (ITline_prag (SourceText src))) -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' columnPrag :: Action -columnPrag span buf len = do +columnPrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit let !src = lexemeToString buf len if usePosPrags - then begin column_prag span buf len + then begin column_prag span buf len buf2 else let !src = lexemeToString buf len in return (L span (ITcolumn_prag (SourceText src))) endPrag :: Action -endPrag span _buf _len = do +endPrag span _buf _len _buf2 = do setExts (.&. complement (xbit InRulePragBit)) return (L span ITclose_prag) @@ -1567,11 +1587,11 @@ errBrace (AI end _) span = (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc (PsErrLexer LexUnterminatedComment LexErrKind_EOF)) open_brace, close_brace :: Action -open_brace span _str _len = do +open_brace span _str _len _buf2 = do ctx <- getContext setContext (NoLayout:ctx) return (L span ITocurly) -close_brace span _str _len = do +close_brace span _str _len _buf2 = do popContext return (L span ITccurly) @@ -1614,7 +1634,7 @@ splitQualName orig_buf len parens = split orig_buf orig_buf qual_size = orig_buf `byteDiff` dot_buf varid :: Action -varid span buf len = +varid span buf len _buf2 = case lookupUFM reservedWordsFM fs of Just (ITcase, _) -> do lastTk <- getLastTk @@ -1660,8 +1680,8 @@ qvarsym buf len = ITqvarsym $! splitQualName buf len False qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] -varsym_prefix :: Action -varsym_prefix = sym $ \span exts s -> +varsym :: OpWs -> Action +varsym OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) ; return (ITvarsym s) } @@ -1693,10 +1713,7 @@ varsym_prefix = sym $ \span exts s -> (mkSrcSpanPs span) (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Prefix) ; return (ITvarsym s) } - --- See Note [Whitespace-sensitive operator parsing] -varsym_suffix :: Action -varsym_suffix = sym $ \span _ s -> +varsym OpWsSuffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc $ PsErrSuffixAT) | s == fsLit "." -> return ITdot | otherwise -> @@ -1704,10 +1721,7 @@ varsym_suffix = sym $ \span _ s -> (mkSrcSpanPs span) (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Suffix) ; return (ITvarsym s) } - --- See Note [Whitespace-sensitive operator parsing] -varsym_tight_infix :: Action -varsym_tight_infix = sym $ \span exts s -> +varsym OpWsTightInfix = sym $ \span exts s -> if | s == fsLit "@" -> return ITat | s == fsLit ".", OverloadedRecordDotBit `xtest` exts -> return (ITproj False) | s == fsLit "." -> return ITdot @@ -1716,10 +1730,7 @@ varsym_tight_infix = sym $ \span exts s -> (mkSrcSpanPs span) (PsWarnOperatorWhitespace s (OperatorWhitespaceOccurrence_TightInfix)) ; return (ITvarsym s) } - --- See Note [Whitespace-sensitive operator parsing] -varsym_loose_infix :: Action -varsym_loose_infix = sym $ \_ _ s -> +varsym OpWsLooseInfix = sym $ \_ _ s -> if | s == fsLit "." -> return ITdot | otherwise @@ -1729,7 +1740,7 @@ consym :: Action consym = sym (\_span _exts s -> return $ ITconsym s) sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action -sym con span buf len = +sym con span buf len _buf2 = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> return $ L span keyword @@ -1760,7 +1771,7 @@ tok_integral :: (SourceText -> Integer -> Token) -> Int -> Int -> (Integer, (Char -> Int)) -> Action -tok_integral itint transint transbuf translen (radix,char_to_int) span buf len = do +tok_integral itint transint transbuf translen (radix,char_to_int) span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToString buf len when ((not numericUnderscores) && ('_' `elem` src)) $ do @@ -1802,7 +1813,7 @@ hexadecimal = (16,hexDigit) -- readSignificandExponentPair can understand negative rationals, exponents, everything. tok_frac :: Int -> (String -> Token) -> Action -tok_frac drop f span buf len = do +tok_frac drop f span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToString buf (len-drop) when ((not numericUnderscores) && ('_' `elem` src)) $ do @@ -1837,7 +1848,7 @@ readFractionalLitX readStr b str = -- we're at the first token on a line, insert layout tokens if necessary do_bol :: Action -do_bol span _str _len = do +do_bol span _str _len _buf2 = do -- See Note [Nested comment line pragmas] b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else do @@ -1888,7 +1899,7 @@ maybe_layout t = do -- If the alternative layout rule is enabled then -- by a 'do', then we allow the new context to be at the same indentation as -- the previous context. This is what the 'strict' argument is for. new_layout_context :: Bool -> Bool -> Token -> Action -new_layout_context strict gen_semic tok span _buf len = do +new_layout_context strict gen_semic tok span _buf len _buf2 = do _ <- popLexState (AI l _) <- getInput let offset = srcLocCol (psRealLoc l) - len @@ -1907,7 +1918,7 @@ new_layout_context strict gen_semic tok span _buf len = do return (L span tok) do_layout_left :: Action -do_layout_left span _buf _len = do +do_layout_left span _buf _len _buf2 = do _ <- popLexState pushLexState bol -- we must be at the start of a line return (L span ITvccurly) @@ -1916,7 +1927,7 @@ do_layout_left span _buf _len = do -- LINE pragmas setLineAndFile :: Int -> Action -setLineAndFile code (PsSpan span _) buf len = do +setLineAndFile code (PsSpan span _) buf len _buf2 = do let src = lexemeToString buf (len - 1) -- drop trailing quotation mark linenumLen = length $ head $ words src linenum = parseUnsignedInteger buf linenumLen 10 octDecDigit @@ -1943,7 +1954,7 @@ setLineAndFile code (PsSpan span _) buf len = do lexToken setColumn :: Action -setColumn (PsSpan span _) buf len = do +setColumn (PsSpan span _) buf len _buf2 = do let column = case reads (lexemeToString buf len) of [(column, _)] -> column @@ -1969,7 +1980,7 @@ lex_string_prag mkTok = lex_string_prag_comment mkTok' mkTok' s _ = mkTok s lex_string_prag_comment :: (String -> PsSpan -> Token) -> Action -lex_string_prag_comment mkTok span _buf _len +lex_string_prag_comment mkTok span _buf _len _buf2 = do input <- getInput start <- getParsedLoc l <- getLastLocComment @@ -1998,7 +2009,7 @@ lex_string_prag_comment mkTok span _buf _len -- This stuff is horrible. I hates it. lex_string_tok :: Action -lex_string_tok span buf _len = do +lex_string_tok span buf _len _buf2 = do tok <- lex_string "" (AI end bufEnd) <- getInput let @@ -2068,7 +2079,7 @@ lex_char_tok :: Action -- (the parser does that). -- So we have to do two characters of lookahead: when we see 'x we need to -- see if there's a trailing quote -lex_char_tok span buf _len = do -- We've seen ' +lex_char_tok span buf _len _buf2 = do -- We've seen ' i1 <- getInput -- Look ahead to first character let loc = psSpanStart span case alexGetChar' i1 of @@ -2246,7 +2257,7 @@ getCharOrFail i = do -- QuasiQuote lex_qquasiquote_tok :: Action -lex_qquasiquote_tok span buf len = do +lex_qquasiquote_tok span buf len _buf2 = do let (qual, quoter) = splitQualName (stepOn buf) (len - 2) False quoteStart <- getParsedLoc quote <- lex_quasiquote (psRealLoc quoteStart) "" @@ -2258,7 +2269,7 @@ lex_qquasiquote_tok span buf len = do mkPsSpan quoteStart end))) lex_quasiquote_tok :: Action -lex_quasiquote_tok span buf len = do +lex_quasiquote_tok span buf len _buf2 = do let quoter = tail (lexemeToString buf (len - 1)) -- 'tail' drops the initial '[', -- while the -1 drops the trailing '|' @@ -2297,14 +2308,14 @@ quasiquote_error start = do -- Warnings warnTab :: Action -warnTab srcspan _buf _len = do +warnTab srcspan _buf _len _buf2 = do addTabWarning (psRealSpan srcspan) lexToken warnThen :: PsMessage -> Action -> Action -warnThen warning action srcspan buf len = do +warnThen warning action srcspan buf len buf2 = do addPsMessage (RealSrcSpan (psRealSpan srcspan) Strict.Nothing) warning - action srcspan buf len + action srcspan buf len buf2 -- ----------------------------------------------------------------------------- -- The Parse Monad @@ -3401,7 +3412,7 @@ lexToken = do let span = mkPsSpan loc1 end let bytes = byteDiff buf buf2 span `seq` setLastToken span bytes - lt <- t span buf bytes + lt <- t span buf bytes buf2 let lt' = unLoc lt if (isComment lt') then setLastComment lt else setLastTk lt return lt @@ -3490,9 +3501,10 @@ twoWordPrags = Map.fromList [ ] dispatch_pragmas :: Map String Action -> Action -dispatch_pragmas prags span buf len = case Map.lookup (clean_pragma (lexemeToString buf len)) prags of - Just found -> found span buf len - Nothing -> lexError LexUnknownPragma +dispatch_pragmas prags span buf len buf2 = + case Map.lookup (clean_pragma (lexemeToString buf len)) prags of + Just found -> found span buf len buf2 + Nothing -> lexError LexUnknownPragma known_pragma :: Map String Action -> AlexAccPred ExtsBitmap known_pragma prags _ (AI _ startbuf) _ (AI _ curbuf) @@ -3514,13 +3526,13 @@ clean_pragma prag = canon_ws (map toLower (unprefix prag)) canon_ws s = unwords (map canonical (words s)) warn_unknown_prag :: Map String Action -> Action -warn_unknown_prag prags span buf len = do +warn_unknown_prag prags span buf len buf2 = do let uppercase = map toUpper unknown_prag = uppercase (clean_pragma (lexemeToString buf len)) suggestions = map uppercase (Map.keys prags) addPsMessage (RealSrcSpan (psRealSpan span) Strict.Nothing) $ PsWarnUnrecognisedPragma unknown_prag suggestions - nested_comment span buf len + nested_comment span buf len buf2 {- %************************************************************************ ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -538,8 +538,36 @@ functorLikeTraverse var (FT { ft_triv = caseTrivial, ft_var = caseVar go _ _ = (caseTrivial,False) --- Return all syntactic subterms of ty that contain var somewhere --- These are the things that should appear in instance constraints +-- | Return all syntactic subterms of a 'Type' that are applied to the 'TyVar' +-- argument. This determines what constraints should be inferred for derived +-- 'Functor', 'Foldable', and 'Traversable' instances in "GHC.Tc.Deriv.Infer". +-- For instance, if we have: +-- +-- @ +-- data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a)) +-- @ +-- +-- Then the following would hold: +-- +-- * @'deepSubtypesContaining' a Int@ would return @[]@, since @Int@ does not +-- contain the type variable @a@ at all. +-- +-- * @'deepSubtypesContaining' a a@ would return @[]@. Although the type @a@ +-- contains the type variable @a@, it is not /applied/ to @a@, which is the +-- criterion that 'deepSubtypesContaining' checks for. +-- +-- * @'deepSubtypesContaining' a (Maybe a)@ would return @[Maybe]@, as @Maybe@ +-- is applied to @a at . +-- +-- * @'deepSubtypesContaining' a (Either Int (Maybe a))@ would return +-- @[Either Int, Maybe]@. Both of these types are applied to @a@ through +-- composition. +-- +-- As used in "GHC.Tc.Deriv.Infer", the 'Type' argument will always come from +-- 'derivDataConInstArgTys', so it is important that the 'TyVar' comes from +-- 'dataConUnivTyVars' to match. Make sure /not/ to take the 'TyVar' from +-- 'tyConTyVars', as these differ from the 'dataConUnivTyVars' when the data +-- type is a GADT. (See #22167 for what goes wrong if 'tyConTyVars' is used.) deepSubtypesContaining :: TyVar -> Type -> [TcType] deepSubtypesContaining tv = functorLikeTraverse tv ===================================== compiler/GHC/Tc/Deriv/Generics.hs ===================================== @@ -93,10 +93,25 @@ gen_Generic_binds gk loc dit = do ************************************************************************ -} +-- | Called by 'GHC.Tc.Deriv.Infer.inferConstraints'; generates a list of +-- types, each of which must be a 'Functor' in order for the 'Generic1' +-- instance to work. For instance, if we have: +-- +-- @ +-- data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a)) +-- @ +-- +-- Then @'get_gen1_constrained_tys' a (f (g a))@ would return @[Either Int]@, +-- as a derived 'Generic1' instance would need to call 'fmap' at that type. +-- Invoking @'get_gen1_constrained_tys' a@ on any of the other fields would +-- return @[]@. +-- +-- 'get_gen1_constrained_tys' is very similar in spirit to +-- 'deepSubtypesContaining' in "GHC.Tc.Deriv.Functor". Just like with +-- 'deepSubtypesContaining', it is important that the 'TyVar' argument come +-- from 'dataConUnivTyVars'. (See #22167 for what goes wrong if 'tyConTyVars' +-- is used.) get_gen1_constrained_tys :: TyVar -> Type -> [Type] --- called by GHC.Tc.Deriv.Infer.inferConstraints; generates a list of --- types, each of which must be a Functor in order for the Generic1 instance to --- work. get_gen1_constrained_tys argVar = argTyFold argVar $ ArgTyAlg { ata_rec0 = const [] , ata_par1 = [], ata_rec1 = const [] ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -178,9 +178,10 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys -- Constraints arising from the arguments of each constructor con_arg_constraints - :: (CtOrigin -> TypeOrKind - -> Type - -> [(ThetaSpec, Maybe Subst)]) + :: ([TyVar] -> CtOrigin + -> TypeOrKind + -> Type + -> [(ThetaSpec, Maybe Subst)]) -> (ThetaSpec, [TyVar], [TcType], DerivInstTys) con_arg_constraints get_arg_constraints = let -- Constraints from the fields of each data constructor. @@ -195,7 +196,8 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys , not (isUnliftedType arg_ty) , let orig = DerivOriginDC data_con arg_n wildcard , preds_and_mbSubst - <- get_arg_constraints orig arg_t_or_k arg_ty + <- get_arg_constraints (dataConUnivTyVars data_con) + orig arg_t_or_k arg_ty ] -- Stupid constraints from DatatypeContexts. Note that we -- must gather these constraints from the data constructors, @@ -237,21 +239,39 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys is_functor_like = tcTypeKind inst_ty `tcEqKind` typeToTypeKind || is_generic1 - get_gen1_constraints :: Class -> CtOrigin -> TypeOrKind -> Type - -> [(ThetaSpec, Maybe Subst)] - get_gen1_constraints functor_cls orig t_or_k ty + get_gen1_constraints :: + Class + -> [TyVar] -- The universally quantified type variables for the + -- data constructor + -> CtOrigin -> TypeOrKind -> Type + -> [(ThetaSpec, Maybe Subst)] + get_gen1_constraints functor_cls dc_univs orig t_or_k ty = mk_functor_like_constraints orig t_or_k functor_cls $ - get_gen1_constrained_tys last_tv ty - - get_std_constrained_tys :: CtOrigin -> TypeOrKind -> Type - -> [(ThetaSpec, Maybe Subst)] - get_std_constrained_tys orig t_or_k ty + get_gen1_constrained_tys last_dc_univ ty + where + -- If we are deriving an instance of 'Generic1' and have made + -- it this far, then there should be at least one universal type + -- variable, making this use of 'last' safe. + last_dc_univ = assert (not (null dc_univs)) $ + last dc_univs + + get_std_constrained_tys :: + [TyVar] -- The universally quantified type variables for the + -- data constructor + -> CtOrigin -> TypeOrKind -> Type + -> [(ThetaSpec, Maybe Subst)] + get_std_constrained_tys dc_univs orig t_or_k ty | is_functor_like = mk_functor_like_constraints orig t_or_k main_cls $ - deepSubtypesContaining last_tv ty + deepSubtypesContaining last_dc_univ ty | otherwise = [( [mk_cls_pred orig t_or_k main_cls ty] , Nothing )] + where + -- If 'is_functor_like' holds, then there should be at least one + -- universal type variable, making this use of 'last' safe. + last_dc_univ = assert (not (null dc_univs)) $ + last dc_univs mk_functor_like_constraints :: CtOrigin -> TypeOrKind -> Class -> [Type] @@ -279,9 +299,6 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys , tcUnifyTy ki typeToTypeKind ) - rep_tc_tvs = tyConTyVars rep_tc - last_tv = last rep_tc_tvs - -- Extra Data constraints -- The Data class (only) requires that for -- instance (...) => Data (T t1 t2) @@ -320,7 +337,7 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys -- Generic1 needs Functor -- See Note [Getting base classes] | is_generic1 - -> assert (rep_tc_tvs `lengthExceeds` 0) $ + -> assert (tyConTyVars rep_tc `lengthExceeds` 0) $ -- Generic1 has a single kind variable assert (cls_tys `lengthIs` 1) $ do { functorClass <- lift $ tcLookupClass functorClassName ===================================== testsuite/tests/deriving/should_compile/T22167.hs ===================================== @@ -0,0 +1,24 @@ +module T22167 where + +import GHC.Generics (Generic1) + +data T1 f a = MkT1 (f a) + deriving (Functor, Foldable, Traversable) + +data T2 f a where + MkT2 :: f a -> T2 f a + deriving (Functor, Foldable, Traversable) + +-- A slightly more complicated example from the `syntactic` library +data (sym1 :+: sym2) sig + where + InjL :: sym1 a -> (sym1 :+: sym2) a + InjR :: sym2 a -> (sym1 :+: sym2) a + deriving (Functor, Foldable, Traversable) + +-- Test Generic1 instances with inferred Functor constraints +data G1 f g a = MkG1 (f (g a)) deriving Generic1 + +data G2 f g a where + MkG2 :: f (g a) -> G2 f g a + deriving Generic1 ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -139,3 +139,4 @@ test('T20387', normal, compile, ['']) test('T20501', normal, compile, ['']) test('T20719', normal, compile, ['']) test('T20994', normal, compile, ['']) +test('T22167', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3763e72b4c951669ebb79a6760fe390a9f9d41dd...3f0c994cb7741b08470f187c67f237d039160708 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3763e72b4c951669ebb79a6760fe390a9f9d41dd...3f0c994cb7741b08470f187c67f237d039160708 You're receiving 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 Sep 18 10:56:39 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 18 Sep 2022 06:56:39 -0400 Subject: [Git][ghc/ghc][wip/class-layout-info] 16 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <6326f967d00f9_3b59a6d8c86082312133@gitlab.mail> Vladislav Zavialov pushed to branch wip/class-layout-info at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - fd62bd36 by Vladislav Zavialov at 2022-09-18T13:56:32+03:00 Class layout info - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a48d9b05c5a86eac2b55469b9889533040d0ea0f...fd62bd36cddf18a814fa82910cb6af02d84dee87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a48d9b05c5a86eac2b55469b9889533040d0ea0f...fd62bd36cddf18a814fa82910cb6af02d84dee87 You're receiving 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 Sep 18 12:01:03 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 18 Sep 2022 08:01:03 -0400 Subject: [Git][ghc/ghc][master] DeriveFunctor: Check for last type variables using dataConUnivTyVars Message-ID: <6327087ff992_3b59a6d8c86082346398@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 5 changed files: - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Infer.hs - + testsuite/tests/deriving/should_compile/T22167.hs - testsuite/tests/deriving/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Deriv/Functor.hs ===================================== @@ -538,8 +538,36 @@ functorLikeTraverse var (FT { ft_triv = caseTrivial, ft_var = caseVar go _ _ = (caseTrivial,False) --- Return all syntactic subterms of ty that contain var somewhere --- These are the things that should appear in instance constraints +-- | Return all syntactic subterms of a 'Type' that are applied to the 'TyVar' +-- argument. This determines what constraints should be inferred for derived +-- 'Functor', 'Foldable', and 'Traversable' instances in "GHC.Tc.Deriv.Infer". +-- For instance, if we have: +-- +-- @ +-- data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a)) +-- @ +-- +-- Then the following would hold: +-- +-- * @'deepSubtypesContaining' a Int@ would return @[]@, since @Int@ does not +-- contain the type variable @a@ at all. +-- +-- * @'deepSubtypesContaining' a a@ would return @[]@. Although the type @a@ +-- contains the type variable @a@, it is not /applied/ to @a@, which is the +-- criterion that 'deepSubtypesContaining' checks for. +-- +-- * @'deepSubtypesContaining' a (Maybe a)@ would return @[Maybe]@, as @Maybe@ +-- is applied to @a at . +-- +-- * @'deepSubtypesContaining' a (Either Int (Maybe a))@ would return +-- @[Either Int, Maybe]@. Both of these types are applied to @a@ through +-- composition. +-- +-- As used in "GHC.Tc.Deriv.Infer", the 'Type' argument will always come from +-- 'derivDataConInstArgTys', so it is important that the 'TyVar' comes from +-- 'dataConUnivTyVars' to match. Make sure /not/ to take the 'TyVar' from +-- 'tyConTyVars', as these differ from the 'dataConUnivTyVars' when the data +-- type is a GADT. (See #22167 for what goes wrong if 'tyConTyVars' is used.) deepSubtypesContaining :: TyVar -> Type -> [TcType] deepSubtypesContaining tv = functorLikeTraverse tv ===================================== compiler/GHC/Tc/Deriv/Generics.hs ===================================== @@ -93,10 +93,25 @@ gen_Generic_binds gk loc dit = do ************************************************************************ -} +-- | Called by 'GHC.Tc.Deriv.Infer.inferConstraints'; generates a list of +-- types, each of which must be a 'Functor' in order for the 'Generic1' +-- instance to work. For instance, if we have: +-- +-- @ +-- data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a)) +-- @ +-- +-- Then @'get_gen1_constrained_tys' a (f (g a))@ would return @[Either Int]@, +-- as a derived 'Generic1' instance would need to call 'fmap' at that type. +-- Invoking @'get_gen1_constrained_tys' a@ on any of the other fields would +-- return @[]@. +-- +-- 'get_gen1_constrained_tys' is very similar in spirit to +-- 'deepSubtypesContaining' in "GHC.Tc.Deriv.Functor". Just like with +-- 'deepSubtypesContaining', it is important that the 'TyVar' argument come +-- from 'dataConUnivTyVars'. (See #22167 for what goes wrong if 'tyConTyVars' +-- is used.) get_gen1_constrained_tys :: TyVar -> Type -> [Type] --- called by GHC.Tc.Deriv.Infer.inferConstraints; generates a list of --- types, each of which must be a Functor in order for the Generic1 instance to --- work. get_gen1_constrained_tys argVar = argTyFold argVar $ ArgTyAlg { ata_rec0 = const [] , ata_par1 = [], ata_rec1 = const [] ===================================== compiler/GHC/Tc/Deriv/Infer.hs ===================================== @@ -178,9 +178,10 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys -- Constraints arising from the arguments of each constructor con_arg_constraints - :: (CtOrigin -> TypeOrKind - -> Type - -> [(ThetaSpec, Maybe Subst)]) + :: ([TyVar] -> CtOrigin + -> TypeOrKind + -> Type + -> [(ThetaSpec, Maybe Subst)]) -> (ThetaSpec, [TyVar], [TcType], DerivInstTys) con_arg_constraints get_arg_constraints = let -- Constraints from the fields of each data constructor. @@ -195,7 +196,8 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys , not (isUnliftedType arg_ty) , let orig = DerivOriginDC data_con arg_n wildcard , preds_and_mbSubst - <- get_arg_constraints orig arg_t_or_k arg_ty + <- get_arg_constraints (dataConUnivTyVars data_con) + orig arg_t_or_k arg_ty ] -- Stupid constraints from DatatypeContexts. Note that we -- must gather these constraints from the data constructors, @@ -237,21 +239,39 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys is_functor_like = tcTypeKind inst_ty `tcEqKind` typeToTypeKind || is_generic1 - get_gen1_constraints :: Class -> CtOrigin -> TypeOrKind -> Type - -> [(ThetaSpec, Maybe Subst)] - get_gen1_constraints functor_cls orig t_or_k ty + get_gen1_constraints :: + Class + -> [TyVar] -- The universally quantified type variables for the + -- data constructor + -> CtOrigin -> TypeOrKind -> Type + -> [(ThetaSpec, Maybe Subst)] + get_gen1_constraints functor_cls dc_univs orig t_or_k ty = mk_functor_like_constraints orig t_or_k functor_cls $ - get_gen1_constrained_tys last_tv ty - - get_std_constrained_tys :: CtOrigin -> TypeOrKind -> Type - -> [(ThetaSpec, Maybe Subst)] - get_std_constrained_tys orig t_or_k ty + get_gen1_constrained_tys last_dc_univ ty + where + -- If we are deriving an instance of 'Generic1' and have made + -- it this far, then there should be at least one universal type + -- variable, making this use of 'last' safe. + last_dc_univ = assert (not (null dc_univs)) $ + last dc_univs + + get_std_constrained_tys :: + [TyVar] -- The universally quantified type variables for the + -- data constructor + -> CtOrigin -> TypeOrKind -> Type + -> [(ThetaSpec, Maybe Subst)] + get_std_constrained_tys dc_univs orig t_or_k ty | is_functor_like = mk_functor_like_constraints orig t_or_k main_cls $ - deepSubtypesContaining last_tv ty + deepSubtypesContaining last_dc_univ ty | otherwise = [( [mk_cls_pred orig t_or_k main_cls ty] , Nothing )] + where + -- If 'is_functor_like' holds, then there should be at least one + -- universal type variable, making this use of 'last' safe. + last_dc_univ = assert (not (null dc_univs)) $ + last dc_univs mk_functor_like_constraints :: CtOrigin -> TypeOrKind -> Class -> [Type] @@ -279,9 +299,6 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys , tcUnifyTy ki typeToTypeKind ) - rep_tc_tvs = tyConTyVars rep_tc - last_tv = last rep_tc_tvs - -- Extra Data constraints -- The Data class (only) requires that for -- instance (...) => Data (T t1 t2) @@ -320,7 +337,7 @@ inferConstraintsStock dit@(DerivInstTys { dit_cls_tys = cls_tys -- Generic1 needs Functor -- See Note [Getting base classes] | is_generic1 - -> assert (rep_tc_tvs `lengthExceeds` 0) $ + -> assert (tyConTyVars rep_tc `lengthExceeds` 0) $ -- Generic1 has a single kind variable assert (cls_tys `lengthIs` 1) $ do { functorClass <- lift $ tcLookupClass functorClassName ===================================== testsuite/tests/deriving/should_compile/T22167.hs ===================================== @@ -0,0 +1,24 @@ +module T22167 where + +import GHC.Generics (Generic1) + +data T1 f a = MkT1 (f a) + deriving (Functor, Foldable, Traversable) + +data T2 f a where + MkT2 :: f a -> T2 f a + deriving (Functor, Foldable, Traversable) + +-- A slightly more complicated example from the `syntactic` library +data (sym1 :+: sym2) sig + where + InjL :: sym1 a -> (sym1 :+: sym2) a + InjR :: sym2 a -> (sym1 :+: sym2) a + deriving (Functor, Foldable, Traversable) + +-- Test Generic1 instances with inferred Functor constraints +data G1 f g a = MkG1 (f (g a)) deriving Generic1 + +data G2 f g a where + MkG2 :: f (g a) -> G2 f g a + deriving Generic1 ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -139,3 +139,4 @@ test('T20387', normal, compile, ['']) test('T20501', normal, compile, ['']) test('T20719', normal, compile, ['']) test('T20994', normal, compile, ['']) +test('T22167', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a666ad2a89a8ad2aa24a6406b88f516afaec671 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a666ad2a89a8ad2aa24a6406b88f516afaec671 You're receiving 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 Sep 18 12:01:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 18 Sep 2022 08:01:36 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Lexer: pass updated buffer to actions (#22201) Message-ID: <632708a02c8fa_3b59a65183823497de@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - compiler/GHC/Parser/Lexer.x Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -490,20 +490,12 @@ $tab { warnTab } @conid "#"+ / { ifExtension MagicHashBit } { idtoken conid } } --- Operators classified into prefix, suffix, tight infix, and loose infix. --- See Note [Whitespace-sensitive operator parsing] -<0> { - @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } - @varsym / { followedByOpeningToken } { varsym_prefix } - @varsym / { precededByClosingToken } { varsym_suffix } - @varsym { varsym_loose_infix } -} - -- ToDo: - move `var` and (sym) into lexical syntax? -- - remove backquote from $special? <0> { @qvarsym { idtoken qvarsym } @qconsym { idtoken qconsym } + @varsym { with_op_ws varsym } @consym { consym } } @@ -707,6 +699,14 @@ $tab { warnTab } { +-- Operator whitespace occurrence. See Note [Whitespace-sensitive operator parsing]. +data OpWs + = OpWsPrefix -- a !b + | OpWsSuffix -- a! b + | OpWsTightInfix -- a!b + | OpWsLooseInfix -- a ! b + deriving Show + -- ----------------------------------------------------------------------------- -- The token type @@ -1093,60 +1093,61 @@ reservedSymsFM = listToUFM $ -- ----------------------------------------------------------------------------- -- Lexer actions -type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) +type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) special :: Token -> Action -special tok span _buf _len = return (L span tok) +special tok span _buf _len _buf2 = return (L span tok) token, layout_token :: Token -> Action -token t span _buf _len = return (L span t) -layout_token t span _buf _len = pushLexState layout >> return (L span t) +token t span _buf _len _buf2 = return (L span t) +layout_token t span _buf _len _buf2 = pushLexState layout >> return (L span t) idtoken :: (StringBuffer -> Int -> Token) -> Action -idtoken f span buf len = return (L span $! (f buf len)) +idtoken f span buf len _buf2 = return (L span $! (f buf len)) qdo_token :: (Maybe FastString -> Token) -> Action -qdo_token con span buf len = do +qdo_token con span buf len _buf2 = do maybe_layout token return (L span $! token) where !token = con $! Just $! fst $! splitQualName buf len False skip_one_varid :: (FastString -> Token) -> Action -skip_one_varid f span buf len +skip_one_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn buf) (len-1))) skip_two_varid :: (FastString -> Token) -> Action -skip_two_varid f span buf len +skip_two_varid f span buf len _buf2 = return (L span $! f (lexemeToFastString (stepOn (stepOn buf)) (len-2))) strtoken :: (String -> Token) -> Action -strtoken f span buf len = +strtoken f span buf len _buf2 = return (L span $! (f $! lexemeToString buf len)) begin :: Int -> Action -begin code _span _str _len = do pushLexState code; lexToken +begin code _span _str _len _buf2 = do pushLexState code; lexToken pop :: Action -pop _span _buf _len = do _ <- popLexState - lexToken +pop _span _buf _len _buf2 = + do _ <- popLexState + lexToken -- See Note [Nested comment line pragmas] failLinePrag1 :: Action -failLinePrag1 span _buf _len = do +failLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else lexError LexErrorInPragma -- See Note [Nested comment line pragmas] popLinePrag1 :: Action -popLinePrag1 span _buf _len = do +popLinePrag1 span _buf _len _buf2 = do b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else do _ <- popLexState lexToken hopefully_open_brace :: Action -hopefully_open_brace span buf len +hopefully_open_brace span buf len buf2 = do relaxed <- getBit RelaxedLayoutBit ctx <- getContext (AI l _) <- getInput @@ -1155,17 +1156,23 @@ hopefully_open_brace span buf len case ctx of Layout prev_off _ : _ -> prev_off < offset _ -> True - if isOK then pop_and open_brace span buf len + if isOK then pop_and open_brace span buf len buf2 else addFatalError $ mkPlainErrorMsgEnvelope (mkSrcSpanPs span) PsErrMissingBlock pop_and :: Action -> Action -pop_and act span buf len = do _ <- popLexState - act span buf len +pop_and act span buf len buf2 = + do _ <- popLexState + act span buf len buf2 -- See Note [Whitespace-sensitive operator parsing] -followedByOpeningToken :: AlexAccPred ExtsBitmap -followedByOpeningToken _ _ _ (AI _ buf) +followedByOpeningToken, precededByClosingToken :: AlexAccPred ExtsBitmap +followedByOpeningToken _ _ _ (AI _ buf) = followedByOpeningToken' buf +precededByClosingToken _ (AI _ buf) _ _ = precededByClosingToken' buf + +-- The input is the buffer *after* the token. +followedByOpeningToken' :: StringBuffer -> Bool +followedByOpeningToken' buf | atEnd buf = False | otherwise = case nextChar buf of @@ -1179,9 +1186,9 @@ followedByOpeningToken _ _ _ (AI _ buf) ('⦇', _) -> True (c, _) -> isAlphaNum c --- See Note [Whitespace-sensitive operator parsing] -precededByClosingToken :: AlexAccPred ExtsBitmap -precededByClosingToken _ (AI _ buf) _ _ = +-- The input is the buffer *before* the token. +precededByClosingToken' :: StringBuffer -> Bool +precededByClosingToken' buf = case prevChar buf '\n' of '}' -> decodePrevNChars 1 buf /= "-" ')' -> True @@ -1193,6 +1200,19 @@ precededByClosingToken _ (AI _ buf) _ _ = '⦈' -> True c -> isAlphaNum c +get_op_ws :: StringBuffer -> StringBuffer -> OpWs +get_op_ws buf1 buf2 = + mk_op_ws (precededByClosingToken' buf1) (followedByOpeningToken' buf2) + where + mk_op_ws False True = OpWsPrefix + mk_op_ws True False = OpWsSuffix + mk_op_ws True True = OpWsTightInfix + mk_op_ws False False = OpWsLooseInfix + +{-# INLINE with_op_ws #-} +with_op_ws :: (OpWs -> Action) -> Action +with_op_ws act span buf len buf2 = act (get_op_ws buf buf2) span buf len buf2 + {-# INLINE nextCharIs #-} nextCharIs :: StringBuffer -> (Char -> Bool) -> Bool nextCharIs buf p = not (atEnd buf) && p (currentChar buf) @@ -1289,7 +1309,7 @@ alexOrPred p1 p2 userState in1 len in2 = p1 userState in1 len in2 || p2 userState in1 len in2 multiline_doc_comment :: Action -multiline_doc_comment span buf _len = {-# SCC "multiline_doc_comment" #-} withLexedDocType worker +multiline_doc_comment span buf _len _buf2 = {-# SCC "multiline_doc_comment" #-} withLexedDocType worker where worker input@(AI start_loc _) docType checkNextLine = go start_loc "" [] input where @@ -1335,11 +1355,11 @@ multiline_doc_comment span buf _len = {-# SCC "multiline_doc_comment" #-} withLe Nothing -> input lineCommentToken :: Action -lineCommentToken span buf len = do +lineCommentToken span buf len buf2 = do b <- getBit RawTokenStreamBit if b then do lt <- getLastLocComment - strtoken (\s -> ITlineComment s lt) span buf len + strtoken (\s -> ITlineComment s lt) span buf len buf2 else lexToken @@ -1348,7 +1368,7 @@ lineCommentToken span buf len = do using regular expressions. -} nested_comment :: Action -nested_comment span buf len = {-# SCC "nested_comment" #-} do +nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do l <- getLastLocComment let endComment input (L _ comment) = commentEnd lexToken input (Nothing, ITblockComment comment l) buf span input <- getInput @@ -1357,7 +1377,7 @@ nested_comment span buf len = {-# SCC "nested_comment" #-} do nested_comment_logic endComment start_decorator input span nested_doc_comment :: Action -nested_doc_comment span buf _len = {-# SCC "nested_doc_comment" #-} withLexedDocType worker +nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLexedDocType worker where worker input docType _checkNextLine = nested_comment_logic endComment "" input span where @@ -1496,7 +1516,7 @@ mkHdkCommentSection loc n mkDS = (HdkCommentSection n ds, ITdocComment ds loc) -- RULES pragmas turn on the forall and '.' keywords, and we turn them -- off again at the end of the pragma. rulePrag :: Action -rulePrag span buf len = do +rulePrag span buf len _buf2 = do setExts (.|. xbit InRulePragBit) let !src = lexemeToString buf len return (L span (ITrules_prag (SourceText src))) @@ -1504,26 +1524,26 @@ rulePrag span buf len = do -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' linePrag :: Action -linePrag span buf len = do +linePrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit if usePosPrags - then begin line_prag2 span buf len + then begin line_prag2 span buf len buf2 else let !src = lexemeToString buf len in return (L span (ITline_prag (SourceText src))) -- When 'UsePosPragsBit' is not set, it is expected that we emit a token instead -- of updating the position in 'PState' columnPrag :: Action -columnPrag span buf len = do +columnPrag span buf len buf2 = do usePosPrags <- getBit UsePosPragsBit let !src = lexemeToString buf len if usePosPrags - then begin column_prag span buf len + then begin column_prag span buf len buf2 else let !src = lexemeToString buf len in return (L span (ITcolumn_prag (SourceText src))) endPrag :: Action -endPrag span _buf _len = do +endPrag span _buf _len _buf2 = do setExts (.&. complement (xbit InRulePragBit)) return (L span ITclose_prag) @@ -1567,11 +1587,11 @@ errBrace (AI end _) span = (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc (PsErrLexer LexUnterminatedComment LexErrKind_EOF)) open_brace, close_brace :: Action -open_brace span _str _len = do +open_brace span _str _len _buf2 = do ctx <- getContext setContext (NoLayout:ctx) return (L span ITocurly) -close_brace span _str _len = do +close_brace span _str _len _buf2 = do popContext return (L span ITccurly) @@ -1614,7 +1634,7 @@ splitQualName orig_buf len parens = split orig_buf orig_buf qual_size = orig_buf `byteDiff` dot_buf varid :: Action -varid span buf len = +varid span buf len _buf2 = case lookupUFM reservedWordsFM fs of Just (ITcase, _) -> do lastTk <- getLastTk @@ -1660,8 +1680,8 @@ qvarsym buf len = ITqvarsym $! splitQualName buf len False qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] -varsym_prefix :: Action -varsym_prefix = sym $ \span exts s -> +varsym :: OpWs -> Action +varsym OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) ; return (ITvarsym s) } @@ -1693,10 +1713,7 @@ varsym_prefix = sym $ \span exts s -> (mkSrcSpanPs span) (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Prefix) ; return (ITvarsym s) } - --- See Note [Whitespace-sensitive operator parsing] -varsym_suffix :: Action -varsym_suffix = sym $ \span _ s -> +varsym OpWsSuffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc $ PsErrSuffixAT) | s == fsLit "." -> return ITdot | otherwise -> @@ -1704,10 +1721,7 @@ varsym_suffix = sym $ \span _ s -> (mkSrcSpanPs span) (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Suffix) ; return (ITvarsym s) } - --- See Note [Whitespace-sensitive operator parsing] -varsym_tight_infix :: Action -varsym_tight_infix = sym $ \span exts s -> +varsym OpWsTightInfix = sym $ \span exts s -> if | s == fsLit "@" -> return ITat | s == fsLit ".", OverloadedRecordDotBit `xtest` exts -> return (ITproj False) | s == fsLit "." -> return ITdot @@ -1716,10 +1730,7 @@ varsym_tight_infix = sym $ \span exts s -> (mkSrcSpanPs span) (PsWarnOperatorWhitespace s (OperatorWhitespaceOccurrence_TightInfix)) ; return (ITvarsym s) } - --- See Note [Whitespace-sensitive operator parsing] -varsym_loose_infix :: Action -varsym_loose_infix = sym $ \_ _ s -> +varsym OpWsLooseInfix = sym $ \_ _ s -> if | s == fsLit "." -> return ITdot | otherwise @@ -1729,7 +1740,7 @@ consym :: Action consym = sym (\_span _exts s -> return $ ITconsym s) sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action -sym con span buf len = +sym con span buf len _buf2 = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> return $ L span keyword @@ -1760,7 +1771,7 @@ tok_integral :: (SourceText -> Integer -> Token) -> Int -> Int -> (Integer, (Char -> Int)) -> Action -tok_integral itint transint transbuf translen (radix,char_to_int) span buf len = do +tok_integral itint transint transbuf translen (radix,char_to_int) span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToString buf len when ((not numericUnderscores) && ('_' `elem` src)) $ do @@ -1802,7 +1813,7 @@ hexadecimal = (16,hexDigit) -- readSignificandExponentPair can understand negative rationals, exponents, everything. tok_frac :: Int -> (String -> Token) -> Action -tok_frac drop f span buf len = do +tok_frac drop f span buf len _buf2 = do numericUnderscores <- getBit NumericUnderscoresBit -- #14473 let src = lexemeToString buf (len-drop) when ((not numericUnderscores) && ('_' `elem` src)) $ do @@ -1837,7 +1848,7 @@ readFractionalLitX readStr b str = -- we're at the first token on a line, insert layout tokens if necessary do_bol :: Action -do_bol span _str _len = do +do_bol span _str _len _buf2 = do -- See Note [Nested comment line pragmas] b <- getBit InNestedCommentBit if b then return (L span ITcomment_line_prag) else do @@ -1888,7 +1899,7 @@ maybe_layout t = do -- If the alternative layout rule is enabled then -- by a 'do', then we allow the new context to be at the same indentation as -- the previous context. This is what the 'strict' argument is for. new_layout_context :: Bool -> Bool -> Token -> Action -new_layout_context strict gen_semic tok span _buf len = do +new_layout_context strict gen_semic tok span _buf len _buf2 = do _ <- popLexState (AI l _) <- getInput let offset = srcLocCol (psRealLoc l) - len @@ -1907,7 +1918,7 @@ new_layout_context strict gen_semic tok span _buf len = do return (L span tok) do_layout_left :: Action -do_layout_left span _buf _len = do +do_layout_left span _buf _len _buf2 = do _ <- popLexState pushLexState bol -- we must be at the start of a line return (L span ITvccurly) @@ -1916,7 +1927,7 @@ do_layout_left span _buf _len = do -- LINE pragmas setLineAndFile :: Int -> Action -setLineAndFile code (PsSpan span _) buf len = do +setLineAndFile code (PsSpan span _) buf len _buf2 = do let src = lexemeToString buf (len - 1) -- drop trailing quotation mark linenumLen = length $ head $ words src linenum = parseUnsignedInteger buf linenumLen 10 octDecDigit @@ -1943,7 +1954,7 @@ setLineAndFile code (PsSpan span _) buf len = do lexToken setColumn :: Action -setColumn (PsSpan span _) buf len = do +setColumn (PsSpan span _) buf len _buf2 = do let column = case reads (lexemeToString buf len) of [(column, _)] -> column @@ -1969,7 +1980,7 @@ lex_string_prag mkTok = lex_string_prag_comment mkTok' mkTok' s _ = mkTok s lex_string_prag_comment :: (String -> PsSpan -> Token) -> Action -lex_string_prag_comment mkTok span _buf _len +lex_string_prag_comment mkTok span _buf _len _buf2 = do input <- getInput start <- getParsedLoc l <- getLastLocComment @@ -1998,7 +2009,7 @@ lex_string_prag_comment mkTok span _buf _len -- This stuff is horrible. I hates it. lex_string_tok :: Action -lex_string_tok span buf _len = do +lex_string_tok span buf _len _buf2 = do tok <- lex_string "" (AI end bufEnd) <- getInput let @@ -2068,7 +2079,7 @@ lex_char_tok :: Action -- (the parser does that). -- So we have to do two characters of lookahead: when we see 'x we need to -- see if there's a trailing quote -lex_char_tok span buf _len = do -- We've seen ' +lex_char_tok span buf _len _buf2 = do -- We've seen ' i1 <- getInput -- Look ahead to first character let loc = psSpanStart span case alexGetChar' i1 of @@ -2246,7 +2257,7 @@ getCharOrFail i = do -- QuasiQuote lex_qquasiquote_tok :: Action -lex_qquasiquote_tok span buf len = do +lex_qquasiquote_tok span buf len _buf2 = do let (qual, quoter) = splitQualName (stepOn buf) (len - 2) False quoteStart <- getParsedLoc quote <- lex_quasiquote (psRealLoc quoteStart) "" @@ -2258,7 +2269,7 @@ lex_qquasiquote_tok span buf len = do mkPsSpan quoteStart end))) lex_quasiquote_tok :: Action -lex_quasiquote_tok span buf len = do +lex_quasiquote_tok span buf len _buf2 = do let quoter = tail (lexemeToString buf (len - 1)) -- 'tail' drops the initial '[', -- while the -1 drops the trailing '|' @@ -2297,14 +2308,14 @@ quasiquote_error start = do -- Warnings warnTab :: Action -warnTab srcspan _buf _len = do +warnTab srcspan _buf _len _buf2 = do addTabWarning (psRealSpan srcspan) lexToken warnThen :: PsMessage -> Action -> Action -warnThen warning action srcspan buf len = do +warnThen warning action srcspan buf len buf2 = do addPsMessage (RealSrcSpan (psRealSpan srcspan) Strict.Nothing) warning - action srcspan buf len + action srcspan buf len buf2 -- ----------------------------------------------------------------------------- -- The Parse Monad @@ -3401,7 +3412,7 @@ lexToken = do let span = mkPsSpan loc1 end let bytes = byteDiff buf buf2 span `seq` setLastToken span bytes - lt <- t span buf bytes + lt <- t span buf bytes buf2 let lt' = unLoc lt if (isComment lt') then setLastComment lt else setLastTk lt return lt @@ -3490,9 +3501,10 @@ twoWordPrags = Map.fromList [ ] dispatch_pragmas :: Map String Action -> Action -dispatch_pragmas prags span buf len = case Map.lookup (clean_pragma (lexemeToString buf len)) prags of - Just found -> found span buf len - Nothing -> lexError LexUnknownPragma +dispatch_pragmas prags span buf len buf2 = + case Map.lookup (clean_pragma (lexemeToString buf len)) prags of + Just found -> found span buf len buf2 + Nothing -> lexError LexUnknownPragma known_pragma :: Map String Action -> AlexAccPred ExtsBitmap known_pragma prags _ (AI _ startbuf) _ (AI _ curbuf) @@ -3514,13 +3526,13 @@ clean_pragma prag = canon_ws (map toLower (unprefix prag)) canon_ws s = unwords (map canonical (words s)) warn_unknown_prag :: Map String Action -> Action -warn_unknown_prag prags span buf len = do +warn_unknown_prag prags span buf len buf2 = do let uppercase = map toUpper unknown_prag = uppercase (clean_pragma (lexemeToString buf len)) suggestions = map uppercase (Map.keys prags) addPsMessage (RealSrcSpan (psRealSpan span) Strict.Nothing) $ PsWarnUnrecognisedPragma unknown_prag suggestions - nested_comment span buf len + nested_comment span buf len buf2 {- %************************************************************************ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a666ad2a89a8ad2aa24a6406b88f516afaec671...7574659452a864e762fa812cb38cf15f70d85617 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a666ad2a89a8ad2aa24a6406b88f516afaec671...7574659452a864e762fa812cb38cf15f70d85617 You're receiving 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 Sep 18 13:29:02 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 18 Sep 2022 09:29:02 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/op-ws-consym-2 Message-ID: <63271d1e52383_3b59a65152c23619e2@gitlab.mail> Vladislav Zavialov pushed new branch wip/op-ws-consym-2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/op-ws-consym-2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Sep 18 14:14:26 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 18 Sep 2022 10:14:26 -0400 Subject: [Git][ghc/ghc][wip/op-ws-consym-2] Fix -Woperator-whitespace for consym (part of #19372) Message-ID: <632727c2bb8c8_3b59a620aecc142368455@gitlab.mail> Vladislav Zavialov pushed to branch wip/op-ws-consym-2 at Glasgow Haskell Compiler / GHC Commits: 07c779a6 by Vladislav Zavialov at 2022-09-18T17:09:29+03: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. - - - - - 5 changed files: - compiler/GHC/Parser/Lexer.x - docs/users_guide/9.6.1-notes.rst - + testsuite/tests/parser/should_compile/T19372consym.hs - + testsuite/tests/parser/should_compile/T19372consym.stderr - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -496,7 +496,7 @@ $tab { warnTab } @qvarsym { idtoken qvarsym } @qconsym { idtoken qconsym } @varsym { with_op_ws varsym } - @consym { consym } + @consym { with_op_ws consym } } -- For the normal boxed literals we need to be careful @@ -1681,7 +1681,7 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym :: OpWs -> Action -varsym OpWsPrefix = sym $ \span exts s -> +varsym opws at OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) ; return (ITvarsym s) } @@ -1709,35 +1709,48 @@ varsym OpWsPrefix = sym $ \span exts s -> | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Prefix) + do { warnOperatorWhitespace opws span s ; return (ITvarsym s) } -varsym OpWsSuffix = sym $ \span _ s -> +varsym opws at OpWsSuffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc $ PsErrSuffixAT) | s == fsLit "." -> return ITdot | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Suffix) + do { warnOperatorWhitespace opws span s ; return (ITvarsym s) } -varsym OpWsTightInfix = sym $ \span exts s -> +varsym opws at OpWsTightInfix = sym $ \span exts s -> if | s == fsLit "@" -> return ITat | s == fsLit ".", OverloadedRecordDotBit `xtest` exts -> return (ITproj False) | s == fsLit "." -> return ITdot | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s (OperatorWhitespaceOccurrence_TightInfix)) - ; return (ITvarsym s) } + do { warnOperatorWhitespace opws span s + ; return (ITvarsym s) } varsym OpWsLooseInfix = sym $ \_ _ s -> if | s == fsLit "." -> return ITdot | otherwise -> return $ ITvarsym s -consym :: Action -consym = sym (\_span _exts s -> return $ ITconsym s) +consym :: OpWs -> Action +consym opws = sym $ \span _exts s -> + do { warnOperatorWhitespace opws span s + ; return (ITconsym s) } + +warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P () +warnOperatorWhitespace opws span s = + whenIsJust (check_unusual_opws opws) $ \opws' -> + addPsMessage + (mkSrcSpanPs span) + (PsWarnOperatorWhitespace s opws') + +-- Check an operator occurrence for unusual whitespace (prefix, suffix, tight infix). +-- This determines if -Woperator-whitespace is triggered. +check_unusual_opws :: OpWs -> Maybe OperatorWhitespaceOccurrence +check_unusual_opws opws = + case opws of + OpWsPrefix -> Just OperatorWhitespaceOccurrence_Prefix + OpWsSuffix -> Just OperatorWhitespaceOccurrence_Suffix + OpWsTightInfix -> Just OperatorWhitespaceOccurrence_TightInfix + OpWsLooseInfix -> Nothing sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len _buf2 = ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -68,6 +68,9 @@ Compiler - The :extension:`TypeInType` is now marked as deprecated. Its meaning has been included in :extension:`PolyKinds` and :extension:`DataKinds`. +- The :ghc-flag:`-Woperator-whitespace` warning no longer ignores constructor symbols + (operators starting with ``:``). + GHCi ~~~~ ===================================== testsuite/tests/parser/should_compile/T19372consym.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T19372consym where + +import Data.List.NonEmpty + +a_suffix = \x y -> x: y +a_prefix = \x y -> x :y +a_tight_infix = \x y -> x:y +a_loose_infix = \x y -> x : y -- Only this one should be without a warning. + +b_suffix = \x y -> x:| y +b_prefix = \x y -> x :|y +b_tight_infix = \x y -> x:|y +b_loose_infix = \x y -> x :| y -- Only this one should be without a warning. ===================================== testsuite/tests/parser/should_compile/T19372consym.stderr ===================================== @@ -0,0 +1,15 @@ + +T19372consym.hs:12:26: warning: [GHC-40798] [-Woperator-whitespace] + The suffix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. + +T19372consym.hs:13:27: warning: [GHC-40798] [-Woperator-whitespace] + The prefix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. + +T19372consym.hs:14:26: warning: [GHC-40798] [-Woperator-whitespace] + The tight infix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -193,3 +193,4 @@ test('T20718', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-c test('T20718b', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) test('T21589', normal, compile, ['']) +test('T19372consym', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07c779a6dd51efd7649645f9387c5c63d989c2f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07c779a6dd51efd7649645f9387c5c63d989c2f2 You're receiving 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 Sep 19 09:37:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 19 Sep 2022 05:37:05 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: DeriveFunctor: Check for last type variables using dataConUnivTyVars Message-ID: <632838414af5a_3b59a6d8c860824813f2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - ffae25da by M Farkas-Dyck at 2022-09-19T05:36:45-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. - - - - - 3f071471 by Cheng Shao at 2022-09-19T05:36:48-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. - - - - - 30 changed files: - compiler/GHC/CmmToC.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Monad.hs - compiler/Language/Haskell/Syntax/Decls.hs - + testsuite/tests/deriving/should_compile/T22167.hs - testsuite/tests/deriving/should_compile/all.T - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f0c994cb7741b08470f187c67f237d039160708...3f0714717fa33beab9f36aeb32925f8af39d5d78 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f0c994cb7741b08470f187c67f237d039160708...3f0714717fa33beab9f36aeb32925f8af39d5d78 You're receiving 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 Sep 19 10:37:04 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 19 Sep 2022 06:37:04 -0400 Subject: [Git][ghc/ghc][wip/ghc-9.2-hasura] 2 commits: Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <63284650b60a1_3b59a651838251868c@gitlab.mail> Zubin pushed to branch wip/ghc-9.2-hasura at Glasgow Haskell Compiler / GHC Commits: 5aaf4548 by Simon Peyton Jones at 2022-09-19T16:06:45+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 - - - - - d33a59b4 by Zubin Duggal at 2022-09-19T16:06:46+05:30 RELEASE=NO - - - - - 14 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 - configure.ac - + testsuite/tests/arityanal/should_compile/T21755.hs - + testsuite/tests/arityanal/should_compile/T21755.stderr - testsuite/tests/arityanal/should_compile/all.T - + testsuite/tests/concurrent/T2317/T21694a.hs - + testsuite/tests/concurrent/T2317/T21694a.stderr - + testsuite/tests/simplCore/should_compile/T21694.hs - + testsuite/tests/simplCore/should_compile/T21694b.hs - + testsuite/tests/simplCore/should_compile/T21694b.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -695,6 +695,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 ===================================== @@ -18,7 +18,7 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), mkBotArityType, mkTopArityType, expandableArityType + , ArityType(..), mkBotArityType, mkManifestArityType, expandableArityType , arityTypeArity, maxWithArity, idArityType -- ** Join points @@ -56,7 +56,6 @@ import GHC.Core.TyCon ( tyConArity ) import GHC.Core.TyCon.RecWalk ( initRecTc, checkRecTc ) import GHC.Core.Predicate ( isDictTy ) import GHC.Core.Multiplicity -import GHC.Types.Var.Set import GHC.Types.Basic import GHC.Types.Tickish import GHC.Builtin.Uniques @@ -532,7 +531,8 @@ Then f :: \??.T -- 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]. @@ -579,11 +579,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 @@ -623,7 +628,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 @@ -763,6 +768,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) @@ -772,16 +778,32 @@ 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 (AT [] div1) at2 - | isDeadEndDiv div1 = at2 -- Note [ABot branches: max arity wins] - | otherwise = takeWhileOneShot at2 -- See Note [Combining case branches] -andArityType at1 (AT [] div2) - | isDeadEndDiv div2 = at1 -- Note [ABot branches: max arity wins] - | otherwise = takeWhileOneShot at1 -- 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 (map bogus_add_work lams2) topDiv -- We know div1 = topDiv + -- See Note [Combining case branches: andWithTail] + where + bogus_add_work = id -- TODO bogus + {- Note [ABot branches: max arity wins] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -792,9 +814,48 @@ 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] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider +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 @@ -872,22 +933,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 @@ -895,7 +955,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! @@ -914,32 +978,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 @@ -978,8 +1027,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 @@ -987,7 +1039,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] @@ -999,12 +1054,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 + = ASSERT2( (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) @@ -1041,50 +1097,104 @@ 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) + alts_type = foldr1 (andArityType env) (map arity_type_alt alts) + +arityType env (Let (NonRec b r) e) + = -- See Note [arityType for let-bindings] + floatIn cheap_rhs (arityType env' e) where - env' = extendJoinEnv env [j] + 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 [Eta-expansion and join points] - foldr (andArityType . do_one) (arityType env' body) pairs + = -- See Note [arityType for join bindings] + foldr (andArityType env . do_one) (arityType rec_env body) pairs where - env' = extendJoinEnv env (map fst pairs) + 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 env' $ snd $ collectNBinders arity rhs + = arityType rec_env $ snd $ collectNBinders arity rhs | otherwise = pprPanic "arityType:joinrec" (ppr pairs) -arityType env (Let (NonRec b r) e) - = floatIn cheap_rhs (arityType env' e) - where - cheap_rhs = myExprIsCheap env r (Just (idType b)) - env' = extendSigEnv env b (arityType env r) - 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 @@ -1097,42 +1207,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 ===================================== @@ -2064,19 +2064,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') } @@ -2183,6 +2196,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 ===================================== @@ -1697,9 +1697,7 @@ tryEtaExpandRhs :: SimplMode -> OutId -> OutExpr tryEtaExpandRhs mode 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 ===================================== configure.ac ===================================== @@ -20,7 +20,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.4], [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 ===================================== 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 ===================================== @@ -21,3 +21,4 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn 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/concurrent/T2317/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/concurrent/T2317/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/simplCore/should_compile/T21694.hs ===================================== @@ -0,0 +1,91 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -Wall #-} +module Bug (go_fast_end) where + +import Control.Monad.ST (ST) +import qualified Data.ByteString.Internal as BS +import qualified Data.ByteString.Unsafe as BS +import Data.ByteString (ByteString) +import Foreign.ForeignPtr (withForeignPtr) +import Foreign.Ptr (plusPtr) +import GHC.Exts ( Int(..), Int#, Ptr(..), Word(..) + , (<#), (>#), indexWord64OffAddr#, isTrue#, orI# + ) +import GHC.Word (Word8(..), Word64(..)) +import System.IO.Unsafe (unsafeDupablePerformIO) + +#if MIN_VERSION_ghc_prim(0,8,0) +import GHC.Exts (word8ToWord#) +#endif + +#if __GLASGOW_HASKELL__ >= 904 +import GHC.Exts (byteSwap64#, int64ToInt#, word64ToInt64#, ltWord64#, wordToWord64#) +#else +import GHC.Exts (byteSwap#, ltWord#, word2Int#) +#endif + +go_fast_end :: ByteString -> DecodeAction s a -> ST s (SlowPath s a) +go_fast_end !bs (ConsumeInt32 k) = + case tryConsumeInt (BS.unsafeHead bs) bs of + DecodeFailure -> return $! SlowFail bs "expected int32" + DecodedToken sz (I# n#) -> + case (n# ># 0x7fffffff#) `orI#` (n# <# -0x80000000#) of + 0# -> k n# >>= go_fast_end (BS.unsafeDrop sz bs) + _ -> return $! SlowFail bs "expected int32" + +data SlowPath s a = SlowFail {-# UNPACK #-} !ByteString String + +data DecodeAction s a = ConsumeInt32 (Int# -> ST s (DecodeAction s a)) + +data DecodedToken a = DecodedToken !Int !a | DecodeFailure + +tryConsumeInt :: Word8 -> ByteString -> DecodedToken Int +tryConsumeInt hdr !bs = case word8ToWord hdr of + 0x17 -> DecodedToken 1 23 + 0x1b -> case word64ToInt (eatTailWord64 bs) of + Just n -> DecodedToken 9 n + Nothing -> DecodeFailure + _ -> DecodeFailure +{-# INLINE tryConsumeInt #-} + +eatTailWord64 :: ByteString -> Word64 +eatTailWord64 xs = withBsPtr grabWord64 (BS.unsafeTail xs) +{-# INLINE eatTailWord64 #-} + +word64ToInt :: Word64 -> Maybe Int +#if __GLASGOW_HASKELL__ >= 904 +word64ToInt (W64# w#) = + case isTrue# (w# `ltWord64#` wordToWord64# 0x80000000##) of + True -> Just (I# (int64ToInt# (word64ToInt64# w#))) + False -> Nothing +#else +word64ToInt (W64# w#) = + case isTrue# (w# `ltWord#` 0x8000000000000000##) of + True -> Just (I# (word2Int# w#)) + False -> Nothing +#endif +{-# INLINE word64ToInt #-} + +withBsPtr :: (Ptr b -> a) -> ByteString -> a +withBsPtr f (BS.PS x off _) = + unsafeDupablePerformIO $ withForeignPtr x $ + \(Ptr addr#) -> return $! (f (Ptr addr# `plusPtr` off)) +{-# INLINE withBsPtr #-} + +grabWord64 :: Ptr () -> Word64 +#if __GLASGOW_HASKELL__ >= 904 +grabWord64 (Ptr ip#) = W64# (byteSwap64# (indexWord64OffAddr# ip# 0#)) +#else +grabWord64 (Ptr ip#) = W64# (byteSwap# (indexWord64OffAddr# ip# 0#)) +#endif +{-# INLINE grabWord64 #-} + +word8ToWord :: Word8 -> Word +#if MIN_VERSION_ghc_prim(0,8,0) +word8ToWord (W8# w#) = W# (word8ToWord# w#) +#else +word8ToWord (W8# w#) = W# w# +#endif +{-# INLINE word8ToWord #-} ===================================== 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 + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -291,6 +291,7 @@ test('T16348', normal, compile, ['-O']) test('T16918', normal, compile, ['-O']) test('T16918a', normal, compile, ['-O']) test('T16978a', normal, compile, ['-O']) +test('T21694', [ req_profiling ] , compile, ['-O -prof -fprof-auto -funfolding-use-threshold=50 ']) test('T16978b', normal, compile, ['-O']) test('T16979a', normal, compile, ['-O']) test('T16979b', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1ebd4ddf6e0a7435232fbfbc4797e0fc60762e17...d33a59b41c709d01903d384f6f6f8a62989518c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1ebd4ddf6e0a7435232fbfbc4797e0fc60762e17...d33a59b41c709d01903d384f6f6f8a62989518c4 You're receiving 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 Sep 19 13:07:21 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 19 Sep 2022 09:07:21 -0400 Subject: [Git][ghc/ghc][master] Scrub partiality about `NewOrData`. Message-ID: <63286989d8e72_3b59a620aecbec25561cd@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Monad.hs - compiler/Language/Haskell/Syntax/Decls.hs - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/parser/should_compile/T20452.stderr - + testsuite/tests/parser/should_fail/T22070.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1f81b38625a5fea7fb8160a3a62ae6be078a7b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1f81b38625a5fea7fb8160a3a62ae6be078a7b1 You're receiving 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 Sep 19 13:07:57 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 19 Sep 2022 09:07:57 -0400 Subject: [Git][ghc/ghc][master] CmmToC: emit __builtin_unreachable() after noreturn ccalls Message-ID: <632869ad1153b_3b59a65152c25597c8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - compiler/GHC/CmmToC.hs Changes: ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -251,7 +251,7 @@ pprStmt platform stmt = -- can't add the @n suffix ourselves, because -- it isn't valid C. | CmmNeverReturns <- ret -> - pprCall platform cast_fn cconv hresults hargs <> semi + pprCall platform cast_fn cconv hresults hargs <> semi <> text "__builtin_unreachable();" | not (isMathFun lbl) -> pprForeignCall platform (pprCLabel platform CStyle lbl) cconv hresults hargs _ -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e1ed8c5224a2a2d8ccf502da08a24ce71fd5ac6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e1ed8c5224a2a2d8ccf502da08a24ce71fd5ac6 You're receiving 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 Sep 19 13:11:56 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 19 Sep 2022 09:11:56 -0400 Subject: [Git][ghc/ghc][wip/wither-eq1-and-friends] 7 commits: DeriveFunctor: Check for last type variables using dataConUnivTyVars Message-ID: <63286a9c78c53_3b59a6194ffb50256543c@gitlab.mail> sheaf pushed to branch wip/wither-eq1-and-friends at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - e729e45e by John Ericson at 2022-09-19T15:11:23+02:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - a9a844fd by John Ericson at 2022-09-19T15:11:23+02: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. - - - - - 30 changed files: - compiler/GHC/CmmToC.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv/Functor.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Infer.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Monad.hs - compiler/Language/Haskell/Syntax/Decls.hs - libraries/base/Data/Functor/Classes.hs - libraries/base/Data/Functor/Compose.hs - libraries/base/Data/Functor/Product.hs - libraries/base/Data/Functor/Sum.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f53f0f1f8679552007545da4993e42580dcb3212...a9a844fdfcc3aa3eecf36238c0e0a74b550d9482 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f53f0f1f8679552007545da4993e42580dcb3212...a9a844fdfcc3aa3eecf36238c0e0a74b550d9482 You're receiving 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 Sep 19 13:13:11 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Mon, 19 Sep 2022 09:13:11 -0400 Subject: [Git][ghc/ghc][wip/wither-eq1-and-friends] Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking Message-ID: <63286ae7daf73_3b59a620aecc14256971a@gitlab.mail> sheaf pushed to branch wip/wither-eq1-and-friends at Glasgow Haskell Compiler / GHC Commits: b3b50765 by John Ericson at 2022-09-19T15:13:01+02: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. - - - - - 6 changed files: - libraries/base/Data/Functor/Classes.hs - libraries/base/Data/Functor/Compose.hs - libraries/base/Data/Functor/Product.hs - libraries/base/Data/Functor/Sum.hs - libraries/base/changelog.md - utils/haddock Changes: ===================================== libraries/base/Data/Functor/Classes.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE QuantifiedConstraints #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Classes @@ -91,8 +94,18 @@ import Text.Show (showListWith) -- | Lifting of the 'Eq' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftEq (==)@ = @(==)@ +-- +-- This class therefore represents the generalization of 'Eq' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Eq1 f where +class (forall a. Eq a => Eq (f a)) => Eq1 f where -- | Lift an equality test through the type constructor. -- -- The function will usually be applied to an equality function, @@ -102,6 +115,10 @@ class Eq1 f where -- -- @since 4.9.0.0 liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool + default liftEq + :: (f ~ f' c, Eq2 f', Eq c) + => (a -> b -> Bool) -> f a -> f b -> Bool + liftEq = liftEq2 (==) -- | Lift the standard @('==')@ function through the type constructor. -- @@ -111,8 +128,18 @@ eq1 = liftEq (==) -- | Lifting of the 'Ord' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftCompare compare@ = 'compare' +-- +-- This class therefore represents the generalization of 'Ord' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class (Eq1 f) => Ord1 f where +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where -- | Lift a 'compare' function through the type constructor. -- -- The function will usually be applied to a comparison function, @@ -122,6 +149,10 @@ class (Eq1 f) => Ord1 f where -- -- @since 4.9.0.0 liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + default liftCompare + :: (f ~ f' c, Ord2 f', Ord c) + => (a -> b -> Ordering) -> f a -> f b -> Ordering + liftCompare = liftCompare2 compare -- | Lift the standard 'compare' function through the type constructor. -- @@ -131,6 +162,22 @@ compare1 = liftCompare compare -- | Lifting of the 'Read' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftReadsPrec readsPrec readList@ = 'readsPrec' +-- +-- @liftReadList readsPrec readList@ = 'readList' +-- +-- @liftReadPrec readPrec readListPrec@ = 'readPrec' +-- +-- @liftReadListPrec readPrec readListPrec@ = 'readListPrec' +-- +-- This class therefore represents the generalization of 'Read' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- Both 'liftReadsPrec' and 'liftReadPrec' exist to match the interface -- provided in the 'Read' type class, but it is recommended to implement -- 'Read1' instances using 'liftReadPrec' as opposed to 'liftReadsPrec', since @@ -145,7 +192,7 @@ compare1 = liftCompare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read1 f where +class (forall a. Read a => Read (f a)) => Read1 f where {-# MINIMAL liftReadsPrec | liftReadPrec #-} -- | 'readsPrec' function for an application of the type constructor @@ -219,14 +266,30 @@ liftReadListPrecDefault rp rl = list (liftReadPrec rp rl) -- | Lifting of the 'Show' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftShowsPrec showsPrec showList@ = 'showsPrec' +-- +-- @liftShowList showsPrec showList@ = 'showList' +-- +-- This class therefore represents the generalization of 'Show' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Show1 f where +class (forall a. Show a => Show (f a)) => Show1 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. -- -- @since 4.9.0.0 liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + default liftShowsPrec + :: (f ~ f' b, Show2 f', Show b) + => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + liftShowsPrec = liftShowsPrec2 showsPrec showList -- | 'showList' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. @@ -248,7 +311,7 @@ showsPrec1 = liftShowsPrec showsPrec showList -- | Lifting of the 'Eq' class to binary type constructors. -- -- @since 4.9.0.0 -class Eq2 f where +class (forall a. Eq a => Eq1 (f a)) => Eq2 f where -- | Lift equality tests through the type constructor. -- -- The function will usually be applied to equality functions, @@ -268,7 +331,7 @@ eq2 = liftEq2 (==) (==) -- | Lifting of the 'Ord' class to binary type constructors. -- -- @since 4.9.0.0 -class (Eq2 f) => Ord2 f where +class (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 f where -- | Lift 'compare' functions through the type constructor. -- -- The function will usually be applied to comparison functions, @@ -302,7 +365,7 @@ compare2 = liftCompare2 compare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read2 f where +class (forall a. Read a => Read1 (f a)) => Read2 f where {-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-} -- | 'readsPrec' function for an application of the type constructor @@ -385,7 +448,7 @@ liftReadListPrec2Default rp1 rl1 rp2 rl2 = list (liftReadPrec2 rp1 rl1 rp2 rl2) -- | Lifting of the 'Show' class to binary type constructors. -- -- @since 4.9.0.0 -class Show2 f where +class (forall a. Show a => Show1 (f a)) => Show2 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument types. -- ===================================== libraries/base/Data/Functor/Compose.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | @@ -32,7 +33,7 @@ import Data.Coerce (coerce) import Data.Data (Data) import Data.Type.Equality (TestEquality(..), (:~:)(..)) import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () infixr 9 `Compose` @@ -47,6 +48,17 @@ newtype Compose f g a = Compose { getCompose :: f (g a) } , Monoid -- ^ @since 4.16.0.0 ) +-- Instances of Prelude classes + +-- | @since 4.18.0.0 +deriving instance Eq (f (g a)) => Eq (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Ord (f (g a)) => Ord (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Read (f (g a)) => Read (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Show (f (g a)) => Show (Compose f g a) + -- Instances of lifted Prelude classes -- | @since 4.9.0.0 @@ -77,27 +89,6 @@ instance (Show1 f, Show1 g) => Show1 (Compose f g) where sp' = liftShowsPrec sp sl sl' = liftShowList sp sl --- Instances of Prelude classes - --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where - (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Compose f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where - showsPrec = showsPrec1 - -- Functor instances -- | @since 4.9.0.0 ===================================== libraries/base/Data/Functor/Product.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Product @@ -28,7 +29,7 @@ import Control.Monad.Zip (MonadZip(mzipWith)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted product of functors. data Product f g a = Pair (f a) (g a) @@ -37,6 +38,15 @@ data Product f g a = Pair (f a) (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Product f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Product f g) where liftEq eq (Pair x1 y1) (Pair x2 y2) = liftEq eq x1 x2 && liftEq eq y1 y2 @@ -59,25 +69,6 @@ instance (Show1 f, Show1 g) => Show1 (Product f g) where liftShowsPrec sp sl d (Pair x y) = showsBinaryWith (liftShowsPrec sp sl) (liftShowsPrec sp sl) "Pair" d x y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) - where (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Product f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Product f g) where fmap f (Pair x y) = Pair (fmap f x) (fmap f y) ===================================== libraries/base/Data/Functor/Sum.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Sum @@ -25,7 +26,7 @@ import Control.Applicative ((<|>)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted sum of functors. data Sum f g a = InL (f a) | InR (g a) @@ -34,6 +35,15 @@ data Sum f g a = InL (f a) | InR (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Sum f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Sum f g) where liftEq eq (InL x1) (InL x2) = liftEq eq x1 x2 @@ -64,22 +74,6 @@ instance (Show1 f, Show1 g) => Show1 (Sum f g) where liftShowsPrec sp sl d (InR y) = showsUnaryWith (liftShowsPrec sp sl) "InR" d y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) where - (==) = eq1 --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) where - compare = compare1 --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Sum f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Sum f g) where fmap f (InL x) = InL (fmap f x) ===================================== libraries/base/changelog.md ===================================== @@ -31,6 +31,11 @@ as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) * Update to Unicode 15.0.0. * Add `Eq` and `Ord` instances for `Generically1`. + * Relax instances for Functor combinators; put superclass on Class1 and Class2 + to make non-breaking. See [CLC + #10](https://github.com/haskell/core-libraries-committee/issues/10) for the + related discussion, as well as [the migration + guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). ## 4.17.0.0 *August 2022* ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b5e40b15228fdca5ce7d4e2f2241156d0b085261 +Subproject commit 7e4326f999056fb7b0b955ccadf5eab86b755a0d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3b50765a2267fb648e79dcb45319e2a6c9a4f75 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3b50765a2267fb648e79dcb45319e2a6c9a4f75 You're receiving 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 Sep 19 13:44:00 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Mon, 19 Sep 2022 09:44:00 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: SysTools.Tasks: quiet non-totality warnings Message-ID: <63287220edd6e_3b59a620aecbec26004fa@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 286a7604 by doyougnu at 2022-09-19T09:23:46-04:00 SysTools.Tasks: quiet non-totality warnings - - - - - c0b9801f by doyougnu at 2022-09-19T09:43:49-04:00 JS.Primops: Add InterlockedExchange Addr Word - - - - - 2 changed files: - compiler/GHC/StgToJS/Prim.hs - compiler/GHC/SysTools/Tasks.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -470,7 +470,9 @@ genPrim prof ty op = case op of DoubleToIntOp -> \[r] [x] -> PrimInline $ r |= i32 x DoubleToFloatOp -> \[r] [x] -> PrimInline $ r |= app "h$fround" [x] DoubleExpOp -> \[r] [x] -> PrimInline $ r |= math_exp [x] + DoubleExpM1Op -> \[r] [x] -> PrimInline $ r |= math_exp [x] DoubleLogOp -> \[r] [x] -> PrimInline $ r |= math_log [x] + DoubleLog1POp -> \[r] [x] -> PrimInline $ r |= math_log [x] DoubleSqrtOp -> \[r] [x] -> PrimInline $ r |= math_sqrt [x] DoubleSinOp -> \[r] [x] -> PrimInline $ r |= math_sin [x] DoubleCosOp -> \[r] [x] -> PrimInline $ r |= math_cos [x] @@ -504,7 +506,9 @@ genPrim prof ty op = case op of FloatFabsOp -> \[r] [x] -> PrimInline $ r |= math_abs [x] FloatToIntOp -> \[r] [x] -> PrimInline $ r |= i32 x FloatExpOp -> \[r] [x] -> PrimInline $ r |= math_exp [x] + FloatExpM1Op -> \[r] [x] -> PrimInline $ r |= math_exp [x] FloatLogOp -> \[r] [x] -> PrimInline $ r |= math_log [x] + FloatLog1POp -> \[r] [x] -> PrimInline $ r |= math_log [x] FloatSqrtOp -> \[r] [x] -> PrimInline $ r |= math_sqrt [x] FloatSinOp -> \[r] [x] -> PrimInline $ r |= math_sin [x] FloatCosOp -> \[r] [x] -> PrimInline $ r |= math_cos [x] @@ -1027,16 +1031,6 @@ genPrim prof ty op = case op of TraceEventBinaryOp -> \[] [ed,eo,len] -> PrimInline $ appS "h$traceEventBinary" [ed,eo,len] TraceMarkerOp -> \[] [ed,eo] -> PrimInline $ appS "h$traceMarker" [ed,eo] ------------------------------- Unhandled primops ------------------- - - DoubleExpM1Op -> unhandledPrimop op - DoubleLog1POp -> unhandledPrimop op - FloatExpM1Op -> unhandledPrimop op - FloatLog1POp -> unhandledPrimop op - - ShrinkSmallMutableArrayOp_Char -> unhandledPrimop op - GetSizeofSmallMutableArrayOp -> unhandledPrimop op - IndexByteArrayOp_Word8AsChar -> \[r] [a,i] -> PrimInline $ r |= dv_u8 a i IndexByteArrayOp_Word8AsWideChar -> \[r] [a,i] -> PrimInline $ r |= dv_i32 a i IndexByteArrayOp_Word8AsAddr -> \[r1,r2] [a,i] -> @@ -1161,10 +1155,6 @@ genPrim prof ty op = case op of mempty ] - - InterlockedExchange_Addr -> unhandledPrimop op - InterlockedExchange_Word -> unhandledPrimop op - CasAddrOp_Addr -> \[r_a,r_o] [a1,o1,a2,o2,a3,o3] -> PrimInline $ mconcat [ ifS (app "h$comparePointer" [a1,o1,a2,o2]) (appS "h$memcpy" [a3,o3,a1,o1,8]) @@ -1209,6 +1199,24 @@ genPrim prof ty op = case op of FetchOrAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BOr r a o v FetchXorAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BXor r a o v + +------------------------------ Unhandled primops ------------------- + + ShrinkSmallMutableArrayOp_Char -> unhandledPrimop op + GetSizeofSmallMutableArrayOp -> unhandledPrimop op + + InterlockedExchange_Addr -> \[r_a,r_o] [a1,o1,a2,o2] -> PrimInline $ + mconcat [ r_a |= a1 + , r_o |= o1 + , a1 .! o1 |= a2 .! o2 + , o1 |= o2 + ] + InterlockedExchange_Word -> \[r] [a,o,w] -> PrimInline $ + mconcat [ r |= a .! o + , dv_s_u32 a o w + ] + + AtomicReadAddrOp_Word -> unhandledPrimop op AtomicWriteAddrOp_Word -> unhandledPrimop op ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -159,6 +159,10 @@ runCc mLanguage logger tmpfs dflags args = traceSystoolCommand logger "cc" $ do ,pgm_c dflags, "Asm Compiler") RawObject -> ("c", [] ,pgm_c dflags, "C Compiler") -- claim C for lack of a better idea + --JS backend shouldn't reach here, so we just pass + -- strings to satisfy the totality checker + LangJs -> ("js", [] + ,pgm_c dflags, "JS Backend Compiler") userOpts_c = getOpts dflags opt_c userOpts_cxx = getOpts dflags opt_cxx View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5519d574c0b3bed51fb01671de01302925c1240e...c0b9801f7e5e332192fb6f86ae86437e68411287 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5519d574c0b3bed51fb01671de01302925c1240e...c0b9801f7e5e332192fb6f86ae86437e68411287 You're receiving 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 Sep 19 15:39:25 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 19 Sep 2022 11:39:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Scrub partiality about `NewOrData`. Message-ID: <63288d2d1e877_3a3c1551838187823@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 8a60b1cb by Jan Hrček at 2022-09-19T11:39:08-04:00 Document :unadd GHCi command in user guide - - - - - 1bd203d4 by sheaf at 2022-09-19T11:39:09-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). - - - - - 8f2037ca by Vladislav Zavialov at 2022-09-19T11:39:10-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. - - - - - 30 changed files: - compiler/GHC/CmmToC.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Utils/Monad.hs - compiler/Language/Haskell/Syntax/Decls.hs - configure.ac - docs/users_guide/9.6.1-notes.rst - docs/users_guide/ghci.rst - ghc/GHCi/UI.hs - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Builders/Ar.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f0714717fa33beab9f36aeb32925f8af39d5d78...8f2037ca2808d034cd455d879c186529cb46f5ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3f0714717fa33beab9f36aeb32925f8af39d5d78...8f2037ca2808d034cd455d879c186529cb46f5ad You're receiving 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 Sep 19 16:12:58 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 19 Sep 2022 12:12:58 -0400 Subject: [Git][ghc/ghc][wip/T21986] 162 commits: testsuite: 21651 add test for closeFdWith + setNumCapabilities Message-ID: <6328950a6a345_3a3c15513d82217b4@gitlab.mail> Andreas Klebinger pushed to branch wip/T21986 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 4d233b9c by Ben Gamari at 2022-09-19T16:12:36+00:00 gitlab-ci: Use clang-14 on FreeBSD 13 To workaround #21986, which appears to be an upstream bug. - - - - - 5273f458 by Ben Gamari at 2022-09-19T16:12:36+00:00 testsuite: Mark encoding004 as broken on FreeBSD Due to #22003. - - - - - 71a57e2f by Ben Gamari at 2022-09-19T16:12:36+00:00 rts/linker: Fix non-prototype declaration warnings - - - - - 7ea85a4d by Ben Gamari at 2022-09-19T16:12:36+00:00 gitlab-ci: Don't allow FreeBSD job to fail - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6eb0088ed9deea84677fb57e8c8a3c7dcf54d7a8...7ea85a4d366fc341b3f61fef199e21b09606da82 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6eb0088ed9deea84677fb57e8c8a3c7dcf54d7a8...7ea85a4d366fc341b3f61fef199e21b09606da82 You're receiving 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 Sep 19 16:16:59 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 19 Sep 2022 12:16:59 -0400 Subject: [Git][ghc/ghc][wip/T21847] 156 commits: Add support for external static plugins (#20964) Message-ID: <632895fb3ca64_3a3c155181024027d@gitlab.mail> Andreas Klebinger pushed to branch wip/T21847 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 6a3da03e by Ben Gamari at 2022-09-19T16:16:54+00: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. - - - - - d3f70414 by Ben Gamari at 2022-09-19T16:16:54+00:00 rts/linker: Add support for .fini sections - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8031c2ec033c7af3ef1759a5f2b8ec39b198b1ea...d3f7041493458f9c7e07f211fa6b2e9e0e84d4f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8031c2ec033c7af3ef1759a5f2b8ec39b198b1ea...d3f7041493458f9c7e07f211fa6b2e9e0e84d4f2 You're receiving 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 Sep 19 21:43:00 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 19 Sep 2022 17:43:00 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/warn-star-default Message-ID: <6328e26438705_3a3c15513c4314051@gitlab.mail> Vladislav Zavialov pushed new branch wip/warn-star-default at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/warn-star-default You're receiving 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 Sep 20 07:49:47 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 03:49:47 -0400 Subject: [Git][ghc/ghc][master] Document :unadd GHCi command in user guide Message-ID: <6329709b6b46b_3a3c15514f040112c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 2 changed files: - docs/users_guide/ghci.rst - ghc/GHCi/UI.hs Changes: ===================================== docs/users_guide/ghci.rst ===================================== @@ -541,8 +541,9 @@ including entities that are in scope in the current module context. .. warning:: Temporary bindings introduced at the prompt only last until the - next :ghci-cmd:`:load` or :ghci-cmd:`:reload` command, at which time they - will be simply lost. However, they do survive a change of context with + next :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` or + :ghci-cmd:`:unadd` command, at which time they will be simply lost. + However, they do survive a change of context with :ghci-cmd:`:module`: the temporary bindings just move to the new location. .. hint:: @@ -731,7 +732,7 @@ When you type an expression at the prompt, what identifiers and types are in scope? GHCi provides a flexible way to control exactly how the context for an expression is constructed: -- The :ghci-cmd:`:load`, :ghci-cmd:`:add`, and :ghci-cmd:`:reload` commands +- The :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd` commands (:ref:`ghci-load-scope`). - The ``import`` declaration (:ref:`ghci-import-decl`). @@ -751,7 +752,7 @@ contribute to the top-level scope. The effect of ``:load`` on what is in scope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The :ghci-cmd:`:load`, :ghci-cmd:`:add`, and :ghci-cmd:`:reload` commands +The :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd` commands (:ref:`loading-source-files` and :ref:`ghci-compiled`) affect the top-level scope. Let's start with the simple cases; when you start GHCi the prompt looks like this: @@ -796,7 +797,7 @@ automatically-added imports can be seen with :ghci-cmd:`:show imports`: *ghci> and the automatically-added import is replaced the next time you use -:ghci-cmd:`:load`, :ghci-cmd:`:add`, or :ghci-cmd:`:reload`. It can also be +:ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` or :ghci-cmd:`:unadd`. It can also be removed by :ghci-cmd:`:module` as with normal imports. .. _ghci-import-decl: @@ -895,13 +896,13 @@ can use both to bring a module into scope. However, there is a very important difference. GHCi is concerned with two sets of modules: - The set of modules that are currently *loaded*. This set is modified - by :ghci-cmd:`:load`, :ghci-cmd:`:add` and :ghci-cmd:`:reload`, and can be shown with + by :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd`, and can be shown with :ghci-cmd:`:show modules`. - The set of modules that are currently *in scope* at the prompt. This set is modified by ``import`` and :ghci-cmd:`:module`, and it is also modified - automatically after :ghci-cmd:`:load`, :ghci-cmd:`:add`, and - :ghci-cmd:`:reload`, as described above. The set of modules in scope can be + automatically after :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` + and :ghci-cmd:`:unadd`, as described above. The set of modules in scope can be shown with :ghci-cmd:`:show imports`. You can add a module to the scope (via :ghci-cmd:`:module` or ``import``) only @@ -1173,7 +1174,7 @@ The :ghc-flag:`-interactive-print ⟨name⟩` flag allows to specify any functio of type ``C a => a -> IO ()``, for some constraint ``C``, as the function for printing evaluated expressions. The function can reside in any loaded module or any registered package, but only when it resides in a registered package will -it survive a :ghci-cmd:`:cd`, :ghci-cmd:`:add`, :ghci-cmd:`:load`, +it survive a :ghci-cmd:`:cd`, :ghci-cmd:`:add`, :ghci-cmd:`:unadd`, :ghci-cmd:`:load`, :ghci-cmd:`:reload` or, :ghci-cmd:`:set`. .. ghc-flag:: -interactive-print ⟨name⟩ @@ -2191,7 +2192,7 @@ commonly used commands. Using the ``*`` prefix forces the module to be loaded as byte-code. ⟨module⟩ may be a file path. A "``~``" symbol at the beginning of - ⟨module⟩ will be replaced by the contents of the environment variable + ⟨module⟩ will be replaced by the contents of the environment variable :envvar:`HOME`. .. ghci-cmd:: :all-types @@ -2948,6 +2949,12 @@ commonly used commands. Show the currently active language flags for expressions typed at the prompt (see also :ghci-cmd:`:seti`). +.. ghci-cmd:: :show targets + + Show list of currently loaded modules. + This set of loaded modules can be modified by :ghci-cmd:`:load`, + :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd`. + .. ghci-cmd:: :show; [args|prog|prompt|editor|stop] Displays the specified setting (see :ghci-cmd:`:set`). @@ -3044,6 +3051,11 @@ commonly used commands. The :ghci-cmd:`:type-at` command requires :ghci-cmd:`:set +c` to be set. +.. ghci-cmd:: :unadd; ⟨module⟩ + + Removes ⟨module⟩(s) from the current target set, and perform a reload + (see :ghci-cmd:`:add` above). + .. ghci-cmd:: :undef; ⟨name⟩ Undefines the user-defined command ⟨name⟩ (see :ghci-cmd:`:def` above). ===================================== ghc/GHCi/UI.hs ===================================== @@ -1994,7 +1994,7 @@ instancesCmd s = do printForUser $ vcat $ map ppr res ----------------------------------------------------------------------------- --- :load, :add, :reload +-- :load, :add, :unadd, :reload -- | Sets '-fdefer-type-errors' if 'defer' is true, executes 'load' and unsets -- '-fdefer-type-errors' again if it has not been set before. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19f45a25f4b14fff081d75f506e7992c81371fc5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19f45a25f4b14fff081d75f506e7992c81371fc5 You're receiving 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 Sep 20 07:50:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 03:50:22 -0400 Subject: [Git][ghc/ghc][master] Hadrian: merge archives even in stage 0 Message-ID: <632970be72e0d_3a3c15515f44053a9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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). - - - - - 4 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Builders/Ar.hs Changes: ===================================== configure.ac ===================================== @@ -201,6 +201,7 @@ if test "$WithGhc" != ""; then fi BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsDashL_STAGE0],[ar supports -L]) BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP]) BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) ===================================== hadrian/cfg/system.config.in ===================================== @@ -39,10 +39,11 @@ python = @PythonCmd@ # Information about builders: #============================ -ar-supports-at-file = @ArSupportsAtFile@ -ar-supports-dash-l = @ArSupportsDashL@ -cc-llvm-backend = @CcLlvmBackend@ -hs-cpp-args = @HaskellCPPArgs@ +ar-supports-at-file = @ArSupportsAtFile@ +ar-supports-dash-l = @ArSupportsDashL@ +system-ar-supports-dash-l = @ArSupportsDashL_STAGE0@ +cc-llvm-backend = @CcLlvmBackend@ +hs-cpp-args = @HaskellCPPArgs@ # Build options: #=============== ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -5,7 +5,8 @@ module Oracles.Flag ( platformSupportsSharedLibs, platformSupportsGhciObjects, targetSupportsSMP, - useLibffiForAdjustors + useLibffiForAdjustors, + arSupportsDashL ) where import Hadrian.Oracles.TextFile @@ -16,6 +17,7 @@ import Oracles.Setting data Flag = ArSupportsAtFile | ArSupportsDashL + | SystemArSupportsDashL | CrossCompiling | CcLlvmBackend | GhcUnregisterised @@ -39,6 +41,7 @@ flag f = do let key = case f of ArSupportsAtFile -> "ar-supports-at-file" ArSupportsDashL -> "ar-supports-dash-l" + SystemArSupportsDashL-> "system-ar-supports-dash-l" CrossCompiling -> "cross-compiling" CcLlvmBackend -> "cc-llvm-backend" GhcUnregisterised -> "ghc-unregisterised" @@ -69,6 +72,10 @@ platformSupportsGhciObjects :: Action Bool platformSupportsGhciObjects = not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand +arSupportsDashL :: Stage -> Action Bool +arSupportsDashL (Stage0 {}) = flag SystemArSupportsDashL +arSupportsDashL _ = flag ArSupportsDashL + platformSupportsSharedLibs :: Action Bool platformSupportsSharedLibs = do windows <- isWinTarget ===================================== hadrian/src/Settings/Builders/Ar.hs ===================================== @@ -6,7 +6,9 @@ import Settings.Builders.Common -- want to place these in a response file. This is handled in -- 'Hadrian.Builder.Ar.runAr'. arBuilderArgs :: Args -arBuilderArgs = mconcat +arBuilderArgs = do + stage <- getStage + mconcat [ builder (Ar Pack) ? mconcat [ -- When building on platforms which don't support object merging -- we must use the -L flag supported by llvm-ar, which ensures that @@ -14,7 +16,7 @@ arBuilderArgs = mconcat -- not added as a single file. This requires that we are using llvm-ar -- -- See Note [Object merging] in GHC.Driver.Pipeline.Execute for details. - ifM ((&&) <$> notStage0 <*> expr (flag ArSupportsDashL)) (arg "qL") (arg "q") + ifM (expr $ arSupportsDashL stage) (arg "qL") (arg "q") , arg =<< getOutput ] , builder (Ar Unpack) ? mconcat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/545ff490144ed3ddd596d2a0c01b0a16b5528f63 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/545ff490144ed3ddd596d2a0c01b0a16b5528f63 You're receiving 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 Sep 20 07:50:55 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 03:50:55 -0400 Subject: [Git][ghc/ghc][master] Fix -Woperator-whitespace for consym (part of #19372) Message-ID: <632970dff0f96_3a3c15515f44089bb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 5 changed files: - compiler/GHC/Parser/Lexer.x - docs/users_guide/9.6.1-notes.rst - + testsuite/tests/parser/should_compile/T19372consym.hs - + testsuite/tests/parser/should_compile/T19372consym.stderr - testsuite/tests/parser/should_compile/all.T Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -496,7 +496,7 @@ $tab { warnTab } @qvarsym { idtoken qvarsym } @qconsym { idtoken qconsym } @varsym { with_op_ws varsym } - @consym { consym } + @consym { with_op_ws consym } } -- For the normal boxed literals we need to be careful @@ -1681,7 +1681,7 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym :: OpWs -> Action -varsym OpWsPrefix = sym $ \span exts s -> +varsym opws at OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) ; return (ITvarsym s) } @@ -1709,35 +1709,48 @@ varsym OpWsPrefix = sym $ \span exts s -> | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Prefix) + do { warnOperatorWhitespace opws span s ; return (ITvarsym s) } -varsym OpWsSuffix = sym $ \span _ s -> +varsym opws at OpWsSuffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc $ PsErrSuffixAT) | s == fsLit "." -> return ITdot | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Suffix) + do { warnOperatorWhitespace opws span s ; return (ITvarsym s) } -varsym OpWsTightInfix = sym $ \span exts s -> +varsym opws at OpWsTightInfix = sym $ \span exts s -> if | s == fsLit "@" -> return ITat | s == fsLit ".", OverloadedRecordDotBit `xtest` exts -> return (ITproj False) | s == fsLit "." -> return ITdot | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s (OperatorWhitespaceOccurrence_TightInfix)) - ; return (ITvarsym s) } + do { warnOperatorWhitespace opws span s + ; return (ITvarsym s) } varsym OpWsLooseInfix = sym $ \_ _ s -> if | s == fsLit "." -> return ITdot | otherwise -> return $ ITvarsym s -consym :: Action -consym = sym (\_span _exts s -> return $ ITconsym s) +consym :: OpWs -> Action +consym opws = sym $ \span _exts s -> + do { warnOperatorWhitespace opws span s + ; return (ITconsym s) } + +warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P () +warnOperatorWhitespace opws span s = + whenIsJust (check_unusual_opws opws) $ \opws' -> + addPsMessage + (mkSrcSpanPs span) + (PsWarnOperatorWhitespace s opws') + +-- Check an operator occurrence for unusual whitespace (prefix, suffix, tight infix). +-- This determines if -Woperator-whitespace is triggered. +check_unusual_opws :: OpWs -> Maybe OperatorWhitespaceOccurrence +check_unusual_opws opws = + case opws of + OpWsPrefix -> Just OperatorWhitespaceOccurrence_Prefix + OpWsSuffix -> Just OperatorWhitespaceOccurrence_Suffix + OpWsTightInfix -> Just OperatorWhitespaceOccurrence_TightInfix + OpWsLooseInfix -> Nothing sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len _buf2 = ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -68,6 +68,9 @@ Compiler - The :extension:`TypeInType` is now marked as deprecated. Its meaning has been included in :extension:`PolyKinds` and :extension:`DataKinds`. +- The :ghc-flag:`-Woperator-whitespace` warning no longer ignores constructor symbols + (operators starting with ``:``). + GHCi ~~~~ ===================================== testsuite/tests/parser/should_compile/T19372consym.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T19372consym where + +import Data.List.NonEmpty + +a_suffix = \x y -> x: y +a_prefix = \x y -> x :y +a_tight_infix = \x y -> x:y +a_loose_infix = \x y -> x : y -- Only this one should be without a warning. + +b_suffix = \x y -> x:| y +b_prefix = \x y -> x :|y +b_tight_infix = \x y -> x:|y +b_loose_infix = \x y -> x :| y -- Only this one should be without a warning. ===================================== testsuite/tests/parser/should_compile/T19372consym.stderr ===================================== @@ -0,0 +1,15 @@ + +T19372consym.hs:12:26: warning: [GHC-40798] [-Woperator-whitespace] + The suffix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. + +T19372consym.hs:13:27: warning: [GHC-40798] [-Woperator-whitespace] + The prefix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. + +T19372consym.hs:14:26: warning: [GHC-40798] [-Woperator-whitespace] + The tight infix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -193,3 +193,4 @@ test('T20718', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-c test('T20718b', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) test('T21589', normal, compile, ['']) +test('T19372consym', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59fe128c37b2befb1ece4bf3f8f5c9082bd213eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59fe128c37b2befb1ece4bf3f8f5c9082bd213eb You're receiving 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 Sep 20 07:55:47 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 20 Sep 2022 03:55:47 -0400 Subject: [Git][ghc/ghc][wip/js-staging] base: conditional js-sources Message-ID: <63297203a7da7_3a3c15513d84091f0@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 1dc7e8aa by Sylvain Henry at 2022-09-20T09:58:47+02:00 base: conditional js-sources - - - - - 1 changed file: - libraries/base/base.cabal Changes: ===================================== libraries/base/base.cabal ===================================== @@ -359,7 +359,7 @@ Library System.Environment.ExecutablePath System.CPUTime.Utils - if !os(ghcjs) + if !arch(js) c-sources: cbits/DarwinUtils.c cbits/PrelIOUtils.c @@ -375,12 +375,13 @@ Library cbits/CastFloatWord.cmm cbits/StackCloningDecoding.cmm - js-sources: - -- "platform" must be linked first because it defines global constants - -- (e.g. h$isNode) - jsbits/platform.js - jsbits/base.js - jsbits/errno.js + if arch(js) + js-sources: + -- "platform" must be linked first because it defines global constants + -- (e.g. h$isNode) + jsbits/platform.js + jsbits/base.js + jsbits/errno.js include-dirs: include includes: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1dc7e8aa7dfac087a02bfb844f8210ebe08554d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1dc7e8aa7dfac087a02bfb844f8210ebe08554d9 You're receiving 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 Sep 20 07:56:53 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 20 Sep 2022 03:56:53 -0400 Subject: [Git][ghc/ghc][wip/js-staging] TH: add support for JS files Message-ID: <6329724555a63_3a3c15513d8409353@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: d2005513 by Sylvain Henry at 2022-09-20T09:59:58+02:00 TH: add support for JS files - - - - - 1 changed file: - libraries/template-haskell/Language/Haskell/TH/Syntax.hs Changes: ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -827,6 +827,7 @@ addForeignSource lang src = do LangObjc -> "m" LangObjcxx -> "mm" LangAsm -> "s" + LangJs -> "js" RawObject -> "a" path <- addTempFile suffix runIO $ writeFile path src View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2005513d0a861a79de298f5e91a0a9e38b28bbb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2005513d0a861a79de298f5e91a0a9e38b28bbb You're receiving 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 Sep 20 08:22:03 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 04:22:03 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Document :unadd GHCi command in user guide Message-ID: <6329782bcd2ca_3a3c15514f0422756@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 7ef7c636 by John Ericson at 2022-09-20T04:21:31-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 1b9f2a41 by John Ericson at 2022-09-20T04:21:31-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. - - - - - a849c930 by Tom Ellis at 2022-09-20T04:21:37-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - 45886dc1 by matoro at 2022-09-20T04:21:40-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. - - - - - 27 changed files: - compiler/GHC/Parser/Lexer.x - configure.ac - docs/users_guide/9.6.1-notes.rst - docs/users_guide/codegens.rst - docs/users_guide/ghci.rst - ghc/GHCi/UI.hs - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Builders/Ar.hs - libraries/base/Data/Functor/Classes.hs - libraries/base/Data/Functor/Compose.hs - libraries/base/Data/Functor/Product.hs - libraries/base/Data/Functor/Sum.hs - libraries/base/GHC/Generics.hs - libraries/base/changelog.md - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Debug.hs - libraries/ghc-prim/GHC/Prim/Exception.hs - libraries/ghc-prim/GHC/Prim/Ext.hs - libraries/ghc-prim/GHC/Prim/Panic.hs - libraries/ghc-prim/GHC/Tuple.hs - libraries/ghc-prim/ghc-prim.cabal - + testsuite/tests/parser/should_compile/T19372consym.hs - + testsuite/tests/parser/should_compile/T19372consym.stderr - testsuite/tests/parser/should_compile/all.T - utils/genprimopcode/Main.hs - utils/haddock Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -496,7 +496,7 @@ $tab { warnTab } @qvarsym { idtoken qvarsym } @qconsym { idtoken qconsym } @varsym { with_op_ws varsym } - @consym { consym } + @consym { with_op_ws consym } } -- For the normal boxed literals we need to be careful @@ -1681,7 +1681,7 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym :: OpWs -> Action -varsym OpWsPrefix = sym $ \span exts s -> +varsym opws at OpWsPrefix = sym $ \span exts s -> let warnExtConflict errtok = do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok) ; return (ITvarsym s) } @@ -1709,35 +1709,48 @@ varsym OpWsPrefix = sym $ \span exts s -> | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Prefix) + do { warnOperatorWhitespace opws span s ; return (ITvarsym s) } -varsym OpWsSuffix = sym $ \span _ s -> +varsym opws at OpWsSuffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc $ PsErrSuffixAT) | s == fsLit "." -> return ITdot | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Suffix) + do { warnOperatorWhitespace opws span s ; return (ITvarsym s) } -varsym OpWsTightInfix = sym $ \span exts s -> +varsym opws at OpWsTightInfix = sym $ \span exts s -> if | s == fsLit "@" -> return ITat | s == fsLit ".", OverloadedRecordDotBit `xtest` exts -> return (ITproj False) | s == fsLit "." -> return ITdot | otherwise -> - do { addPsMessage - (mkSrcSpanPs span) - (PsWarnOperatorWhitespace s (OperatorWhitespaceOccurrence_TightInfix)) - ; return (ITvarsym s) } + do { warnOperatorWhitespace opws span s + ; return (ITvarsym s) } varsym OpWsLooseInfix = sym $ \_ _ s -> if | s == fsLit "." -> return ITdot | otherwise -> return $ ITvarsym s -consym :: Action -consym = sym (\_span _exts s -> return $ ITconsym s) +consym :: OpWs -> Action +consym opws = sym $ \span _exts s -> + do { warnOperatorWhitespace opws span s + ; return (ITconsym s) } + +warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P () +warnOperatorWhitespace opws span s = + whenIsJust (check_unusual_opws opws) $ \opws' -> + addPsMessage + (mkSrcSpanPs span) + (PsWarnOperatorWhitespace s opws') + +-- Check an operator occurrence for unusual whitespace (prefix, suffix, tight infix). +-- This determines if -Woperator-whitespace is triggered. +check_unusual_opws :: OpWs -> Maybe OperatorWhitespaceOccurrence +check_unusual_opws opws = + case opws of + OpWsPrefix -> Just OperatorWhitespaceOccurrence_Prefix + OpWsSuffix -> Just OperatorWhitespaceOccurrence_Suffix + OpWsTightInfix -> Just OperatorWhitespaceOccurrence_TightInfix + OpWsLooseInfix -> Nothing sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len _buf2 = ===================================== configure.ac ===================================== @@ -201,6 +201,7 @@ if test "$WithGhc" != ""; then fi BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) + BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsDashL_STAGE0],[ar supports -L]) BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP]) BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -68,6 +68,9 @@ Compiler - The :extension:`TypeInType` is now marked as deprecated. Its meaning has been included in :extension:`PolyKinds` and :extension:`DataKinds`. +- The :ghc-flag:`-Woperator-whitespace` warning no longer ignores constructor symbols + (operators starting with ``:``). + GHCi ~~~~ ===================================== docs/users_guide/codegens.rst ===================================== @@ -108,10 +108,9 @@ disabling some of the platform-specific tricks that GHC normally uses to make programs go faster. When compiling unregisterised, GHC simply generates a C file which is compiled via gcc. -When GHC is build in unregisterised mode only the LLVM and C code -generators will be available. The native code generator won't be. LLVM -usually offers a substantial performance benefit over the C backend in -unregisterised mode. +When GHC is built in unregisterised mode only the C code generator is +available. Neither the LLVM nor native code generator can be used by an +unregisterised build. Unregisterised compilation can be useful when porting GHC to a new machine, since it reduces the prerequisite tools to ``gcc``, ``as``, and ===================================== docs/users_guide/ghci.rst ===================================== @@ -541,8 +541,9 @@ including entities that are in scope in the current module context. .. warning:: Temporary bindings introduced at the prompt only last until the - next :ghci-cmd:`:load` or :ghci-cmd:`:reload` command, at which time they - will be simply lost. However, they do survive a change of context with + next :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` or + :ghci-cmd:`:unadd` command, at which time they will be simply lost. + However, they do survive a change of context with :ghci-cmd:`:module`: the temporary bindings just move to the new location. .. hint:: @@ -731,7 +732,7 @@ When you type an expression at the prompt, what identifiers and types are in scope? GHCi provides a flexible way to control exactly how the context for an expression is constructed: -- The :ghci-cmd:`:load`, :ghci-cmd:`:add`, and :ghci-cmd:`:reload` commands +- The :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd` commands (:ref:`ghci-load-scope`). - The ``import`` declaration (:ref:`ghci-import-decl`). @@ -751,7 +752,7 @@ contribute to the top-level scope. The effect of ``:load`` on what is in scope ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The :ghci-cmd:`:load`, :ghci-cmd:`:add`, and :ghci-cmd:`:reload` commands +The :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd` commands (:ref:`loading-source-files` and :ref:`ghci-compiled`) affect the top-level scope. Let's start with the simple cases; when you start GHCi the prompt looks like this: @@ -796,7 +797,7 @@ automatically-added imports can be seen with :ghci-cmd:`:show imports`: *ghci> and the automatically-added import is replaced the next time you use -:ghci-cmd:`:load`, :ghci-cmd:`:add`, or :ghci-cmd:`:reload`. It can also be +:ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` or :ghci-cmd:`:unadd`. It can also be removed by :ghci-cmd:`:module` as with normal imports. .. _ghci-import-decl: @@ -895,13 +896,13 @@ can use both to bring a module into scope. However, there is a very important difference. GHCi is concerned with two sets of modules: - The set of modules that are currently *loaded*. This set is modified - by :ghci-cmd:`:load`, :ghci-cmd:`:add` and :ghci-cmd:`:reload`, and can be shown with + by :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd`, and can be shown with :ghci-cmd:`:show modules`. - The set of modules that are currently *in scope* at the prompt. This set is modified by ``import`` and :ghci-cmd:`:module`, and it is also modified - automatically after :ghci-cmd:`:load`, :ghci-cmd:`:add`, and - :ghci-cmd:`:reload`, as described above. The set of modules in scope can be + automatically after :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` + and :ghci-cmd:`:unadd`, as described above. The set of modules in scope can be shown with :ghci-cmd:`:show imports`. You can add a module to the scope (via :ghci-cmd:`:module` or ``import``) only @@ -1173,7 +1174,7 @@ The :ghc-flag:`-interactive-print ⟨name⟩` flag allows to specify any functio of type ``C a => a -> IO ()``, for some constraint ``C``, as the function for printing evaluated expressions. The function can reside in any loaded module or any registered package, but only when it resides in a registered package will -it survive a :ghci-cmd:`:cd`, :ghci-cmd:`:add`, :ghci-cmd:`:load`, +it survive a :ghci-cmd:`:cd`, :ghci-cmd:`:add`, :ghci-cmd:`:unadd`, :ghci-cmd:`:load`, :ghci-cmd:`:reload` or, :ghci-cmd:`:set`. .. ghc-flag:: -interactive-print ⟨name⟩ @@ -2191,7 +2192,7 @@ commonly used commands. Using the ``*`` prefix forces the module to be loaded as byte-code. ⟨module⟩ may be a file path. A "``~``" symbol at the beginning of - ⟨module⟩ will be replaced by the contents of the environment variable + ⟨module⟩ will be replaced by the contents of the environment variable :envvar:`HOME`. .. ghci-cmd:: :all-types @@ -2948,6 +2949,12 @@ commonly used commands. Show the currently active language flags for expressions typed at the prompt (see also :ghci-cmd:`:seti`). +.. ghci-cmd:: :show targets + + Show list of currently loaded modules. + This set of loaded modules can be modified by :ghci-cmd:`:load`, + :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd`. + .. ghci-cmd:: :show; [args|prog|prompt|editor|stop] Displays the specified setting (see :ghci-cmd:`:set`). @@ -3044,6 +3051,11 @@ commonly used commands. The :ghci-cmd:`:type-at` command requires :ghci-cmd:`:set +c` to be set. +.. ghci-cmd:: :unadd; ⟨module⟩ + + Removes ⟨module⟩(s) from the current target set, and perform a reload + (see :ghci-cmd:`:add` above). + .. ghci-cmd:: :undef; ⟨name⟩ Undefines the user-defined command ⟨name⟩ (see :ghci-cmd:`:def` above). ===================================== ghc/GHCi/UI.hs ===================================== @@ -1994,7 +1994,7 @@ instancesCmd s = do printForUser $ vcat $ map ppr res ----------------------------------------------------------------------------- --- :load, :add, :reload +-- :load, :add, :unadd, :reload -- | Sets '-fdefer-type-errors' if 'defer' is true, executes 'load' and unsets -- '-fdefer-type-errors' again if it has not been set before. ===================================== hadrian/cfg/system.config.in ===================================== @@ -39,10 +39,11 @@ python = @PythonCmd@ # Information about builders: #============================ -ar-supports-at-file = @ArSupportsAtFile@ -ar-supports-dash-l = @ArSupportsDashL@ -cc-llvm-backend = @CcLlvmBackend@ -hs-cpp-args = @HaskellCPPArgs@ +ar-supports-at-file = @ArSupportsAtFile@ +ar-supports-dash-l = @ArSupportsDashL@ +system-ar-supports-dash-l = @ArSupportsDashL_STAGE0@ +cc-llvm-backend = @CcLlvmBackend@ +hs-cpp-args = @HaskellCPPArgs@ # Build options: #=============== ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -5,7 +5,8 @@ module Oracles.Flag ( platformSupportsSharedLibs, platformSupportsGhciObjects, targetSupportsSMP, - useLibffiForAdjustors + useLibffiForAdjustors, + arSupportsDashL ) where import Hadrian.Oracles.TextFile @@ -16,6 +17,7 @@ import Oracles.Setting data Flag = ArSupportsAtFile | ArSupportsDashL + | SystemArSupportsDashL | CrossCompiling | CcLlvmBackend | GhcUnregisterised @@ -39,6 +41,7 @@ flag f = do let key = case f of ArSupportsAtFile -> "ar-supports-at-file" ArSupportsDashL -> "ar-supports-dash-l" + SystemArSupportsDashL-> "system-ar-supports-dash-l" CrossCompiling -> "cross-compiling" CcLlvmBackend -> "cc-llvm-backend" GhcUnregisterised -> "ghc-unregisterised" @@ -69,6 +72,10 @@ platformSupportsGhciObjects :: Action Bool platformSupportsGhciObjects = not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand +arSupportsDashL :: Stage -> Action Bool +arSupportsDashL (Stage0 {}) = flag SystemArSupportsDashL +arSupportsDashL _ = flag ArSupportsDashL + platformSupportsSharedLibs :: Action Bool platformSupportsSharedLibs = do windows <- isWinTarget ===================================== hadrian/src/Settings/Builders/Ar.hs ===================================== @@ -6,7 +6,9 @@ import Settings.Builders.Common -- want to place these in a response file. This is handled in -- 'Hadrian.Builder.Ar.runAr'. arBuilderArgs :: Args -arBuilderArgs = mconcat +arBuilderArgs = do + stage <- getStage + mconcat [ builder (Ar Pack) ? mconcat [ -- When building on platforms which don't support object merging -- we must use the -L flag supported by llvm-ar, which ensures that @@ -14,7 +16,7 @@ arBuilderArgs = mconcat -- not added as a single file. This requires that we are using llvm-ar -- -- See Note [Object merging] in GHC.Driver.Pipeline.Execute for details. - ifM ((&&) <$> notStage0 <*> expr (flag ArSupportsDashL)) (arg "qL") (arg "q") + ifM (expr $ arSupportsDashL stage) (arg "qL") (arg "q") , arg =<< getOutput ] , builder (Ar Unpack) ? mconcat ===================================== libraries/base/Data/Functor/Classes.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE QuantifiedConstraints #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Classes @@ -91,8 +94,18 @@ import Text.Show (showListWith) -- | Lifting of the 'Eq' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftEq (==)@ = @(==)@ +-- +-- This class therefore represents the generalization of 'Eq' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Eq1 f where +class (forall a. Eq a => Eq (f a)) => Eq1 f where -- | Lift an equality test through the type constructor. -- -- The function will usually be applied to an equality function, @@ -102,6 +115,10 @@ class Eq1 f where -- -- @since 4.9.0.0 liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool + default liftEq + :: (f ~ f' c, Eq2 f', Eq c) + => (a -> b -> Bool) -> f a -> f b -> Bool + liftEq = liftEq2 (==) -- | Lift the standard @('==')@ function through the type constructor. -- @@ -111,8 +128,18 @@ eq1 = liftEq (==) -- | Lifting of the 'Ord' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftCompare compare@ = 'compare' +-- +-- This class therefore represents the generalization of 'Ord' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class (Eq1 f) => Ord1 f where +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where -- | Lift a 'compare' function through the type constructor. -- -- The function will usually be applied to a comparison function, @@ -122,6 +149,10 @@ class (Eq1 f) => Ord1 f where -- -- @since 4.9.0.0 liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + default liftCompare + :: (f ~ f' c, Ord2 f', Ord c) + => (a -> b -> Ordering) -> f a -> f b -> Ordering + liftCompare = liftCompare2 compare -- | Lift the standard 'compare' function through the type constructor. -- @@ -131,6 +162,22 @@ compare1 = liftCompare compare -- | Lifting of the 'Read' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftReadsPrec readsPrec readList@ = 'readsPrec' +-- +-- @liftReadList readsPrec readList@ = 'readList' +-- +-- @liftReadPrec readPrec readListPrec@ = 'readPrec' +-- +-- @liftReadListPrec readPrec readListPrec@ = 'readListPrec' +-- +-- This class therefore represents the generalization of 'Read' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- Both 'liftReadsPrec' and 'liftReadPrec' exist to match the interface -- provided in the 'Read' type class, but it is recommended to implement -- 'Read1' instances using 'liftReadPrec' as opposed to 'liftReadsPrec', since @@ -145,7 +192,7 @@ compare1 = liftCompare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read1 f where +class (forall a. Read a => Read (f a)) => Read1 f where {-# MINIMAL liftReadsPrec | liftReadPrec #-} -- | 'readsPrec' function for an application of the type constructor @@ -219,14 +266,30 @@ liftReadListPrecDefault rp rl = list (liftReadPrec rp rl) -- | Lifting of the 'Show' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftShowsPrec showsPrec showList@ = 'showsPrec' +-- +-- @liftShowList showsPrec showList@ = 'showList' +-- +-- This class therefore represents the generalization of 'Show' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Show1 f where +class (forall a. Show a => Show (f a)) => Show1 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. -- -- @since 4.9.0.0 liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + default liftShowsPrec + :: (f ~ f' b, Show2 f', Show b) + => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + liftShowsPrec = liftShowsPrec2 showsPrec showList -- | 'showList' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. @@ -248,7 +311,7 @@ showsPrec1 = liftShowsPrec showsPrec showList -- | Lifting of the 'Eq' class to binary type constructors. -- -- @since 4.9.0.0 -class Eq2 f where +class (forall a. Eq a => Eq1 (f a)) => Eq2 f where -- | Lift equality tests through the type constructor. -- -- The function will usually be applied to equality functions, @@ -268,7 +331,7 @@ eq2 = liftEq2 (==) (==) -- | Lifting of the 'Ord' class to binary type constructors. -- -- @since 4.9.0.0 -class (Eq2 f) => Ord2 f where +class (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 f where -- | Lift 'compare' functions through the type constructor. -- -- The function will usually be applied to comparison functions, @@ -302,7 +365,7 @@ compare2 = liftCompare2 compare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read2 f where +class (forall a. Read a => Read1 (f a)) => Read2 f where {-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-} -- | 'readsPrec' function for an application of the type constructor @@ -385,7 +448,7 @@ liftReadListPrec2Default rp1 rl1 rp2 rl2 = list (liftReadPrec2 rp1 rl1 rp2 rl2) -- | Lifting of the 'Show' class to binary type constructors. -- -- @since 4.9.0.0 -class Show2 f where +class (forall a. Show a => Show1 (f a)) => Show2 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument types. -- ===================================== libraries/base/Data/Functor/Compose.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | @@ -32,7 +33,7 @@ import Data.Coerce (coerce) import Data.Data (Data) import Data.Type.Equality (TestEquality(..), (:~:)(..)) import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () infixr 9 `Compose` @@ -47,6 +48,17 @@ newtype Compose f g a = Compose { getCompose :: f (g a) } , Monoid -- ^ @since 4.16.0.0 ) +-- Instances of Prelude classes + +-- | @since 4.18.0.0 +deriving instance Eq (f (g a)) => Eq (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Ord (f (g a)) => Ord (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Read (f (g a)) => Read (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Show (f (g a)) => Show (Compose f g a) + -- Instances of lifted Prelude classes -- | @since 4.9.0.0 @@ -77,27 +89,6 @@ instance (Show1 f, Show1 g) => Show1 (Compose f g) where sp' = liftShowsPrec sp sl sl' = liftShowList sp sl --- Instances of Prelude classes - --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where - (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Compose f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where - showsPrec = showsPrec1 - -- Functor instances -- | @since 4.9.0.0 ===================================== libraries/base/Data/Functor/Product.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Product @@ -28,7 +29,7 @@ import Control.Monad.Zip (MonadZip(mzipWith)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted product of functors. data Product f g a = Pair (f a) (g a) @@ -37,6 +38,15 @@ data Product f g a = Pair (f a) (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Product f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Product f g) where liftEq eq (Pair x1 y1) (Pair x2 y2) = liftEq eq x1 x2 && liftEq eq y1 y2 @@ -59,25 +69,6 @@ instance (Show1 f, Show1 g) => Show1 (Product f g) where liftShowsPrec sp sl d (Pair x y) = showsBinaryWith (liftShowsPrec sp sl) (liftShowsPrec sp sl) "Pair" d x y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) - where (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Product f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Product f g) where fmap f (Pair x y) = Pair (fmap f x) (fmap f y) ===================================== libraries/base/Data/Functor/Sum.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Sum @@ -25,7 +26,7 @@ import Control.Applicative ((<|>)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted sum of functors. data Sum f g a = InL (f a) | InR (g a) @@ -34,6 +35,15 @@ data Sum f g a = InL (f a) | InR (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Sum f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Sum f g) where liftEq eq (InL x1) (InL x2) = liftEq eq x1 x2 @@ -64,22 +74,6 @@ instance (Show1 f, Show1 g) => Show1 (Sum f g) where liftShowsPrec sp sl d (InR y) = showsUnaryWith (liftShowsPrec sp sl) "InR" d y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) where - (==) = eq1 --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) where - compare = compare1 --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Sum f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Sum f g) where fmap f (InL x) = InL (fmap f x) ===================================== libraries/base/GHC/Generics.hs ===================================== @@ -1480,6 +1480,15 @@ type Generically1 :: forall k. (k -> Type) -> (k -> Type) newtype Generically1 f a where Generically1 :: forall {k} f a. f a -> Generically1 @k f a +-- | @since 4.18.0.0 +instance (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a) where + Generically1 x == Generically1 y = from1 x == from1 y + Generically1 x /= Generically1 y = from1 x /= from1 y + +-- | @since 4.18.0.0 +instance (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) where + Generically1 x `compare` Generically1 y = from1 x `compare` from1 y + -- | @since 4.17.0.0 instance (Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) where fmap :: (a -> a') -> (Generically1 f a -> Generically1 f a') ===================================== libraries/base/changelog.md ===================================== @@ -30,6 +30,12 @@ for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) * Update to Unicode 15.0.0. + * Add `Eq` and `Ord` instances for `Generically1`. + * Relax instances for Functor combinators; put superclass on Class1 and Class2 + to make non-breaking. See [CLC + #10](https://github.com/haskell/core-libraries-committee/issues/10) for the + related discussion, as well as [the migration + guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). ## 4.17.0.0 *August 2022* ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -27,6 +27,9 @@ -- Portability : non-portable (GHC extensions) -- -- Basic classes. +-- Do not import this module directly. It is an GHC internal only +-- module. Some of its contents are instead available from @Prelude@ +-- and @GHC.Int at . -- ----------------------------------------------------------------------------- @@ -35,6 +38,8 @@ module GHC.Classes( IP(..), -- * Equality and ordering + -- | Do not import these classes from this module. Import them + -- from @Prelude@ instead. Eq(..), Ord(..), -- ** Monomorphic equality operators @@ -48,6 +53,8 @@ module GHC.Classes( gtWord, geWord, leWord, ltWord, compareWord, compareWord#, -- * Functions over Bool + -- | Do not import these functions from this module. Import them + -- from @Prelude@ instead. (&&), (||), not, -- * Integer arithmetic ===================================== libraries/ghc-prim/GHC/Debug.hs ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples, UnliftedFFITypes #-} +-- | Users should not import this module. It is GHC internal only. + module GHC.Debug ( debugLn, debugErrLn ) where import GHC.Prim ===================================== libraries/ghc-prim/GHC/Prim/Exception.hs ===================================== @@ -6,6 +6,8 @@ {-# LANGUAGE EmptyCase #-} -- | Primitive exceptions. +-- +-- Users should not import this module. It is GHC internal only. module GHC.Prim.Exception ( raiseOverflow , raiseUnderflow ===================================== libraries/ghc-prim/GHC/Prim/Ext.hs ===================================== @@ -18,6 +18,9 @@ -- | Extra C-- routines exposed from the RTS -- +-- Users should not import this module. It is GHC internal only. Use +-- "GHC.Conc" instead. +-- -- Actual primops are emitted by the compiler itself. They are special bits of -- code with backend support. The foreign functions in this module aren't actual -- primops because the compiler doesn't care about them at all: they just are ===================================== libraries/ghc-prim/GHC/Prim/Panic.hs ===================================== @@ -6,6 +6,8 @@ {-# LANGUAGE EmptyCase #-} -- | Primitive panics. +-- +-- Users should not import this module. It is GHC internal only. module GHC.Prim.Panic ( absentSumFieldError , panicError ===================================== libraries/ghc-prim/GHC/Tuple.hs ===================================== @@ -12,6 +12,8 @@ -- -- The tuple data types -- +-- Users should not import this module. It is GHC internal only. +-- ----------------------------------------------------------------------------- module GHC.Tuple where ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -12,6 +12,11 @@ build-type: Custom description: This package contains the primitive types and operations supplied by GHC. + It is an internal package, only for the use of GHC developers. + GHC users should not use it! If you do use it then expect + breaking changes at any time without warning. You should prefer + to import @GHC.Exts@ from the @base@ package instead. + extra-source-files: changelog.md source-repository head ===================================== testsuite/tests/parser/should_compile/T19372consym.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T19372consym where + +import Data.List.NonEmpty + +a_suffix = \x y -> x: y +a_prefix = \x y -> x :y +a_tight_infix = \x y -> x:y +a_loose_infix = \x y -> x : y -- Only this one should be without a warning. + +b_suffix = \x y -> x:| y +b_prefix = \x y -> x :|y +b_tight_infix = \x y -> x:|y +b_loose_infix = \x y -> x :| y -- Only this one should be without a warning. ===================================== testsuite/tests/parser/should_compile/T19372consym.stderr ===================================== @@ -0,0 +1,15 @@ + +T19372consym.hs:12:26: warning: [GHC-40798] [-Woperator-whitespace] + The suffix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. + +T19372consym.hs:13:27: warning: [GHC-40798] [-Woperator-whitespace] + The prefix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. + +T19372consym.hs:14:26: warning: [GHC-40798] [-Woperator-whitespace] + The tight infix use of a ‘:|’ might be repurposed as special syntax + by a future language extension. + Suggested fix: Add whitespace around ‘:|’. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -193,3 +193,4 @@ test('T20718', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-c test('T20718b', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) test('T21589', normal, compile, ['']) +test('T19372consym', normal, compile, ['']) ===================================== utils/genprimopcode/Main.hs ===================================== @@ -446,7 +446,9 @@ In PrimopWrappers we set some crucial GHC options gen_wrappers :: Info -> String gen_wrappers (Info _ entries) - = "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n" + = "-- | Users should not import this module. It is GHC internal only.\n" + ++ "-- Use \"GHC.Exts\" instead.\n" + ++ "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n" -- Dependencies on Prelude must be explicit in libraries/base, but we -- don't need the Prelude here so we add NoImplicitPrelude. ++ "{-# OPTIONS_GHC -Wno-deprecations -O0 -fno-do-eta-reduction #-}\n" ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b5e40b15228fdca5ce7d4e2f2241156d0b085261 +Subproject commit 7e4326f999056fb7b0b955ccadf5eab86b755a0d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f2037ca2808d034cd455d879c186529cb46f5ad...45886dc1297631659ff2b6e1bf935da964f25b5e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f2037ca2808d034cd455d879c186529cb46f5ad...45886dc1297631659ff2b6e1bf935da964f25b5e You're receiving 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 Sep 20 10:20:58 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 20 Sep 2022 06:20:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/extra_edges Message-ID: <6329940aab838_3a3c15514004617e2@gitlab.mail> Matthew Pickering pushed new branch wip/extra_edges at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/extra_edges You're receiving 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 Sep 20 10:28:11 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 20 Sep 2022 06:28:11 -0400 Subject: [Git][ghc/ghc][wip/T21286] 47 commits: Add native delimited continuations to the RTS Message-ID: <632995bbb32e7_3a3c15513ec469619@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - d1504eeb by Simon Peyton Jones at 2022-09-20T10:37:37+01: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 modules * 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: Metrics: compile_time/bytes allocated -------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 -50.1% GOOD ManyConstructors(normal) ghc/alloc 3,928,349,810 +1.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,523,518,560 +1.2% T12545(normal) ghc/alloc 1,633,149,272 +3.1% T13056(optasm) ghc/alloc 349,532,453 -8.7% GOOD T13253(normal) ghc/alloc 343,592,469 -3.3% GOOD T15164(normal) ghc/alloc 1,304,125,024 -3.4% GOOD T16190(normal) ghc/alloc 278,584,392 -1.5% T16577(normal) ghc/alloc 8,050,423,421 -2.8% GOOD T17836(normal) ghc/alloc 829,913,981 +2.3% T18223(normal) ghc/alloc 734,732,288 -33.3% GOOD T18282(normal) ghc/alloc 150,159,957 -2.9% GOOD T18478(normal) ghc/alloc 498,300,837 +1.2% T19695(normal) ghc/alloc 1,444,571,802 -2.5% GOOD T9630(normal) ghc/alloc 1,523,682,706 -32.8% GOOD WWRec(normal) ghc/alloc 624,174,317 -9.6% GOOD hie002(normal) ghc/alloc 9,020,356,301 +1.8% ------------------------------------------------------------------------- geo. mean -1.7% minimum -50.1% maximum +3.1% I diligently investigated all these big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlesslly specialising wrappers LargeRecord, T9630 I also got one runtime improvement: T9203(normal) run/alloc 105,672,160 -10.7% GOOD but I did not investigate. Nofib is a wash: +===============================++===============+===========+ | real/anna || -0.13% | 0.0% | | real/fem || +0.13% | 0.0% | | real/fulsom || -0.16% | 0.0% | | real/gamteb || +0.02% | 0.0% | | real/gg || +0.01% | 0.0% | | real/lift || -1.55% | 0.0% | | real/reptile || -0.11% | 0.0% | | real/scs || -0.08% | 0.0% | | real/smallpt || +0.51% | 0.0% | | real/symalg || -0.01% | 0.0% | | real/veritas || +0.05% | 0.0% | | shootout/binary-trees || +0.00% | 0.0% | | shootout/fannkuch-redux || -0.05% | 0.0% | | shootout/k-nucleotide || -0.01% | 0.0% | | shootout/n-body || -0.06% | 0.0% | | shootout/spectral-norm || +0.01% | 0.0% | | spectral/constraints || +0.20% | 0.0% | | spectral/dom-lt || +1.80% | 0.0% | | spectral/expert || +0.33% | 0.0% | Metric Decrease: LargeRecord T13056 T15164 T16577 T18223 T9630 WWRec T9203 - - - - - 052dcc0e by Simon Peyton Jones at 2022-09-20T10:37:37+01: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. - - - - - 3dfc1773 by Simon Peyton Jones at 2022-09-20T10:37:37+01: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. - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8be40982755fa9872bbf3de0737accdb263c0500...3dfc17739c62a4f553e7a5912e67ee330d386a6a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8be40982755fa9872bbf3de0737accdb263c0500...3dfc17739c62a4f553e7a5912e67ee330d386a6a You're receiving 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 Sep 20 11:36:22 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 20 Sep 2022 07:36:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-filepath-2 Message-ID: <6329a5b6f386_3a3c1551400493223@gitlab.mail> Matthew Pickering pushed new branch wip/bump-filepath-2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-filepath-2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Sep 20 11:38:25 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 20 Sep 2022 07:38:25 -0400 Subject: [Git][ghc/ghc][wip/bump-filepath-2] Update filepath to filepath-1.4.100.0 Message-ID: <6329a631caf94_3a3c15514f04936f9@gitlab.mail> Matthew Pickering pushed to branch wip/bump-filepath-2 at Glasgow Haskell Compiler / GHC Commits: 8dcf331d by Matthew Pickering at 2022-09-20T12:38:13+01: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 - - - - - 4 changed files: - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - libraries/filepath - libraries/template-haskell/template-haskell.cabal.in Changes: ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -81,6 +81,7 @@ stage0Packages = do , directory , process , exceptions + , filepath , ghc , runGhc , ghcBoot @@ -122,7 +123,6 @@ stage1Packages = do , containers , deepseq , exceptions - , filepath , ghc , ghcBignum , ghcCompact ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -213,11 +213,6 @@ packageArgs = do , package hpcBin ? builder (Cabal Flags) ? arg "-build-tool-depends" - --------------------------------- template-haskell ---------------------------------- - - , package templateHaskell - ? mconcat [ builder (Cabal Flags) ? notStage0 ? arg "+vendor-filepath" - , builder Ghc ? notStage0 ? arg ("-i" <> (root pkgPath filepath)) ] ] ghcBignumArgs :: Args ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit 4d7092ad3a8357b18a8fcbeb6fcf38045460eb98 +Subproject commit 872e19fce06ddd40bd0771dbd3cad2c3c6ed5e7d ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -27,14 +27,6 @@ source-repository head location: https://gitlab.haskell.org/ghc/ghc.git subdir: libraries/template-haskell - --- We give the option to vendor filepath to avoid making filepath non-reinstallable.. --- see #21738 for why we are doing this now and what the plan is for the future. -Flag vendor-filepath - Description: Vendor the dependency on filepath - Default: False - Manual: True - Library default-language: Haskell2010 other-extensions: @@ -68,25 +60,16 @@ Library ghc-prim, pretty == 1.1.* - if flag(vendor-filepath) - other-modules: - System.FilePath - System.FilePath.Posix - System.FilePath.Windows - hs-source-dirs: ./vendored-filepath . - default-extensions: - ImplicitPrelude - else - build-depends: filepath - hs-source-dirs: . + other-modules: + System.FilePath + System.FilePath.Posix + System.FilePath.Windows + hs-source-dirs: ./vendored-filepath . + default-extensions: + ImplicitPrelude ghc-options: -Wall -- We need to set the unit ID to template-haskell (without a -- version number) as it's magic. ghc-options: -this-unit-id template-haskell - - -- This should match the default-extensions used in 'ghc.cabal'. This way, - -- GHCi can be used to load it along with the compiler. - Default-Extensions: - NoImplicitPrelude View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8dcf331d5d6ddf1b6418546023d69385ec39e102 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8dcf331d5d6ddf1b6418546023d69385ec39e102 You're receiving 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 Sep 20 12:50:01 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 20 Sep 2022 08:50:01 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Linker: fix creation of directories in output paths Message-ID: <6329b6f994b72_3a3c15515f4515042@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 64cb5056 by Sylvain Henry at 2022-09-20T14:53:02+02:00 Linker: fix creation of directories in output paths - - - - - 4 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/StgToJS/Linker/Utils.hs - compiler/GHC/SysTools.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -130,9 +130,7 @@ runPhase (T_CmmCpp pipe_env hsc_env input_fn) = do [] input_fn output_fn return output_fn -runPhase (T_Js pipe_env hsc_env mb_location js_src) = do - _out_path <- phaseOutputFilenameNew StopLn pipe_env hsc_env Nothing - runJsPhase pipe_env hsc_env mb_location js_src +runPhase (T_Js pipe_env hsc_env _mb_location js_src) = runJsPhase pipe_env hsc_env js_src runPhase (T_Cmm pipe_env hsc_env input_fn) = do let dflags = hsc_dflags hsc_env let next_phase = hscPostBackendPhase HsSrcFile (backend dflags) @@ -348,8 +346,8 @@ runAsPhase with_cpp pipe_env hsc_env location input_fn = do return output_fn -runJsPhase :: PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> IO FilePath -runJsPhase pipe_env hsc_env _location input_fn = do +runJsPhase :: PipeEnv -> HscEnv -> FilePath -> IO FilePath +runJsPhase pipe_env hsc_env input_fn = do let dflags = hsc_dflags hsc_env let logger = hsc_logger hsc_env let tmpfs = hsc_tmpfs hsc_env @@ -358,7 +356,7 @@ runJsPhase pipe_env hsc_env _location input_fn = do let header = "//JavaScript\n" output_fn <- phaseOutputFilenameNew StopLn pipe_env hsc_env Nothing - need_cpp <- jsFileNeedsCpp hsc_env input_fn + need_cpp <- jsFileNeedsCpp input_fn tmp_fn <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js" -- if the input filename is the same as the output, then we've probably -- generated the object ourselves, we leave the file alone @@ -381,8 +379,8 @@ runJsPhase pipe_env hsc_env _location input_fn = do else copyWithHeader header input_fn output_fn return output_fn -jsFileNeedsCpp :: HscEnv -> FilePath -> IO Bool -jsFileNeedsCpp _hsc_env fn = do +jsFileNeedsCpp :: FilePath -> IO Bool +jsFileNeedsCpp fn = do opts <- JSHeader.getOptionsFromJsFile fn pure (JSHeader.CPP `elem` opts) ===================================== compiler/GHC/StgToJS/Linker/Utils.hs ===================================== @@ -35,9 +35,11 @@ import GHC.StgToJS.Types import Prelude import GHC.Platform import Data.List (isPrefixOf) +import System.Directory (createDirectoryIfMissing) writeBinaryFile :: FilePath -> ByteString -> IO () -writeBinaryFile file bs = +writeBinaryFile file bs = do + createDirectoryIfMissing True (takeDirectory file) withBinaryFile file WriteMode $ \h -> mapM_ (B.hPut h) (chunks bs) where -- split the ByteString into a nonempty list of chunks of at most 1GiB ===================================== compiler/GHC/SysTools.hs ===================================== @@ -44,7 +44,8 @@ import GHC.Settings.IO import Control.Monad.Trans.Except (runExceptT) import System.IO import Foreign.Marshal.Alloc (allocaBytes) -import System.Directory (copyFile) +import System.Directory (copyFile,createDirectoryIfMissing) +import System.FilePath {- Note [How GHC finds toolchain utilities] @@ -155,7 +156,8 @@ copyHandle hin hout = do -- | Copy file after printing the given header copyWithHeader :: String -> FilePath -> FilePath -> IO () -copyWithHeader header from to = +copyWithHeader header from to = do + createDirectoryIfMissing True (takeDirectory to) withBinaryFile to WriteMode $ \hout -> do -- write the header string in UTF-8. The header is something like -- {-# LINE "foo.hs" #-} ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -116,6 +116,8 @@ import System.IO.Unsafe ( unsafeInterleaveIO ) import System.IO.Error ( mkIOError, eofErrorType ) import GHC.Real ( Ratio(..) ) import Data.IntMap (IntMap) +import System.Directory +import System.FilePath import qualified Data.IntMap as IntMap #if MIN_VERSION_base(4,15,0) import GHC.ForeignPtr ( unsafeWithForeignPtr ) @@ -277,6 +279,7 @@ seekBinNoExpand (BinMem _ ix_r sz_r _) (BinPtr !p) = do writeBinMem :: BinHandle -> FilePath -> IO () writeBinMem (BinMem _ ix_r _ arr_r) fn = do + createDirectoryIfMissing True (takeDirectory fn) h <- openBinaryFile fn WriteMode arr <- readIORef arr_r ix <- readFastMutInt ix_r View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64cb5056fbb88b10323c96f133924277aeb415d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/64cb5056fbb88b10323c96f133924277aeb415d0 You're receiving 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 Sep 20 14:56:38 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 20 Sep 2022 10:56:38 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Backpack: fix empty stubs Message-ID: <6329d4a693dab_3a3c155140056309d@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 6192e4f3 by Sylvain Henry at 2022-09-20T16:59:36+02:00 Backpack: fix empty stubs - - - - - 4 changed files: - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/StgToJS/Object.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -610,7 +610,7 @@ compileForeign hsc_env lang stub_c = do LangObjc -> viaCPipeline Cobjc LangObjcxx -> viaCPipeline Cobjcxx LangAsm -> \pe hsc_env ml fp -> asPipeline True pe hsc_env ml fp - LangJs -> panic "GHC.Driver.Pipeline:compileForeign unimplemented" + LangJs -> \pe hsc_env ml fp -> Just <$> jsPipeline pe hsc_env ml fp #if __GLASGOW_HASKELL__ < 811 RawObject -> panic "compileForeign: should be unreachable" #endif @@ -634,14 +634,27 @@ compileEmptyStub dflags hsc_env basename location mod_name = do -- and https://github.com/haskell/cabal/issues/2257 let logger = hsc_logger hsc_env let tmpfs = hsc_tmpfs hsc_env - empty_stub <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "c" let home_unit = hsc_home_unit hsc_env - src = text "int" <+> ppr (mkHomeModule home_unit mod_name) <+> text "= 0;" - writeFile empty_stub (showSDoc dflags (pprCode src)) - let pipe_env = (mkPipeEnv NoStop empty_stub Nothing Persistent) { src_basename = basename} - pipeline = viaCPipeline HCc pipe_env hsc_env (Just location) empty_stub - _ <- runPipeline (hsc_hooks hsc_env) pipeline - return () + + case backendCodeOutput (backend dflags) of + JSCodeOutput -> do + empty_stub <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js" + let src = ppr (mkHomeModule home_unit mod_name) <+> text "= 0;" + writeFile empty_stub (showSDoc dflags (pprCode src)) + let pipe_env = (mkPipeEnv NoStop empty_stub Nothing Persistent) { src_basename = basename} + pipeline = Just <$> jsPipeline pipe_env hsc_env (Just location) empty_stub + _ <- runPipeline (hsc_hooks hsc_env) pipeline + pure () + + _ -> do + empty_stub <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "c" + let src = text "int" <+> ppr (mkHomeModule home_unit mod_name) <+> text "= 0;" + writeFile empty_stub (showSDoc dflags (pprCode src)) + let pipe_env = (mkPipeEnv NoStop empty_stub Nothing Persistent) { src_basename = basename} + pipeline = viaCPipeline HCc pipe_env hsc_env (Just location) empty_stub + _ <- runPipeline (hsc_hooks hsc_env) pipeline + pure () + {- Environment Initialisation -} ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -82,6 +82,7 @@ import GHC.Unit.Module.Env import GHC.Driver.Env.KnotVars import GHC.Driver.Config.Finder import GHC.Rename.Names +import GHC.StgToJS.Object (isJsObjectFile) import Language.Haskell.Syntax.Module.Name @@ -352,15 +353,20 @@ runJsPhase pipe_env hsc_env input_fn = do let logger = hsc_logger hsc_env let tmpfs = hsc_tmpfs hsc_env let unit_env = hsc_unit_env hsc_env - -- the header lets the linker recognize processed JavaScript files - let header = "//JavaScript\n" output_fn <- phaseOutputFilenameNew StopLn pipe_env hsc_env Nothing need_cpp <- jsFileNeedsCpp input_fn tmp_fn <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js" + + -- the header lets the linker recognize processed JavaScript files + -- But don't add JavaScript header to object files! + is_js_obj <- isJsObjectFile input_fn + let header + | is_js_obj = "" + | otherwise = "//JavaScript\n" + -- if the input filename is the same as the output, then we've probably -- generated the object ourselves, we leave the file alone - -- FIXME (Luite 2022-08) we should make sure that we never add the JavaScript header to object files when (input_fn /= output_fn) $ do if need_cpp then do ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -51,6 +51,7 @@ module GHC.StgToJS.Object , readObjectUnits , readObjectDeps , isGlobalUnit + , isJsObjectFile , Object(..) , IndexEntry(..) , Deps (..), BlockDeps (..), DepsLocation (..) @@ -220,16 +221,27 @@ putObject bh mod_name deps os = do pure (oiSymbols o,p) pure idx --- | Parse object header -getObjectHeader :: BinHandle -> IO (Either String ModuleName) -getObjectHeader bh = do +-- | Test if the object file is a JS object +isJsObjectFile :: FilePath -> IO Bool +isJsObjectFile fp = + readBinMemN (length magic) fp >>= \case + Nothing -> pure False + Just bh -> getCheckMagic bh + +-- | Parse object magic +getCheckMagic :: BinHandle -> IO Bool +getCheckMagic bh = do let go_magic = \case [] -> pure True (e:es) -> getByte bh >>= \case c | fromIntegral (ord e) == c -> go_magic es | otherwise -> pure False + go_magic magic - is_magic <- go_magic magic +-- | Parse object header +getObjectHeader :: BinHandle -> IO (Either String ModuleName) +getObjectHeader bh = do + is_magic <- getCheckMagic bh case is_magic of False -> pure (Left "invalid magic header") True -> do ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -48,6 +48,7 @@ module GHC.Utils.Binary writeBinMem, readBinMem, + readBinMemN, putAt, getAt, forwardPut, forwardPut_, forwardGet, @@ -287,11 +288,23 @@ writeBinMem (BinMem _ ix_r _ arr_r) fn = do hClose h readBinMem :: FilePath -> IO BinHandle --- Return a BinHandle with a totally undefined State readBinMem filename = do h <- openBinaryFile filename ReadMode filesize' <- hFileSize h let filesize = fromIntegral filesize' + readBinMem_ filesize h + +readBinMemN :: Int -> FilePath -> IO (Maybe BinHandle) +readBinMemN size filename = do + h <- openBinaryFile filename ReadMode + filesize' <- hFileSize h + let filesize = fromIntegral filesize' + if filesize < size + then pure Nothing + else Just <$> readBinMem_ size h + +readBinMem_ :: Int -> Handle -> IO BinHandle +readBinMem_ filesize h = do arr <- mallocForeignPtrBytes filesize count <- unsafeWithForeignPtr arr $ \p -> hGetBuf h p filesize when (count /= filesize) $ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6192e4f38f785c66ff3ab29c7bf7d85d853ce69a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6192e4f38f785c66ff3ab29c7bf7d85d853ce69a You're receiving 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 Sep 20 17:12:09 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 13:12:09 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Add `Eq` and `Ord` instances for `Generically1` Message-ID: <6329f46965b84_3a3c15513ec62136e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 7 changed files: - libraries/base/Data/Functor/Classes.hs - libraries/base/Data/Functor/Compose.hs - libraries/base/Data/Functor/Product.hs - libraries/base/Data/Functor/Sum.hs - libraries/base/GHC/Generics.hs - libraries/base/changelog.md - utils/haddock Changes: ===================================== libraries/base/Data/Functor/Classes.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE QuantifiedConstraints #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Classes @@ -91,8 +94,18 @@ import Text.Show (showListWith) -- | Lifting of the 'Eq' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftEq (==)@ = @(==)@ +-- +-- This class therefore represents the generalization of 'Eq' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Eq1 f where +class (forall a. Eq a => Eq (f a)) => Eq1 f where -- | Lift an equality test through the type constructor. -- -- The function will usually be applied to an equality function, @@ -102,6 +115,10 @@ class Eq1 f where -- -- @since 4.9.0.0 liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool + default liftEq + :: (f ~ f' c, Eq2 f', Eq c) + => (a -> b -> Bool) -> f a -> f b -> Bool + liftEq = liftEq2 (==) -- | Lift the standard @('==')@ function through the type constructor. -- @@ -111,8 +128,18 @@ eq1 = liftEq (==) -- | Lifting of the 'Ord' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftCompare compare@ = 'compare' +-- +-- This class therefore represents the generalization of 'Ord' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class (Eq1 f) => Ord1 f where +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where -- | Lift a 'compare' function through the type constructor. -- -- The function will usually be applied to a comparison function, @@ -122,6 +149,10 @@ class (Eq1 f) => Ord1 f where -- -- @since 4.9.0.0 liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + default liftCompare + :: (f ~ f' c, Ord2 f', Ord c) + => (a -> b -> Ordering) -> f a -> f b -> Ordering + liftCompare = liftCompare2 compare -- | Lift the standard 'compare' function through the type constructor. -- @@ -131,6 +162,22 @@ compare1 = liftCompare compare -- | Lifting of the 'Read' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftReadsPrec readsPrec readList@ = 'readsPrec' +-- +-- @liftReadList readsPrec readList@ = 'readList' +-- +-- @liftReadPrec readPrec readListPrec@ = 'readPrec' +-- +-- @liftReadListPrec readPrec readListPrec@ = 'readListPrec' +-- +-- This class therefore represents the generalization of 'Read' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- Both 'liftReadsPrec' and 'liftReadPrec' exist to match the interface -- provided in the 'Read' type class, but it is recommended to implement -- 'Read1' instances using 'liftReadPrec' as opposed to 'liftReadsPrec', since @@ -145,7 +192,7 @@ compare1 = liftCompare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read1 f where +class (forall a. Read a => Read (f a)) => Read1 f where {-# MINIMAL liftReadsPrec | liftReadPrec #-} -- | 'readsPrec' function for an application of the type constructor @@ -219,14 +266,30 @@ liftReadListPrecDefault rp rl = list (liftReadPrec rp rl) -- | Lifting of the 'Show' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftShowsPrec showsPrec showList@ = 'showsPrec' +-- +-- @liftShowList showsPrec showList@ = 'showList' +-- +-- This class therefore represents the generalization of 'Show' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Show1 f where +class (forall a. Show a => Show (f a)) => Show1 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. -- -- @since 4.9.0.0 liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + default liftShowsPrec + :: (f ~ f' b, Show2 f', Show b) + => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + liftShowsPrec = liftShowsPrec2 showsPrec showList -- | 'showList' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. @@ -248,7 +311,7 @@ showsPrec1 = liftShowsPrec showsPrec showList -- | Lifting of the 'Eq' class to binary type constructors. -- -- @since 4.9.0.0 -class Eq2 f where +class (forall a. Eq a => Eq1 (f a)) => Eq2 f where -- | Lift equality tests through the type constructor. -- -- The function will usually be applied to equality functions, @@ -268,7 +331,7 @@ eq2 = liftEq2 (==) (==) -- | Lifting of the 'Ord' class to binary type constructors. -- -- @since 4.9.0.0 -class (Eq2 f) => Ord2 f where +class (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 f where -- | Lift 'compare' functions through the type constructor. -- -- The function will usually be applied to comparison functions, @@ -302,7 +365,7 @@ compare2 = liftCompare2 compare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read2 f where +class (forall a. Read a => Read1 (f a)) => Read2 f where {-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-} -- | 'readsPrec' function for an application of the type constructor @@ -385,7 +448,7 @@ liftReadListPrec2Default rp1 rl1 rp2 rl2 = list (liftReadPrec2 rp1 rl1 rp2 rl2) -- | Lifting of the 'Show' class to binary type constructors. -- -- @since 4.9.0.0 -class Show2 f where +class (forall a. Show a => Show1 (f a)) => Show2 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument types. -- ===================================== libraries/base/Data/Functor/Compose.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | @@ -32,7 +33,7 @@ import Data.Coerce (coerce) import Data.Data (Data) import Data.Type.Equality (TestEquality(..), (:~:)(..)) import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () infixr 9 `Compose` @@ -47,6 +48,17 @@ newtype Compose f g a = Compose { getCompose :: f (g a) } , Monoid -- ^ @since 4.16.0.0 ) +-- Instances of Prelude classes + +-- | @since 4.18.0.0 +deriving instance Eq (f (g a)) => Eq (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Ord (f (g a)) => Ord (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Read (f (g a)) => Read (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Show (f (g a)) => Show (Compose f g a) + -- Instances of lifted Prelude classes -- | @since 4.9.0.0 @@ -77,27 +89,6 @@ instance (Show1 f, Show1 g) => Show1 (Compose f g) where sp' = liftShowsPrec sp sl sl' = liftShowList sp sl --- Instances of Prelude classes - --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where - (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Compose f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where - showsPrec = showsPrec1 - -- Functor instances -- | @since 4.9.0.0 ===================================== libraries/base/Data/Functor/Product.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Product @@ -28,7 +29,7 @@ import Control.Monad.Zip (MonadZip(mzipWith)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted product of functors. data Product f g a = Pair (f a) (g a) @@ -37,6 +38,15 @@ data Product f g a = Pair (f a) (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Product f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Product f g) where liftEq eq (Pair x1 y1) (Pair x2 y2) = liftEq eq x1 x2 && liftEq eq y1 y2 @@ -59,25 +69,6 @@ instance (Show1 f, Show1 g) => Show1 (Product f g) where liftShowsPrec sp sl d (Pair x y) = showsBinaryWith (liftShowsPrec sp sl) (liftShowsPrec sp sl) "Pair" d x y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) - where (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Product f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Product f g) where fmap f (Pair x y) = Pair (fmap f x) (fmap f y) ===================================== libraries/base/Data/Functor/Sum.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Sum @@ -25,7 +26,7 @@ import Control.Applicative ((<|>)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted sum of functors. data Sum f g a = InL (f a) | InR (g a) @@ -34,6 +35,15 @@ data Sum f g a = InL (f a) | InR (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Sum f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Sum f g) where liftEq eq (InL x1) (InL x2) = liftEq eq x1 x2 @@ -64,22 +74,6 @@ instance (Show1 f, Show1 g) => Show1 (Sum f g) where liftShowsPrec sp sl d (InR y) = showsUnaryWith (liftShowsPrec sp sl) "InR" d y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) where - (==) = eq1 --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) where - compare = compare1 --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Sum f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Sum f g) where fmap f (InL x) = InL (fmap f x) ===================================== libraries/base/GHC/Generics.hs ===================================== @@ -1480,6 +1480,15 @@ type Generically1 :: forall k. (k -> Type) -> (k -> Type) newtype Generically1 f a where Generically1 :: forall {k} f a. f a -> Generically1 @k f a +-- | @since 4.18.0.0 +instance (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a) where + Generically1 x == Generically1 y = from1 x == from1 y + Generically1 x /= Generically1 y = from1 x /= from1 y + +-- | @since 4.18.0.0 +instance (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) where + Generically1 x `compare` Generically1 y = from1 x `compare` from1 y + -- | @since 4.17.0.0 instance (Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) where fmap :: (a -> a') -> (Generically1 f a -> Generically1 f a') ===================================== libraries/base/changelog.md ===================================== @@ -30,6 +30,12 @@ for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) * Update to Unicode 15.0.0. + * Add `Eq` and `Ord` instances for `Generically1`. + * Relax instances for Functor combinators; put superclass on Class1 and Class2 + to make non-breaking. See [CLC + #10](https://github.com/haskell/core-libraries-committee/issues/10) for the + related discussion, as well as [the migration + guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). ## 4.17.0.0 *August 2022* ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b5e40b15228fdca5ce7d4e2f2241156d0b085261 +Subproject commit 7e4326f999056fb7b0b955ccadf5eab86b755a0d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59fe128c37b2befb1ece4bf3f8f5c9082bd213eb...7beb356e944bf3415394fd6aeb7841aca5759020 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59fe128c37b2befb1ece4bf3f8f5c9082bd213eb...7beb356e944bf3415394fd6aeb7841aca5759020 You're receiving 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 Sep 20 17:12:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 13:12:42 -0400 Subject: [Git][ghc/ghc][master] Add notes to ghc-prim Haddocks that users should not import it Message-ID: <6329f48ad2acf_3a3c15515f46255b0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - 8 changed files: - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Debug.hs - libraries/ghc-prim/GHC/Prim/Exception.hs - libraries/ghc-prim/GHC/Prim/Ext.hs - libraries/ghc-prim/GHC/Prim/Panic.hs - libraries/ghc-prim/GHC/Tuple.hs - libraries/ghc-prim/ghc-prim.cabal - utils/genprimopcode/Main.hs Changes: ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -27,6 +27,9 @@ -- Portability : non-portable (GHC extensions) -- -- Basic classes. +-- Do not import this module directly. It is an GHC internal only +-- module. Some of its contents are instead available from @Prelude@ +-- and @GHC.Int at . -- ----------------------------------------------------------------------------- @@ -35,6 +38,8 @@ module GHC.Classes( IP(..), -- * Equality and ordering + -- | Do not import these classes from this module. Import them + -- from @Prelude@ instead. Eq(..), Ord(..), -- ** Monomorphic equality operators @@ -48,6 +53,8 @@ module GHC.Classes( gtWord, geWord, leWord, ltWord, compareWord, compareWord#, -- * Functions over Bool + -- | Do not import these functions from this module. Import them + -- from @Prelude@ instead. (&&), (||), not, -- * Integer arithmetic ===================================== libraries/ghc-prim/GHC/Debug.hs ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples, UnliftedFFITypes #-} +-- | Users should not import this module. It is GHC internal only. + module GHC.Debug ( debugLn, debugErrLn ) where import GHC.Prim ===================================== libraries/ghc-prim/GHC/Prim/Exception.hs ===================================== @@ -6,6 +6,8 @@ {-# LANGUAGE EmptyCase #-} -- | Primitive exceptions. +-- +-- Users should not import this module. It is GHC internal only. module GHC.Prim.Exception ( raiseOverflow , raiseUnderflow ===================================== libraries/ghc-prim/GHC/Prim/Ext.hs ===================================== @@ -18,6 +18,9 @@ -- | Extra C-- routines exposed from the RTS -- +-- Users should not import this module. It is GHC internal only. Use +-- "GHC.Conc" instead. +-- -- Actual primops are emitted by the compiler itself. They are special bits of -- code with backend support. The foreign functions in this module aren't actual -- primops because the compiler doesn't care about them at all: they just are ===================================== libraries/ghc-prim/GHC/Prim/Panic.hs ===================================== @@ -6,6 +6,8 @@ {-# LANGUAGE EmptyCase #-} -- | Primitive panics. +-- +-- Users should not import this module. It is GHC internal only. module GHC.Prim.Panic ( absentSumFieldError , panicError ===================================== libraries/ghc-prim/GHC/Tuple.hs ===================================== @@ -12,6 +12,8 @@ -- -- The tuple data types -- +-- Users should not import this module. It is GHC internal only. +-- ----------------------------------------------------------------------------- module GHC.Tuple where ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -12,6 +12,11 @@ build-type: Custom description: This package contains the primitive types and operations supplied by GHC. + It is an internal package, only for the use of GHC developers. + GHC users should not use it! If you do use it then expect + breaking changes at any time without warning. You should prefer + to import @GHC.Exts@ from the @base@ package instead. + extra-source-files: changelog.md source-repository head ===================================== utils/genprimopcode/Main.hs ===================================== @@ -446,7 +446,9 @@ In PrimopWrappers we set some crucial GHC options gen_wrappers :: Info -> String gen_wrappers (Info _ entries) - = "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n" + = "-- | Users should not import this module. It is GHC internal only.\n" + ++ "-- Use \"GHC.Exts\" instead.\n" + ++ "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n" -- Dependencies on Prelude must be explicit in libraries/base, but we -- don't need the Prelude here so we add NoImplicitPrelude. ++ "{-# OPTIONS_GHC -Wno-deprecations -O0 -fno-do-eta-reduction #-}\n" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a8c6b5ede0345bf0bb1b34d93fe7dc759b99bfd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a8c6b5ede0345bf0bb1b34d93fe7dc759b99bfd You're receiving 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 Sep 20 17:13:19 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 13:13:19 -0400 Subject: [Git][ghc/ghc][master] docs: clarify that LLVM codegen is not available in unregisterised mode Message-ID: <6329f4afdc98f_3a3c1551400629118@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - docs/users_guide/codegens.rst Changes: ===================================== docs/users_guide/codegens.rst ===================================== @@ -108,10 +108,9 @@ disabling some of the platform-specific tricks that GHC normally uses to make programs go faster. When compiling unregisterised, GHC simply generates a C file which is compiled via gcc. -When GHC is build in unregisterised mode only the LLVM and C code -generators will be available. The native code generator won't be. LLVM -usually offers a substantial performance benefit over the C backend in -unregisterised mode. +When GHC is built in unregisterised mode only the C code generator is +available. Neither the LLVM nor native code generator can be used by an +unregisterised build. Unregisterised compilation can be useful when porting GHC to a new machine, since it reduces the prerequisite tools to ``gcc``, ``as``, and View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee9d0f5c5680ae033d701dfbd220c7938c7a2d51 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee9d0f5c5680ae033d701dfbd220c7938c7a2d51 You're receiving 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 Sep 20 18:44:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 14:44:39 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Add `Eq` and `Ord` instances for `Generically1` Message-ID: <632a0a173847c_3a3c15513c464439b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 3a1a7fa1 by Nicolas Trangez at 2022-09-20T14:44:20-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - fb6d2998 by Matthew Pickering at 2022-09-20T14:44:20-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 - - - - - 18 changed files: - docs/users_guide/codegens.rst - hadrian/src/Rules/Dependencies.hs - libraries/base/Data/Functor/Classes.hs - libraries/base/Data/Functor/Compose.hs - libraries/base/Data/Functor/Product.hs - libraries/base/Data/Functor/Sum.hs - libraries/base/GHC/Generics.hs - libraries/base/changelog.md - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Debug.hs - libraries/ghc-prim/GHC/Prim/Exception.hs - libraries/ghc-prim/GHC/Prim/Ext.hs - libraries/ghc-prim/GHC/Prim/Panic.hs - libraries/ghc-prim/GHC/Tuple.hs - libraries/ghc-prim/ghc-prim.cabal - rts/rts.cabal.in - utils/genprimopcode/Main.hs - utils/haddock Changes: ===================================== docs/users_guide/codegens.rst ===================================== @@ -108,10 +108,9 @@ disabling some of the platform-specific tricks that GHC normally uses to make programs go faster. When compiling unregisterised, GHC simply generates a C file which is compiled via gcc. -When GHC is build in unregisterised mode only the LLVM and C code -generators will be available. The native code generator won't be. LLVM -usually offers a substantial performance benefit over the C backend in -unregisterised mode. +When GHC is built in unregisterised mode only the C code generator is +available. Neither the LLVM nor native code generator can be used by an +unregisterised build. Unregisterised compilation can be useful when porting GHC to a new machine, since it reduces the prerequisite tools to ``gcc``, ``as``, and ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -14,6 +14,7 @@ import Target import Utilities import Packages import qualified Data.Map as M +import qualified Data.Set as S import qualified Text.Parsec as Parsec @@ -22,7 +23,7 @@ import qualified Text.Parsec as Parsec -- until it does we need to add this dependency ourselves. extra_dependencies :: M.Map Package (Stage -> Action [(FilePath, FilePath)]) extra_dependencies = - M.fromList [(containers, fmap sequence (sequence + M.fromList [(containers, fmap (fmap concat . sequence) (sequence [dep (containers, "Data.IntSet.Internal") th_internal ,dep (containers, "Data.Set.Internal") th_internal ,dep (containers, "Data.Sequence.Internal") th_internal @@ -32,9 +33,12 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = (,) <$> path s p1 m1 <*> path s p2 m2 - path stage p m = - let context = Context stage p vanilla Inplace + dep (p1, m1) (p2, m2) s = do + let context = Context s p1 (error "extra_dependencies: way not set") (error "extra_dependencies: iplace not set") + ways <- interpretInContext context getLibraryWays + mapM (\way -> (,) <$> path s way p1 m1 <*> path s way p2 m2) (S.toList ways) + path stage way p m = + let context = Context stage p way Inplace in objectPath context . moduleSource $ m formatExtra :: (FilePath, FilePath) -> String ===================================== libraries/base/Data/Functor/Classes.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE QuantifiedConstraints #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Classes @@ -91,8 +94,18 @@ import Text.Show (showListWith) -- | Lifting of the 'Eq' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftEq (==)@ = @(==)@ +-- +-- This class therefore represents the generalization of 'Eq' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Eq1 f where +class (forall a. Eq a => Eq (f a)) => Eq1 f where -- | Lift an equality test through the type constructor. -- -- The function will usually be applied to an equality function, @@ -102,6 +115,10 @@ class Eq1 f where -- -- @since 4.9.0.0 liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool + default liftEq + :: (f ~ f' c, Eq2 f', Eq c) + => (a -> b -> Bool) -> f a -> f b -> Bool + liftEq = liftEq2 (==) -- | Lift the standard @('==')@ function through the type constructor. -- @@ -111,8 +128,18 @@ eq1 = liftEq (==) -- | Lifting of the 'Ord' class to unary type constructors. -- +-- Any instance should be subject to the following law that canonicity +-- is preserved: +-- +-- @liftCompare compare@ = 'compare' +-- +-- This class therefore represents the generalization of 'Ord' by +-- decomposing its main method into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class (Eq1 f) => Ord1 f where +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where -- | Lift a 'compare' function through the type constructor. -- -- The function will usually be applied to a comparison function, @@ -122,6 +149,10 @@ class (Eq1 f) => Ord1 f where -- -- @since 4.9.0.0 liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + default liftCompare + :: (f ~ f' c, Ord2 f', Ord c) + => (a -> b -> Ordering) -> f a -> f b -> Ordering + liftCompare = liftCompare2 compare -- | Lift the standard 'compare' function through the type constructor. -- @@ -131,6 +162,22 @@ compare1 = liftCompare compare -- | Lifting of the 'Read' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftReadsPrec readsPrec readList@ = 'readsPrec' +-- +-- @liftReadList readsPrec readList@ = 'readList' +-- +-- @liftReadPrec readPrec readListPrec@ = 'readPrec' +-- +-- @liftReadListPrec readPrec readListPrec@ = 'readListPrec' +-- +-- This class therefore represents the generalization of 'Read' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- Both 'liftReadsPrec' and 'liftReadPrec' exist to match the interface -- provided in the 'Read' type class, but it is recommended to implement -- 'Read1' instances using 'liftReadPrec' as opposed to 'liftReadsPrec', since @@ -145,7 +192,7 @@ compare1 = liftCompare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read1 f where +class (forall a. Read a => Read (f a)) => Read1 f where {-# MINIMAL liftReadsPrec | liftReadPrec #-} -- | 'readsPrec' function for an application of the type constructor @@ -219,14 +266,30 @@ liftReadListPrecDefault rp rl = list (liftReadPrec rp rl) -- | Lifting of the 'Show' class to unary type constructors. -- +-- Any instance should be subject to the following laws that canonicity +-- is preserved: +-- +-- @liftShowsPrec showsPrec showList@ = 'showsPrec' +-- +-- @liftShowList showsPrec showList@ = 'showList' +-- +-- This class therefore represents the generalization of 'Show' by +-- decomposing it's methods into a canonical lifting on a canonical +-- inner method, so that the lifting can be reused for other arguments +-- than the canonical one. +-- -- @since 4.9.0.0 -class Show1 f where +class (forall a. Show a => Show (f a)) => Show1 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. -- -- @since 4.9.0.0 liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + default liftShowsPrec + :: (f ~ f' b, Show2 f', Show b) + => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS + liftShowsPrec = liftShowsPrec2 showsPrec showList -- | 'showList' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument type. @@ -248,7 +311,7 @@ showsPrec1 = liftShowsPrec showsPrec showList -- | Lifting of the 'Eq' class to binary type constructors. -- -- @since 4.9.0.0 -class Eq2 f where +class (forall a. Eq a => Eq1 (f a)) => Eq2 f where -- | Lift equality tests through the type constructor. -- -- The function will usually be applied to equality functions, @@ -268,7 +331,7 @@ eq2 = liftEq2 (==) (==) -- | Lifting of the 'Ord' class to binary type constructors. -- -- @since 4.9.0.0 -class (Eq2 f) => Ord2 f where +class (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 f where -- | Lift 'compare' functions through the type constructor. -- -- The function will usually be applied to comparison functions, @@ -302,7 +365,7 @@ compare2 = liftCompare2 compare compare -- For more information, refer to the documentation for the 'Read' class. -- -- @since 4.9.0.0 -class Read2 f where +class (forall a. Read a => Read1 (f a)) => Read2 f where {-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-} -- | 'readsPrec' function for an application of the type constructor @@ -385,7 +448,7 @@ liftReadListPrec2Default rp1 rl1 rp2 rl2 = list (liftReadPrec2 rp1 rl1 rp2 rl2) -- | Lifting of the 'Show' class to binary type constructors. -- -- @since 4.9.0.0 -class Show2 f where +class (forall a. Show a => Show1 (f a)) => Show2 f where -- | 'showsPrec' function for an application of the type constructor -- based on 'showsPrec' and 'showList' functions for the argument types. -- ===================================== libraries/base/Data/Functor/Compose.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | @@ -32,7 +33,7 @@ import Data.Coerce (coerce) import Data.Data (Data) import Data.Type.Equality (TestEquality(..), (:~:)(..)) import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () infixr 9 `Compose` @@ -47,6 +48,17 @@ newtype Compose f g a = Compose { getCompose :: f (g a) } , Monoid -- ^ @since 4.16.0.0 ) +-- Instances of Prelude classes + +-- | @since 4.18.0.0 +deriving instance Eq (f (g a)) => Eq (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Ord (f (g a)) => Ord (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Read (f (g a)) => Read (Compose f g a) +-- | @since 4.18.0.0 +deriving instance Show (f (g a)) => Show (Compose f g a) + -- Instances of lifted Prelude classes -- | @since 4.9.0.0 @@ -77,27 +89,6 @@ instance (Show1 f, Show1 g) => Show1 (Compose f g) where sp' = liftShowsPrec sp sl sl' = liftShowList sp sl --- Instances of Prelude classes - --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where - (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Compose f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where - showsPrec = showsPrec1 - -- Functor instances -- | @since 4.9.0.0 ===================================== libraries/base/Data/Functor/Product.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Product @@ -28,7 +29,7 @@ import Control.Monad.Zip (MonadZip(mzipWith)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted product of functors. data Product f g a = Pair (f a) (g a) @@ -37,6 +38,15 @@ data Product f g a = Pair (f a) (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Product f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Product f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Product f g) where liftEq eq (Pair x1 y1) (Pair x2 y2) = liftEq eq x1 x2 && liftEq eq y1 y2 @@ -59,25 +69,6 @@ instance (Show1 f, Show1 g) => Show1 (Product f g) where liftShowsPrec sp sl d (Pair x y) = showsBinaryWith (liftShowsPrec sp sl) (liftShowsPrec sp sl) "Pair" d x y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) - where (==) = eq1 - --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) where - compare = compare1 - --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Product f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault - --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Product f g) where fmap f (Pair x y) = Pair (fmap f x) (fmap f y) ===================================== libraries/base/Data/Functor/Sum.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Sum @@ -25,7 +26,7 @@ import Control.Applicative ((<|>)) import Data.Data (Data) import Data.Functor.Classes import GHC.Generics (Generic, Generic1) -import Text.Read (Read(..), readListDefault, readListPrecDefault) +import Text.Read () -- | Lifted sum of functors. data Sum f g a = InL (f a) | InR (g a) @@ -34,6 +35,15 @@ data Sum f g a = InL (f a) | InR (g a) , Generic1 -- ^ @since 4.9.0.0 ) +-- | @since 4.18.0.0 +deriving instance (Eq (f a), Eq (g a)) => Eq (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Ord (f a), Ord (g a)) => Ord (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Read (f a), Read (g a)) => Read (Sum f g a) +-- | @since 4.18.0.0 +deriving instance (Show (f a), Show (g a)) => Show (Sum f g a) + -- | @since 4.9.0.0 instance (Eq1 f, Eq1 g) => Eq1 (Sum f g) where liftEq eq (InL x1) (InL x2) = liftEq eq x1 x2 @@ -64,22 +74,6 @@ instance (Show1 f, Show1 g) => Show1 (Sum f g) where liftShowsPrec sp sl d (InR y) = showsUnaryWith (liftShowsPrec sp sl) "InR" d y --- | @since 4.9.0.0 -instance (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) where - (==) = eq1 --- | @since 4.9.0.0 -instance (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) where - compare = compare1 --- | @since 4.9.0.0 -instance (Read1 f, Read1 g, Read a) => Read (Sum f g a) where - readPrec = readPrec1 - - readListPrec = readListPrecDefault - readList = readListDefault --- | @since 4.9.0.0 -instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where - showsPrec = showsPrec1 - -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Sum f g) where fmap f (InL x) = InL (fmap f x) ===================================== libraries/base/GHC/Generics.hs ===================================== @@ -1480,6 +1480,15 @@ type Generically1 :: forall k. (k -> Type) -> (k -> Type) newtype Generically1 f a where Generically1 :: forall {k} f a. f a -> Generically1 @k f a +-- | @since 4.18.0.0 +instance (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a) where + Generically1 x == Generically1 y = from1 x == from1 y + Generically1 x /= Generically1 y = from1 x /= from1 y + +-- | @since 4.18.0.0 +instance (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) where + Generically1 x `compare` Generically1 y = from1 x `compare` from1 y + -- | @since 4.17.0.0 instance (Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) where fmap :: (a -> a') -> (Generically1 f a -> Generically1 f a') ===================================== libraries/base/changelog.md ===================================== @@ -30,6 +30,12 @@ for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md) * Update to Unicode 15.0.0. + * Add `Eq` and `Ord` instances for `Generically1`. + * Relax instances for Functor combinators; put superclass on Class1 and Class2 + to make non-breaking. See [CLC + #10](https://github.com/haskell/core-libraries-committee/issues/10) for the + related discussion, as well as [the migration + guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). ## 4.17.0.0 *August 2022* ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -27,6 +27,9 @@ -- Portability : non-portable (GHC extensions) -- -- Basic classes. +-- Do not import this module directly. It is an GHC internal only +-- module. Some of its contents are instead available from @Prelude@ +-- and @GHC.Int at . -- ----------------------------------------------------------------------------- @@ -35,6 +38,8 @@ module GHC.Classes( IP(..), -- * Equality and ordering + -- | Do not import these classes from this module. Import them + -- from @Prelude@ instead. Eq(..), Ord(..), -- ** Monomorphic equality operators @@ -48,6 +53,8 @@ module GHC.Classes( gtWord, geWord, leWord, ltWord, compareWord, compareWord#, -- * Functions over Bool + -- | Do not import these functions from this module. Import them + -- from @Prelude@ instead. (&&), (||), not, -- * Integer arithmetic ===================================== libraries/ghc-prim/GHC/Debug.hs ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples, UnliftedFFITypes #-} +-- | Users should not import this module. It is GHC internal only. + module GHC.Debug ( debugLn, debugErrLn ) where import GHC.Prim ===================================== libraries/ghc-prim/GHC/Prim/Exception.hs ===================================== @@ -6,6 +6,8 @@ {-# LANGUAGE EmptyCase #-} -- | Primitive exceptions. +-- +-- Users should not import this module. It is GHC internal only. module GHC.Prim.Exception ( raiseOverflow , raiseUnderflow ===================================== libraries/ghc-prim/GHC/Prim/Ext.hs ===================================== @@ -18,6 +18,9 @@ -- | Extra C-- routines exposed from the RTS -- +-- Users should not import this module. It is GHC internal only. Use +-- "GHC.Conc" instead. +-- -- Actual primops are emitted by the compiler itself. They are special bits of -- code with backend support. The foreign functions in this module aren't actual -- primops because the compiler doesn't care about them at all: they just are ===================================== libraries/ghc-prim/GHC/Prim/Panic.hs ===================================== @@ -6,6 +6,8 @@ {-# LANGUAGE EmptyCase #-} -- | Primitive panics. +-- +-- Users should not import this module. It is GHC internal only. module GHC.Prim.Panic ( absentSumFieldError , panicError ===================================== libraries/ghc-prim/GHC/Tuple.hs ===================================== @@ -12,6 +12,8 @@ -- -- The tuple data types -- +-- Users should not import this module. It is GHC internal only. +-- ----------------------------------------------------------------------------- module GHC.Tuple where ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -12,6 +12,11 @@ build-type: Custom description: This package contains the primitive types and operations supplied by GHC. + It is an internal package, only for the use of GHC developers. + GHC users should not use it! If you do use it then expect + breaking changes at any time without warning. You should prefer + to import @GHC.Exts@ from the @base@ package instead. + extra-source-files: changelog.md source-repository head ===================================== rts/rts.cabal.in ===================================== @@ -419,9 +419,6 @@ library -- This symbol is useful in gdb, but not referred to anywhere, -- so we need to force it to be included in the binary. ld-options: "-Wl,-u,findPtr" - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - "-Wl,-u,findPtr" if os(windows) if flag(leading-underscore) ===================================== utils/genprimopcode/Main.hs ===================================== @@ -446,7 +446,9 @@ In PrimopWrappers we set some crucial GHC options gen_wrappers :: Info -> String gen_wrappers (Info _ entries) - = "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n" + = "-- | Users should not import this module. It is GHC internal only.\n" + ++ "-- Use \"GHC.Exts\" instead.\n" + ++ "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n" -- Dependencies on Prelude must be explicit in libraries/base, but we -- don't need the Prelude here so we add NoImplicitPrelude. ++ "{-# OPTIONS_GHC -Wno-deprecations -O0 -fno-do-eta-reduction #-}\n" ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit b5e40b15228fdca5ce7d4e2f2241156d0b085261 +Subproject commit 7e4326f999056fb7b0b955ccadf5eab86b755a0d View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/45886dc1297631659ff2b6e1bf935da964f25b5e...fb6d299865968d0a8f559668d3c809ce887ed9a7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/45886dc1297631659ff2b6e1bf935da964f25b5e...fb6d299865968d0a8f559668d3c809ce887ed9a7 You're receiving 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 Sep 21 00:14:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 20:14:43 -0400 Subject: [Git][ghc/ghc][master] rts: remove copy-paste error from `cabal.rts.in` Message-ID: <632a5773d0bec_3a3c15518246985f5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 1 changed file: - rts/rts.cabal.in Changes: ===================================== rts/rts.cabal.in ===================================== @@ -419,9 +419,6 @@ library -- This symbol is useful in gdb, but not referred to anywhere, -- so we need to force it to be included in the binary. ld-options: "-Wl,-u,findPtr" - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - "-Wl,-u,findPtr" if os(windows) if flag(leading-underscore) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/854224ed32422f7a315a2480c129691ad40ca504 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/854224ed32422f7a315a2480c129691ad40ca504 You're receiving 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 Sep 21 00:15:21 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 20 Sep 2022 20:15:21 -0400 Subject: [Git][ghc/ghc][master] hadrian: Add extra_dependencies edges for all different ways Message-ID: <632a5799fa24_3a3c15513c47040ad@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 1 changed file: - hadrian/src/Rules/Dependencies.hs Changes: ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -14,6 +14,7 @@ import Target import Utilities import Packages import qualified Data.Map as M +import qualified Data.Set as S import qualified Text.Parsec as Parsec @@ -22,7 +23,7 @@ import qualified Text.Parsec as Parsec -- until it does we need to add this dependency ourselves. extra_dependencies :: M.Map Package (Stage -> Action [(FilePath, FilePath)]) extra_dependencies = - M.fromList [(containers, fmap sequence (sequence + M.fromList [(containers, fmap (fmap concat . sequence) (sequence [dep (containers, "Data.IntSet.Internal") th_internal ,dep (containers, "Data.Set.Internal") th_internal ,dep (containers, "Data.Sequence.Internal") th_internal @@ -32,9 +33,12 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = (,) <$> path s p1 m1 <*> path s p2 m2 - path stage p m = - let context = Context stage p vanilla Inplace + dep (p1, m1) (p2, m2) s = do + let context = Context s p1 (error "extra_dependencies: way not set") (error "extra_dependencies: iplace not set") + ways <- interpretInContext context getLibraryWays + mapM (\way -> (,) <$> path s way p1 m1 <*> path s way p2 m2) (S.toList ways) + path stage way p m = + let context = Context stage p way Inplace in objectPath context . moduleSource $ m formatExtra :: (FilePath, FilePath) -> String View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c8ae3add11969b5128f34d02a5582c1f007cce5c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c8ae3add11969b5128f34d02a5582c1f007cce5c You're receiving 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 Sep 21 09:28:51 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 05:28:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/opt-core-lint Message-ID: <632ad953b207a_3a3c15515f4760538@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/opt-core-lint You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Sep 21 09:31:23 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 05:31:23 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <632ad9eb84463_3a3c15518247645e@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 23a93bb5 by Andreas Klebinger at 2022-09-21T11:30:13+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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: Return a unboxed maybe: ~1% - - - - - 7 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} {- (c) The University of Glasgow 2006 @@ -163,6 +164,7 @@ import Control.Monad (foldM, zipWithM) import Data.Function ( on ) import Data.Char( isDigit ) import qualified Data.Monoid as Monoid +import GHC.Data.Unboxed (pattern JustUB) {- %************************************************************************ @@ -781,7 +783,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | JustUB (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE PatternSynonyms #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} -- (c) The University of Glasgow 2006 @@ -62,6 +63,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Data.Bag +import GHC.Data.Unboxed {- ************************************************************************ @@ -1370,7 +1372,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | JustUB (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,10 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} +{-# OPTIONS_GHC -ddump-stg-final -ddump-simpl -ddump-to-file #-} {- (c) The University of Glasgow 2006 @@ -95,6 +99,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +269,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1867,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | JustUB (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1916,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,45 +1935,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + -- ; _ <- foldlM (go_app in_scope) kfn arg_tys + -- ; return () + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc + -- We pass kfn arg_tys explicitly here to avoid this binder becoming a thunk + -- that get's allocated in the hot code path. + -- See Note [Avoiding compiler perf traps when constructing error messages.] + fail_msg kfn arg_tys msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) , nest 2 (text "Function kind =" <+> ppr kfn) , nest 2 (text "Arg types =" <+> ppr arg_tys) , extra ] - go_app in_scope kfn ta + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (fail_msg kfn arg_tys msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } + -- ; return kfb } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (fail_msg kfn arg_tys msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + = failWithL (fail_msg kfn arg_tys msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) {- ********************************************************************* * * @@ -2672,14 +2727,42 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> (LResult a)) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w <- (# m, w #) + where LResult m w = (# m , w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2887,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2940,10 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + -- (Just _, errs) -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2972,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2988,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3028,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3044,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3064,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -2,6 +2,8 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE DeriveDataTypeable #-} +{-# OPTIONS_GHC -ddump-stg-final -ddump-simpl -ddump-to-file #-} +{-# LANGUAGE UnboxedTuples #-} {- (c) The University of Glasgow 2006 @@ -177,6 +179,7 @@ import GHC.Unit.Module import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import qualified Data.Data as Data +import GHC.Data.Unboxed {- ----------------------------------------------- @@ -2524,7 +2527,7 @@ isConcreteTyConFlavour = \case expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], + -> MaybeUB ([(TyVar,tyco)], Type, [tyco]) -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then JustUB ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> JustUB (tvs `zip` tys, rhs, drop arity tys) + EQ -> JustUB (tvs `zip` tys, rhs, []) + LT -> NothingUB | otherwise - = Nothing + = NothingUB ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,8 +4,10 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} +{-# OPTIONS_GHC -ddump-stg-final -ddump-simpl -ddump-to-file #-} -- | Main functions for manipulating types and type-related things module GHC.Core.Type ( @@ -296,6 +298,8 @@ import GHC.Types.Unique ( nonDetCmpUnique ) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) +import GHC.Base (reallyUnsafePtrEquality#) +import GHC.Data.Unboxed -- import GHC.Utils.Trace -- $type_classification @@ -555,7 +559,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | JustUB (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2799,11 +2803,14 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,92 @@ +-- Strict counterparts to common data structures, +-- e.g. tuples, lists, maybes, etc. +-- +-- Import this module qualified as Strict. + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE MagicHash #-} + +module GHC.Data.Unboxed ( + -- Maybe(Nothing, Just), + -- fromMaybe, + -- Pair(And), + + -- -- Not used at the moment: + -- -- + -- -- Either(Left, Right), + -- -- List(Nil, Cons), + pattern JustUB, pattern NothingUB, + + MaybeUB, fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +type MaybeUB a = (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x <- (# | x #) where + JustUB x = (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB <- (# (# #) | #) where + NothingUB = (# (##) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +-- data Maybe a = Nothing | Just !a +-- deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data) + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def + +-- altMaybe :: Maybe a -> Maybe a -> Maybe a +-- altMaybe Nothing r = r +-- altMaybe l _ = l + +-- instance Semigroup a => Semigroup (Maybe a) where +-- Nothing <> b = b +-- a <> Nothing = a +-- Just a <> Just b = Just (a <> b) + +-- instance Semigroup a => Monoid (Maybe a) where +-- mempty = Nothing + +-- instance Applicative Maybe where +-- pure = Just +-- (<*>) = apMaybe + +-- instance Alternative Maybe where +-- empty = Nothing +-- (<|>) = altMaybe + +-- data Pair a b = !a `And` !b +-- deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data) + +-- The definitions below are commented out because they are +-- not used anywhere in the compiler, but are useful to showcase +-- the intent behind this module (i.e. how it may evolve). +-- +-- data Either a b = Left !a | Right !b +-- deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data) +-- +-- data List a = Nil | !a `Cons` !(List a) +-- deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data) ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23a93bb5957a615f0c7504474710f48d59acde00 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23a93bb5957a615f0c7504474710f48d59acde00 You're receiving 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 Sep 21 09:48:19 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 21 Sep 2022 05:48:19 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: rts: remove copy-paste error from `cabal.rts.in` Message-ID: <632adde32c7ee_3a3c15513c476874c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - fe5ab480 by sheaf at 2022-09-21T05:48:00-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 - - - - - 6 changed files: - compiler/GHC/Stg/InferTags/Rewrite.hs - docs/users_guide/ghci.rst - hadrian/src/Rules/Dependencies.hs - rts/rts.cabal.in - + testsuite/tests/simplStg/should_compile/T22212.hs - testsuite/tests/simplStg/should_compile/all.T Changes: ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -21,15 +21,19 @@ where import GHC.Prelude import GHC.Builtin.PrimOps ( PrimOp(..) ) +import GHC.Types.Basic ( CbvMark (..), isMarkedCbv + , TopLevelFlag(..), isTopLevel + , Levity(..) ) import GHC.Types.Id import GHC.Types.Name import GHC.Types.Unique.Supply import GHC.Types.Unique.FM import GHC.Types.RepType -import GHC.Unit.Types (Module) +import GHC.Types.Var.Set +import GHC.Unit.Types ( Module ) import GHC.Core.DataCon -import GHC.Core (AltCon(..) ) +import GHC.Core ( AltCon(..) ) import GHC.Core.Type import GHC.StgToCmm.Types @@ -47,8 +51,7 @@ import GHC.Utils.Misc import GHC.Stg.InferTags.Types import Control.Monad -import GHC.Types.Basic (CbvMark (NotMarkedCbv, MarkedCbv), isMarkedCbv, TopLevelFlag(..), isTopLevel) -import GHC.Types.Var.Set + -- import GHC.Utils.Trace -- import GHC.Driver.Ppr @@ -217,7 +220,9 @@ isTagged v = do this_mod <- getMod case nameIsLocalOrFrom this_mod (idName v) of True - | isUnliftedType (idType v) + | Just Unlifted <- typeLevity_maybe (idType v) + -- NB: v might be the Id of a representation-polymorphic join point, + -- so we shouldn't use isUnliftedType here. See T22212. -> return True | otherwise -> do -- Local binding !s <- getMap ===================================== docs/users_guide/ghci.rst ===================================== @@ -3295,13 +3295,12 @@ reads and executes commands from the following files, in this order, if they exist: 1. :file:`{ghcappdata}/ghci.conf`, where ⟨ghcappdata⟩ depends on - your system, but is usually something like :file:`$HOME/.ghc` on - Unix or :file:`C:/Documents and Settings/user/Application - Data/ghc` on Windows. + your system, but is usually something like :file:`$HOME/.ghc` or + :file:`$XDG_CONFIG_HOME/ghc` on Unix or + :file:`C:\\Users\\{username}\\AppData\\Roaming\\ghc` on + Windows. -2. :file:`$XDG_CONFIG_HOME/.ghci` - -3. :file:`./.ghci` +2. :file:`./.ghci` The :file:`ghci.conf` file is most useful for turning on favourite options (e.g. ``:set +s``), and defining useful macros. ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -14,6 +14,7 @@ import Target import Utilities import Packages import qualified Data.Map as M +import qualified Data.Set as S import qualified Text.Parsec as Parsec @@ -22,7 +23,7 @@ import qualified Text.Parsec as Parsec -- until it does we need to add this dependency ourselves. extra_dependencies :: M.Map Package (Stage -> Action [(FilePath, FilePath)]) extra_dependencies = - M.fromList [(containers, fmap sequence (sequence + M.fromList [(containers, fmap (fmap concat . sequence) (sequence [dep (containers, "Data.IntSet.Internal") th_internal ,dep (containers, "Data.Set.Internal") th_internal ,dep (containers, "Data.Sequence.Internal") th_internal @@ -32,9 +33,12 @@ extra_dependencies = where th_internal = (templateHaskell, "Language.Haskell.TH.Lib.Internal") - dep (p1, m1) (p2, m2) s = (,) <$> path s p1 m1 <*> path s p2 m2 - path stage p m = - let context = Context stage p vanilla Inplace + dep (p1, m1) (p2, m2) s = do + let context = Context s p1 (error "extra_dependencies: way not set") (error "extra_dependencies: iplace not set") + ways <- interpretInContext context getLibraryWays + mapM (\way -> (,) <$> path s way p1 m1 <*> path s way p2 m2) (S.toList ways) + path stage way p m = + let context = Context stage p way Inplace in objectPath context . moduleSource $ m formatExtra :: (FilePath, FilePath) -> String ===================================== rts/rts.cabal.in ===================================== @@ -419,9 +419,6 @@ library -- This symbol is useful in gdb, but not referred to anywhere, -- so we need to force it to be included in the binary. ld-options: "-Wl,-u,findPtr" - -- This symbol is useful in gdb, but not referred to anywhere, - -- so we need to force it to be included in the binary. - "-Wl,-u,findPtr" if os(windows) if flag(leading-underscore) ===================================== testsuite/tests/simplStg/should_compile/T22212.hs ===================================== @@ -0,0 +1,45 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +module T22212 where + +import GHC.Exts + +isNullAddr# :: Addr# -> (##) +isNullAddr# a = + case eqAddr# a nullAddr# of + 1# -> (##) + _ -> compareBytes (##) +{-# INLINE isNullAddr# #-} + +compareBytes :: (##) -> (##) +compareBytes _ = (##) +{-# NOINLINE compareBytes #-} + +mArray :: forall {rep :: RuntimeRep} {res :: TYPE rep} + . ( () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> res ) + -> res +mArray cont = + case isNullAddr# nullAddr# of + (##) -> + cont + () () () () () + () () () () () + () () () () () + () () () () () + () () () () () + -- As of writing this test, + -- 9 arguments were required to trigger the bug. + +{- +Original reproducer: + +data Sort = MkSort BS.ByteString [()] + +pattern Array :: () -> () -> Sort +pattern Array x y = MkSort "Array" [x,y] +-} \ No newline at end of file ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -12,3 +12,5 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) + +test('T22212', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb6d299865968d0a8f559668d3c809ce887ed9a7...fe5ab480fe7ba77d49626bff40685cb5c3749519 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb6d299865968d0a8f559668d3c809ce887ed9a7...fe5ab480fe7ba77d49626bff40685cb5c3749519 You're receiving 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 Sep 21 12:04:44 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 08:04:44 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] 30 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <632afddcc8600_3a3c15514f080056b@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 86fb34e5 by Andreas Klebinger at 2022-09-21T13:56:58+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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: Return a unboxed maybe: ~1% - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - + compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23a93bb5957a615f0c7504474710f48d59acde00...86fb34e5eacc8cbe6e0c8b52b952b4008ea117d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23a93bb5957a615f0c7504474710f48d59acde00...86fb34e5eacc8cbe6e0c8b52b952b4008ea117d9 You're receiving 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 Sep 21 12:28:31 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 21 Sep 2022 08:28:31 -0400 Subject: [Git][ghc/ghc][master] users-guide: fix incorrect ghcappdata folder for unix and windows Message-ID: <632b036f85881_3a3c15518388128ba@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 1 changed file: - docs/users_guide/ghci.rst Changes: ===================================== docs/users_guide/ghci.rst ===================================== @@ -3295,13 +3295,12 @@ reads and executes commands from the following files, in this order, if they exist: 1. :file:`{ghcappdata}/ghci.conf`, where ⟨ghcappdata⟩ depends on - your system, but is usually something like :file:`$HOME/.ghc` on - Unix or :file:`C:/Documents and Settings/user/Application - Data/ghc` on Windows. + your system, but is usually something like :file:`$HOME/.ghc` or + :file:`$XDG_CONFIG_HOME/ghc` on Unix or + :file:`C:\\Users\\{username}\\AppData\\Roaming\\ghc` on + Windows. -2. :file:`$XDG_CONFIG_HOME/.ghci` - -3. :file:`./.ghci` +2. :file:`./.ghci` The :file:`ghci.conf` file is most useful for turning on favourite options (e.g. ``:set +s``), and defining useful macros. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a971657d5c4e919a8d446386374e5ed491e9f6b9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a971657d5c4e919a8d446386374e5ed491e9f6b9 You're receiving 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 Sep 21 12:29:07 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 21 Sep 2022 08:29:07 -0400 Subject: [Git][ghc/ghc][master] Don't use isUnliftedType in isTagged Message-ID: <632b03937e48_3a3c15515f48182f5@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 3 changed files: - compiler/GHC/Stg/InferTags/Rewrite.hs - + testsuite/tests/simplStg/should_compile/T22212.hs - testsuite/tests/simplStg/should_compile/all.T Changes: ===================================== compiler/GHC/Stg/InferTags/Rewrite.hs ===================================== @@ -21,15 +21,19 @@ where import GHC.Prelude import GHC.Builtin.PrimOps ( PrimOp(..) ) +import GHC.Types.Basic ( CbvMark (..), isMarkedCbv + , TopLevelFlag(..), isTopLevel + , Levity(..) ) import GHC.Types.Id import GHC.Types.Name import GHC.Types.Unique.Supply import GHC.Types.Unique.FM import GHC.Types.RepType -import GHC.Unit.Types (Module) +import GHC.Types.Var.Set +import GHC.Unit.Types ( Module ) import GHC.Core.DataCon -import GHC.Core (AltCon(..) ) +import GHC.Core ( AltCon(..) ) import GHC.Core.Type import GHC.StgToCmm.Types @@ -47,8 +51,7 @@ import GHC.Utils.Misc import GHC.Stg.InferTags.Types import Control.Monad -import GHC.Types.Basic (CbvMark (NotMarkedCbv, MarkedCbv), isMarkedCbv, TopLevelFlag(..), isTopLevel) -import GHC.Types.Var.Set + -- import GHC.Utils.Trace -- import GHC.Driver.Ppr @@ -217,7 +220,9 @@ isTagged v = do this_mod <- getMod case nameIsLocalOrFrom this_mod (idName v) of True - | isUnliftedType (idType v) + | Just Unlifted <- typeLevity_maybe (idType v) + -- NB: v might be the Id of a representation-polymorphic join point, + -- so we shouldn't use isUnliftedType here. See T22212. -> return True | otherwise -> do -- Local binding !s <- getMap ===================================== testsuite/tests/simplStg/should_compile/T22212.hs ===================================== @@ -0,0 +1,45 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +module T22212 where + +import GHC.Exts + +isNullAddr# :: Addr# -> (##) +isNullAddr# a = + case eqAddr# a nullAddr# of + 1# -> (##) + _ -> compareBytes (##) +{-# INLINE isNullAddr# #-} + +compareBytes :: (##) -> (##) +compareBytes _ = (##) +{-# NOINLINE compareBytes #-} + +mArray :: forall {rep :: RuntimeRep} {res :: TYPE rep} + . ( () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> () -> () -> () -> () -> () + -> res ) + -> res +mArray cont = + case isNullAddr# nullAddr# of + (##) -> + cont + () () () () () + () () () () () + () () () () () + () () () () () + () () () () () + -- As of writing this test, + -- 9 arguments were required to trigger the bug. + +{- +Original reproducer: + +data Sort = MkSort BS.ByteString [()] + +pattern Array :: () -> () -> Sort +pattern Array x y = MkSort "Array" [x,y] +-} \ No newline at end of file ===================================== testsuite/tests/simplStg/should_compile/all.T ===================================== @@ -12,3 +12,5 @@ setTestOpts(f) test('T13588', [ grep_errmsg('case') ] , compile, ['-dverbose-stg2stg -fno-worker-wrapper']) test('T19717', normal, compile, ['-ddump-stg-final -dsuppress-uniques -dno-typeable-binds']) test('inferTags002', [ only_ways(['optasm']), grep_errmsg('(call stg\_ap\_0)', [1])], compile, ['-ddump-cmm -dsuppress-uniques -dno-typeable-binds -O']) + +test('T22212', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06ccad0de07026ea8128a9951f608bcc67ef23d8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06ccad0de07026ea8128a9951f608bcc67ef23d8 You're receiving 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 Sep 21 13:49:05 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 09:49:05 -0400 Subject: [Git][ghc/ghc][wip/andreask/stgLintFix] 32 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <632b16512eca3_3a3c155184c832798@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - c6d348e2 by Andreas Klebinger at 2022-09-21T13:48:58+00:00 Improve stg lint for unboxed sums. It now properly catches cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f1701569bcd699408521aa82340cd8764706d76...c6d348e2f5a571775e02472dba6f80f148f1e247 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f1701569bcd699408521aa82340cd8764706d76...c6d348e2f5a571775e02472dba6f80f148f1e247 You're receiving 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 Sep 21 15:30:44 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 21 Sep 2022 11:30:44 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Don't use isUnliftedType in isTagged Message-ID: <632b2e244ab01_3a3c15513d887432e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 0d364ab1 by Teo Camarasu at 2022-09-21T11:30:19-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 0024750c by Torsten Schmits at 2022-09-21T11:30:28-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 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Types/Name/Cache.hs - ghc/ghc-bin.cabal.in - libraries/base/Control/Monad/Fix.hs - libraries/base/Control/Monad/Zip.hs - libraries/base/Data/Functor/Classes.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Enum.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Stats.hsc - libraries/base/base.cabal - libraries/base/changelog.md - libraries/deepseq - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-prim/GHC/Tuple.hs - + libraries/ghc-prim/GHC/Tuple/Prim.hs - libraries/ghc-prim/ghc-prim.cabal - libraries/ghci/ghci.cabal.in - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/text - packages - rts/Prelude.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe5ab480fe7ba77d49626bff40685cb5c3749519...0024750c8b92f56c76692521c61101ee1d29564a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe5ab480fe7ba77d49626bff40685cb5c3749519...0024750c8b92f56c76692521c61101ee1d29564a You're receiving 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 Sep 21 15:33:55 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 21 Sep 2022 11:33:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/outputable-cleanup Message-ID: <632b2ee336915_3a3c15514f08808b7@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/outputable-cleanup at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/outputable-cleanup You're receiving 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 Sep 21 18:28:23 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 14:28:23 -0400 Subject: [Git][ghc/ghc][wip/andreask/stgLintFix] Improve stg lint for unboxed sums. Message-ID: <632b57c7702c7_3a3c15514009252ab@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC Commits: 51a0e47b by Andreas Klebinger at 2022-09-21T20:27:09+02:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 1 changed file: - compiler/GHC/Stg/Lint.hs Changes: ===================================== compiler/GHC/Stg/Lint.hs ===================================== @@ -46,9 +46,18 @@ are as follows: t_1 :: TYPE r_1, ..., t_n :: TYPE r_n s_1 :: TYPE p_1, ..., a_n :: TYPE p_n -Then we must check that each r_i is compatible with s_i. Compatibility -is weaker than on-the-nose equality: for example, IntRep and WordRep are -compatible. See Note [Bad unsafe coercion] in GHC.Core.Lint. +Before unarisation, we must check that each r_i is compatible with s_i. +Compatibility is weaker than on-the-nose equality: for example, +IntRep and WordRep are compatible. See Note [Bad unsafe coercion] in GHC.Core.Lint. + +After unarisation, a single type might correspond to multiple arguments, e.g. + + (# Int# | Bool #) :: TYPE (SumRep '[ IntRep, LiftedRep ]) + +will result in two arguments: [Int# :: TYPE 'IntRep, Bool :: TYPE LiftedRep] +This means post unarise we potentially have to match up multiple arguments with +the reps of a signle argument in the types definitions. Because the type of the function +is *not* in unarised form. Wrinkle: it can sometimes happen that an argument type in the type of the function does not have a fixed runtime representation, i.e. @@ -332,14 +341,18 @@ lintStgAppReps _fun [] = return () lintStgAppReps fun args = do lf <- getLintFlags let platform = lf_platform lf + (fun_arg_tys, _res) = splitFunTys (idType fun) fun_arg_tys' = map (scaledThing ) fun_arg_tys :: [Type] + + -- Might be "wrongly" typed as polymorphic. See #21399 + -- In these cases typePrimRep_maybe will return Nothing + -- and we abort kind checking. fun_arg_tys_reps, actual_arg_reps :: [Maybe [PrimRep]] fun_arg_tys_reps = map typePrimRep_maybe fun_arg_tys' actual_arg_reps = map (typePrimRep_maybe . stgArgType) args match_args :: [Maybe [PrimRep]] -> [Maybe [PrimRep]] -> LintM () - -- Might be wrongly typed as polymorphic. See #21399 match_args (Nothing:_) _ = return () match_args (_) (Nothing:_) = return () match_args (Just actual_rep:actual_reps_left) (Just expected_rep:expected_reps_left) @@ -353,21 +366,36 @@ lintStgAppReps fun args = do -- Some reps are compatible *even* if they are not the same. E.g. IntRep and WordRep. -- We check for that here with primRepCompatible - | and $ zipWith (primRepCompatible platform) actual_rep expected_rep + | length actual_rep == length expected_rep + -- We can use zipWith since functions are allowed to be over/under saturated. + , and $ zipWith (primRepCompatible platform) actual_rep expected_rep = match_args actual_reps_left expected_reps_left + -- Post unarise we might distribute args from within one unboxed sum over multiple single rep args. + -- This means we might need to match up things like: + -- [Just [WordRep, LiftedRep]] with [Just [WordRep],Just [LiftedRep]] which we do here. + | lf_unarised lf + , Just (actual,actuals) <- getOneRep actual_rep actual_reps_left + , Just (expected,expecteds) <- getOneRep expected_rep expected_reps_left + , (primRepCompatible platform) actual expected + = match_args actuals expecteds + | otherwise = addErrL $ hang (text "Function type reps and function argument reps mismatched") 2 $ (text "In application " <> ppr fun <+> ppr args $$ - text "argument rep:" <> ppr actual_rep $$ - text "expected rep:" <> ppr expected_rep $$ + text "argument rep:" <> ppr actual_arg_reps $$ + text "expected rep:" <> ppr fun_arg_tys_reps $$ -- text "expected reps:" <> ppr arg_ty_reps $$ text "unarised?:" <> ppr (lf_unarised lf)) where isVoidRep [] = True isVoidRep [VoidRep] = True isVoidRep _ = False - - -- n_arg_ty_reps = length arg_ty_reps + -- Try to strip one non-void arg rep from the current argument type returning + -- the remaining list of arguments + getOneRep :: [PrimRep] -> [Maybe [PrimRep]] -> Maybe (PrimRep, [Maybe [PrimRep]]) + getOneRep [] _rest = Nothing -- Void rep args are invalid at this point. + getOneRep [rep] rest = Just (rep,rest) -- A single arg rep arg + getOneRep (rep:reps) rest = Just (rep,Just reps:rest) -- Multi rep arg. match_args _ _ = return () -- Functions are allowed to be over/under applied. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51a0e47b29b69af3ac130ff4adcd2594a008b1b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51a0e47b29b69af3ac130ff4adcd2594a008b1b7 You're receiving 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 Sep 21 18:29:31 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 14:29:31 -0400 Subject: [Git][ghc/ghc][wip/andreask/stgLintFix] 32 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <632b580b5f4f7_3a3c15515f49256fc@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 4175d508 by Andreas Klebinger at 2022-09-21T20:28:29+02:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 30 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/51a0e47b29b69af3ac130ff4adcd2594a008b1b7...4175d50805b8dc6718fba8015ce9c18c4f6bc8f9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/51a0e47b29b69af3ac130ff4adcd2594a008b1b7...4175d50805b8dc6718fba8015ce9c18c4f6bc8f9 You're receiving 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 Sep 21 18:30:55 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 21 Sep 2022 14:30:55 -0400 Subject: [Git][ghc/ghc][master] Add fragmentation statistic to GHC.Stats Message-ID: <632b585fdb746_3a3c155184c9319c1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 4 changed files: - libraries/base/GHC/Stats.hsc - libraries/base/changelog.md - rts/Stats.c - rts/include/RtsAPI.h Changes: ===================================== libraries/base/GHC/Stats.hsc ===================================== @@ -159,6 +159,11 @@ data GCDetails = GCDetails { , gcdetails_par_max_copied_bytes :: Word64 -- | In parallel GC, the amount of balanced data copied by all threads , gcdetails_par_balanced_copied_bytes :: Word64 + -- | The amount of memory lost due to block fragmentation in bytes. + -- Block fragmentation is the difference between the amount of blocks retained by the RTS and the blocks that are in use. + -- This occurs when megablocks are only sparsely used, eg, when data that cannot be moved retains a megablock. + -- @since 4.17.0.0 + , gcdetails_block_fragmentation_bytes :: Word64 -- | The time elapsed during synchronisation before GC , gcdetails_sync_elapsed_ns :: RtsTime -- | The CPU time used during GC itself @@ -241,6 +246,8 @@ getRTSStats = do (# peek GCDetails, par_max_copied_bytes) pgc gcdetails_par_balanced_copied_bytes <- (# peek GCDetails, par_balanced_copied_bytes) pgc + gcdetails_block_fragmentation_bytes <- + (# peek GCDetails, block_fragmentation_bytes) pgc gcdetails_sync_elapsed_ns <- (# peek GCDetails, sync_elapsed_ns) pgc gcdetails_cpu_ns <- (# peek GCDetails, cpu_ns) pgc gcdetails_elapsed_ns <- (# peek GCDetails, elapsed_ns) pgc ===================================== libraries/base/changelog.md ===================================== @@ -36,6 +36,7 @@ #10](https://github.com/haskell/core-libraries-committee/issues/10) for the related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). + * Add `gcdetails_block_fragmentation_bytes` to `GHC.Stats.GCDetails` to track heap fragmentation. ## 4.17.0.0 *August 2022* ===================================== rts/Stats.c ===================================== @@ -182,6 +182,7 @@ initStats0(void) .copied_bytes = 0, .par_max_copied_bytes = 0, .par_balanced_copied_bytes = 0, + .block_fragmentation_bytes = 0, .sync_elapsed_ns = 0, .cpu_ns = 0, .elapsed_ns = 0, @@ -482,6 +483,9 @@ stat_endGC (Capability *cap, gc_thread *initiating_gct, W_ live, W_ copied, W_ s stats.gc.copied_bytes = copied * sizeof(W_); stats.gc.par_max_copied_bytes = par_max_copied * sizeof(W_); stats.gc.par_balanced_copied_bytes = par_balanced_copied * sizeof(W_); + stats.gc.block_fragmentation_bytes = + (mblocks_allocated * BLOCKS_PER_MBLOCK + - n_alloc_blocks) * BLOCK_SIZE; bool stats_enabled = RtsFlags.GcFlags.giveStats != NO_GC_STATS || @@ -582,9 +586,7 @@ stat_endGC (Capability *cap, gc_thread *initiating_gct, W_ live, W_ copied, W_ s stats.gc.gen, stats.gc.copied_bytes, stats.gc.slop_bytes, - /* current loss due to fragmentation */ - (mblocks_allocated * BLOCKS_PER_MBLOCK - - n_alloc_blocks) * BLOCK_SIZE, + stats.gc.block_fragmentation_bytes, par_n_threads, stats.gc.par_max_copied_bytes, stats.gc.copied_bytes, ===================================== rts/include/RtsAPI.h ===================================== @@ -155,6 +155,8 @@ typedef struct GCDetails_ { uint64_t mem_in_use_bytes; // Total amount of data copied during this GC uint64_t copied_bytes; + // Memory lost due to block fragmentation + uint64_t block_fragmentation_bytes; // In parallel GC, the max amount of data copied by any one thread uint64_t par_max_copied_bytes; // In parallel GC, the amount of balanced data copied by all threads View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c0ba775dda6ddec1251363d1b73f4f3e35931dd9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c0ba775dda6ddec1251363d1b73f4f3e35931dd9 You're receiving 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 Sep 21 18:31:45 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 21 Sep 2022 14:31:45 -0400 Subject: [Git][ghc/ghc][master] Rename Solo[constructor] to MkSolo Message-ID: <632b589185ec6_3a3c15513ec9385c1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Types/Name/Cache.hs - ghc/ghc-bin.cabal.in - libraries/base/Control/Monad/Fix.hs - libraries/base/Control/Monad/Zip.hs - libraries/base/Data/Functor/Classes.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Enum.hs - libraries/base/GHC/Ix.hs - libraries/base/base.cabal - libraries/deepseq - libraries/ghc-bignum/ghc-bignum.cabal - libraries/ghc-compact/ghc-compact.cabal - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-prim/GHC/Tuple.hs - + libraries/ghc-prim/GHC/Tuple/Prim.hs - libraries/ghc-prim/ghc-prim.cabal - libraries/ghci/ghci.cabal.in - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/text - packages - rts/Prelude.h - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/backpack/should_compile/bkp16.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2463df2fe21b5b37ecada3df8c6726c534d24590 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2463df2fe21b5b37ecada3df8c6726c534d24590 You're receiving 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 Sep 21 18:47:53 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 14:47:53 -0400 Subject: [Git][ghc/ghc][wip/andreask/stgLintFix] Apply 4 suggestion(s) to 1 file(s) Message-ID: <632b5c598e149_3a3c1551838947976@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC Commits: 43dfbafb by sheaf at 2022-09-21T18:47:51+00:00 Apply 4 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/Stg/Lint.hs Changes: ===================================== compiler/GHC/Stg/Lint.hs ===================================== @@ -56,7 +56,7 @@ After unarisation, a single type might correspond to multiple arguments, e.g. will result in two arguments: [Int# :: TYPE 'IntRep, Bool :: TYPE LiftedRep] This means post unarise we potentially have to match up multiple arguments with -the reps of a signle argument in the types definitions. Because the type of the function +the reps of a single argument in the type's definition, because the type of the function is *not* in unarised form. Wrinkle: it can sometimes happen that an argument type in the type of @@ -366,18 +366,17 @@ lintStgAppReps fun args = do -- Some reps are compatible *even* if they are not the same. E.g. IntRep and WordRep. -- We check for that here with primRepCompatible - | length actual_rep == length expected_rep - -- We can use zipWith since functions are allowed to be over/under saturated. - , and $ zipWith (primRepCompatible platform) actual_rep expected_rep + | primRepsCompatible platform actual_rep expected_rep = match_args actual_reps_left expected_reps_left -- Post unarise we might distribute args from within one unboxed sum over multiple single rep args. -- This means we might need to match up things like: -- [Just [WordRep, LiftedRep]] with [Just [WordRep],Just [LiftedRep]] which we do here. + -- See Note [Linting StgApp]. | lf_unarised lf , Just (actual,actuals) <- getOneRep actual_rep actual_reps_left , Just (expected,expecteds) <- getOneRep expected_rep expected_reps_left - , (primRepCompatible platform) actual expected + , primRepCompatible platform actual expected = match_args actuals expecteds | otherwise = addErrL $ hang (text "Function type reps and function argument reps mismatched") 2 $ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43dfbafb1453cc051595773339c5862666650856 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43dfbafb1453cc051595773339c5862666650856 You're receiving 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 Sep 21 18:56:36 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 21 Sep 2022 14:56:36 -0400 Subject: [Git][ghc/ghc][wip/andreask/stgLintFix] Improve stg lint for unboxed sums. Message-ID: <632b5e6452c8d_3a3c15515f49513c7@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC Commits: 5caedd50 by Andreas Klebinger at 2022-09-21T20:55:24+02:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 1 changed file: - compiler/GHC/Stg/Lint.hs Changes: ===================================== compiler/GHC/Stg/Lint.hs ===================================== @@ -46,9 +46,18 @@ are as follows: t_1 :: TYPE r_1, ..., t_n :: TYPE r_n s_1 :: TYPE p_1, ..., a_n :: TYPE p_n -Then we must check that each r_i is compatible with s_i. Compatibility -is weaker than on-the-nose equality: for example, IntRep and WordRep are -compatible. See Note [Bad unsafe coercion] in GHC.Core.Lint. +Before unarisation, we must check that each r_i is compatible with s_i. +Compatibility is weaker than on-the-nose equality: for example, +IntRep and WordRep are compatible. See Note [Bad unsafe coercion] in GHC.Core.Lint. + +After unarisation, a single type might correspond to multiple arguments, e.g. + + (# Int# | Bool #) :: TYPE (SumRep '[ IntRep, LiftedRep ]) + +will result in two arguments: [Int# :: TYPE 'IntRep, Bool :: TYPE LiftedRep] +This means post unarise we potentially have to match up multiple arguments with +the reps of a single argument in the type's definition, because the type of the function +is *not* in unarised form. Wrinkle: it can sometimes happen that an argument type in the type of the function does not have a fixed runtime representation, i.e. @@ -119,7 +128,7 @@ import Data.Maybe import GHC.Utils.Misc import GHC.Core.Multiplicity (scaledThing) import GHC.Settings (Platform) -import GHC.Core.TyCon (primRepCompatible) +import GHC.Core.TyCon (primRepCompatible, primRepsCompatible) import GHC.Utils.Panic.Plain (panic) lintStgTopBindings :: forall a . (OutputablePass a, BinderP a ~ Id) @@ -332,14 +341,18 @@ lintStgAppReps _fun [] = return () lintStgAppReps fun args = do lf <- getLintFlags let platform = lf_platform lf + (fun_arg_tys, _res) = splitFunTys (idType fun) fun_arg_tys' = map (scaledThing ) fun_arg_tys :: [Type] + + -- Might be "wrongly" typed as polymorphic. See #21399 + -- In these cases typePrimRep_maybe will return Nothing + -- and we abort kind checking. fun_arg_tys_reps, actual_arg_reps :: [Maybe [PrimRep]] fun_arg_tys_reps = map typePrimRep_maybe fun_arg_tys' actual_arg_reps = map (typePrimRep_maybe . stgArgType) args match_args :: [Maybe [PrimRep]] -> [Maybe [PrimRep]] -> LintM () - -- Might be wrongly typed as polymorphic. See #21399 match_args (Nothing:_) _ = return () match_args (_) (Nothing:_) = return () match_args (Just actual_rep:actual_reps_left) (Just expected_rep:expected_reps_left) @@ -353,21 +366,36 @@ lintStgAppReps fun args = do -- Some reps are compatible *even* if they are not the same. E.g. IntRep and WordRep. -- We check for that here with primRepCompatible - | and $ zipWith (primRepCompatible platform) actual_rep expected_rep + | primRepsCompatible platform actual_rep expected_rep = match_args actual_reps_left expected_reps_left + -- Post unarise we might distribute args from within one unboxed sum over multiple single rep args. + -- This means we might need to match up things like: + -- [Just [WordRep, LiftedRep]] with [Just [WordRep],Just [LiftedRep]] which we do here. + -- See Note [Linting StgApp]. + | lf_unarised lf + , Just (actual,actuals) <- getOneRep actual_rep actual_reps_left + , Just (expected,expecteds) <- getOneRep expected_rep expected_reps_left + , primRepCompatible platform actual expected + = match_args actuals expecteds + | otherwise = addErrL $ hang (text "Function type reps and function argument reps mismatched") 2 $ (text "In application " <> ppr fun <+> ppr args $$ - text "argument rep:" <> ppr actual_rep $$ - text "expected rep:" <> ppr expected_rep $$ + text "argument rep:" <> ppr actual_arg_reps $$ + text "expected rep:" <> ppr fun_arg_tys_reps $$ -- text "expected reps:" <> ppr arg_ty_reps $$ text "unarised?:" <> ppr (lf_unarised lf)) where isVoidRep [] = True isVoidRep [VoidRep] = True isVoidRep _ = False - - -- n_arg_ty_reps = length arg_ty_reps + -- Try to strip one non-void arg rep from the current argument type returning + -- the remaining list of arguments. We return Nothing for invalid input which + -- will result in a lint failure in match_args. + getOneRep :: [PrimRep] -> [Maybe [PrimRep]] -> Maybe (PrimRep, [Maybe [PrimRep]]) + getOneRep [] _rest = Nothing -- Void rep args are invalid at this point. + getOneRep [rep] rest = Just (rep,rest) -- A single arg rep arg + getOneRep (rep:reps) rest = Just (rep,Just reps:rest) -- Multi rep arg. match_args _ _ = return () -- Functions are allowed to be over/under applied. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5caedd50db499638420207a5a871b7d3f43f189f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5caedd50db499638420207a5a871b7d3f43f189f You're receiving 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 Sep 21 21:05:50 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 21 Sep 2022 17:05:50 -0400 Subject: [Git][ghc/ghc][wip/outputable-cleanup] Minor refactor around Outputable Message-ID: <632b7cae206ed_3a3c1551400972615@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/outputable-cleanup at Glasgow Haskell Compiler / GHC Commits: eb1e236f by Krzysztof Gogolewski at 2022-09-21T23:05:30+02: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 - - - - - 12 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Hs.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Unit/Types.hs-boot - compiler/GHC/Utils/Outputable.hs - − compiler/GHC/Utils/Outputable.hs-boot Changes: ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -1481,28 +1481,28 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel] -> maybe_underscore $ ftext str <> text "_fast" RtsLabel (RtsSelectorInfoTable upd_reqd offset) - -> maybe_underscore $ hcat [ text "stg_sel_", text (show offset) + -> maybe_underscore $ hcat [ text "stg_sel_", int offset , if upd_reqd then text "_upd_info" else text "_noupd_info" ] RtsLabel (RtsSelectorEntry upd_reqd offset) - -> maybe_underscore $ hcat [ text "stg_sel_", text (show offset) + -> maybe_underscore $ hcat [ text "stg_sel_", int offset , if upd_reqd then text "_upd_entry" else text "_noupd_entry" ] RtsLabel (RtsApInfoTable upd_reqd arity) - -> maybe_underscore $ hcat [ text "stg_ap_", text (show arity) + -> maybe_underscore $ hcat [ text "stg_ap_", int arity , if upd_reqd then text "_upd_info" else text "_noupd_info" ] RtsLabel (RtsApEntry upd_reqd arity) - -> maybe_underscore $ hcat [ text "stg_ap_", text (show arity) + -> maybe_underscore $ hcat [ text "stg_ap_", int arity , if upd_reqd then text "_upd_entry" else text "_noupd_entry" ===================================== compiler/GHC/Cmm/DebugBlock.hs ===================================== @@ -524,7 +524,7 @@ instance OutputableP Platform UnwindExpr where pprUnwindExpr :: Rational -> Platform -> UnwindExpr -> SDoc pprUnwindExpr p env = \case - UwConst i -> ppr i + UwConst i -> int i UwReg g 0 -> ppr g UwReg g x -> pprUnwindExpr p env (UwPlus (UwReg g 0) (UwConst x)) UwDeref e -> char '*' <> pprUnwindExpr 3 env e ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -386,7 +386,7 @@ cmmNativeGens logger config ncgImpl h dbgMap = go let newFileIds = sortBy (comparing snd) $ nonDetEltsUFM $ fileIds' `minusUFM` fileIds -- See Note [Unique Determinism and code generation] - pprDecl (f,n) = text "\t.file " <> ppr n <+> + pprDecl (f,n) = text "\t.file " <> int n <+> pprFilePathString (unpackFS f) emitNativeCode logger config h $ vcat $ ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -373,60 +373,60 @@ pprInstr platform instr = case instr of -- AArch64 Instruction Set -- 1. Arithmetic Instructions ------------------------------------------------ ADD o1 o2 o3 - | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> text "\tfadd" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - | otherwise -> text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - CMN o1 o2 -> text "\tcmn" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 + | otherwise -> op3 (text "\tadd") o1 o2 o3 + CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 - | isFloatOp o1 && isFloatOp o2 -> text "\tfcmp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - | otherwise -> text "\tcmp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - MSUB o1 o2 o3 o4 -> text "\tmsub" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 + | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 + | otherwise -> op2 (text "\tcmp") o1 o2 + MSUB o1 o2 o3 o4 -> op4 (text "\tmsub") o1 o2 o3 o4 MUL o1 o2 o3 - | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> text "\tfmul" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - | otherwise -> text "\tmul" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - SMULH o1 o2 o3 -> text "\tsmulh" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - SMULL o1 o2 o3 -> text "\tsmull" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfmul") o1 o2 o3 + | otherwise -> op3 (text "\tmul") o1 o2 o3 + SMULH o1 o2 o3 -> op3 (text "\tsmulh") o1 o2 o3 + SMULL o1 o2 o3 -> op3 (text "\tsmull") o1 o2 o3 NEG o1 o2 - | isFloatOp o1 && isFloatOp o2 -> text "\tfneg" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - | otherwise -> text "\tneg" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfneg") o1 o2 + | otherwise -> op2 (text "\tneg") o1 o2 SDIV o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 - -> text "\tfdiv" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - SDIV o1 o2 o3 -> text "\tsdiv" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + -> op3 (text "\tfdiv") o1 o2 o3 + SDIV o1 o2 o3 -> op3 (text "\tsdiv") o1 o2 o3 SUB o1 o2 o3 - | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> text "\tfsub" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - | otherwise -> text "\tsub" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - UDIV o1 o2 o3 -> text "\tudiv" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfsub") o1 o2 o3 + | otherwise -> op3 (text "\tsub") o1 o2 o3 + UDIV o1 o2 o3 -> op3 (text "\tudiv") o1 o2 o3 -- 2. Bit Manipulation Instructions ------------------------------------------ - SBFM o1 o2 o3 o4 -> text "\tsbfm" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 - UBFM o1 o2 o3 o4 -> text "\tubfm" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 + SBFM o1 o2 o3 o4 -> op4 (text "\tsbfm") o1 o2 o3 o4 + UBFM o1 o2 o3 o4 -> op4 (text "\tubfm") o1 o2 o3 o4 -- signed and unsigned bitfield extract - SBFX o1 o2 o3 o4 -> text "\tsbfx" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 - UBFX o1 o2 o3 o4 -> text "\tubfx" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 - SXTB o1 o2 -> text "\tsxtb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - UXTB o1 o2 -> text "\tuxtb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - SXTH o1 o2 -> text "\tsxth" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - UXTH o1 o2 -> text "\tuxth" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + SBFX o1 o2 o3 o4 -> op4 (text "\tsbfx") o1 o2 o3 o4 + UBFX o1 o2 o3 o4 -> op4 (text "\tubfx") o1 o2 o3 o4 + SXTB o1 o2 -> op2 (text "\tsxtb") o1 o2 + UXTB o1 o2 -> op2 (text "\tuxtb") o1 o2 + SXTH o1 o2 -> op2 (text "\tsxth") o1 o2 + UXTH o1 o2 -> op2 (text "\tuxth") o1 o2 -- 3. Logical and Move Instructions ------------------------------------------ - AND o1 o2 o3 -> text "\tand" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ANDS o1 o2 o3 -> text "\tands" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ASR o1 o2 o3 -> text "\tasr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - BIC o1 o2 o3 -> text "\tbic" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - BICS o1 o2 o3 -> text "\tbics" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - EON o1 o2 o3 -> text "\teon" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - EOR o1 o2 o3 -> text "\teor" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - LSL o1 o2 o3 -> text "\tlsl" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - LSR o1 o2 o3 -> text "\tlsr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 + ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 + ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 + BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 + BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 + EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 + EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 + LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 + LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 MOV o1 o2 - | isFloatOp o1 || isFloatOp o2 -> text "\tfmov" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - | otherwise -> text "\tmov" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - MOVK o1 o2 -> text "\tmovk" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - MVN o1 o2 -> text "\tmvn" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - ORN o1 o2 o3 -> text "\torn" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ORR o1 o2 o3 -> text "\torr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ROR o1 o2 o3 -> text "\tror" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - TST o1 o2 -> text "\ttst" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + | isFloatOp o1 || isFloatOp o2 -> op2 (text "\tfmov") o1 o2 + | otherwise -> op2 (text "\tmov") o1 o2 + MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 + MVN o1 o2 -> op2 (text "\tmvn") o1 o2 + ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 + ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 + ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 + TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -459,83 +459,91 @@ pprInstr platform instr = case instr of -- address. Not observing the correct size when loading will lead -- inevitably to crashes. STR _f o1@(OpReg W8 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tstrb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tstrb") o1 o2 STR _f o1@(OpReg W16 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tstrh" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - STR _f o1 o2 -> text "\tstr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tstrh") o1 o2 + STR _f o1 o2 -> op2 (text "\tstr") o1 o2 #if defined(darwin_HOST_OS) LDR _f o1 (OpImm (ImmIndex lbl' off)) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@page" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@pageoff" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl <> text "@page") $$ + op_add o1 (pprAsmLabel platform lbl <> text "@pageoff") $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") LDR _f o1 (OpImm (ImmCLbl lbl)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@page" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@pageoff" + op_adrp o1 (pprAsmLabel platform lbl <> text "@page") $$ + op_add o1 (pprAsmLabel platform lbl <> text "@pageoff") + #else LDR _f o1 (OpImm (ImmIndex lbl' off)) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text ":lo12:" <> pprAsmLabel platform lbl $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl) $$ + op_add o1 (text ":lo12:" <> pprAsmLabel platform lbl) $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) LDR _f o1 (OpImm (ImmCLbl lbl)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text ":lo12:" <> pprAsmLabel platform lbl + op_adrp o1 (pprAsmLabel platform lbl) $$ + op_add o1 (text ":lo12:" <> pprAsmLabel platform lbl) + #endif LDR _f o1@(OpReg W8 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tldrb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tldrb") o1 o2 LDR _f o1@(OpReg W16 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tldrh" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - LDR _f o1 o2 -> text "\tldr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tldrh") o1 o2 + LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 - STP _f o1 o2 o3 -> text "\tstp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - LDP _f o1 o2 o3 -> text "\tldp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 + LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 -- 8. Synchronization Instructions ------------------------------------------- DMBSY -> text "\tdmb sy" -- 9. Floating Point Instructions -------------------------------------------- - FCVT o1 o2 -> text "\tfcvt" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - SCVTF o1 o2 -> text "\tscvtf" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - FCVTZS o1 o2 -> text "\tfcvtzs" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - FABS o1 o2 -> text "\tfabs" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 + SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 + FCVTZS o1 o2 -> op2 (text "\tfcvtzs") o1 o2 + FABS o1 o2 -> op2 (text "\tfabs") o1 o2 + where op2 op o1 o2 = op <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op3 op o1 o2 o3 = op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + op4 op o1 o2 o3 o4 = op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 + op_ldr o1 rest = text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> rest <> text "]" + op_adrp o1 rest = text "\tadrp" <+> pprOp platform o1 <> comma <+> rest + op_add o1 rest = text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> rest pprBcond :: Cond -> SDoc pprBcond c = text "b." <> pprCond c ===================================== compiler/GHC/Core/Coercion/Axiom.hs ===================================== @@ -485,7 +485,7 @@ instance Outputable CoAxBranch where , cab_lhs = lhs , cab_rhs = rhs }) = text "CoAxBranch" <+> parens (ppr loc) <> colon - <+> brackets (fsep (punctuate comma (map pprType lhs))) + <+> brackets (pprWithCommas pprType lhs) <+> text "=>" <+> pprType rhs {- ===================================== compiler/GHC/Hs.hs ===================================== @@ -124,7 +124,7 @@ instance Outputable (HsModule GhcPs) where Nothing -> pp_header (text "where") Just es -> vcat [ pp_header lparen, - nest 8 (fsep (punctuate comma (map ppr (unLoc es)))), + nest 8 (pprWithCommas ppr (unLoc es)), nest 4 (text ") where") ], pp_nonnull imports, ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1691,7 +1691,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsWildCardPV l = cmdFail l (text "_") mkHsTySigPV l a sig _ = cmdFail (locA l) (ppr a <+> text "::" <+> ppr sig) mkHsExplicitListPV l xs _ = cmdFail l $ - brackets (fsep (punctuate comma (map ppr xs))) + brackets (pprWithCommas ppr xs) mkHsSplicePV (L l sp) = cmdFail l (pprUntypedSplice True Nothing sp) mkHsRecordPV _ l _ a (fbinds, ddLoc) _ = do let (fs, ps) = partitionEithers fbinds ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -489,8 +489,7 @@ addHoleFitDocs fits = { let warning = text "WARNING: Couldn't find any documentation for the following modules:" $+$ nest 2 - (fsep (punctuate comma - (either text ppr <$> Set.toList mods)) $+$ + (pprWithCommas (either text ppr) (Set.toList mods) $+$ text "Make sure the modules are compiled with '-haddock'.") ; warnPprTrace (not $ Set.null mods)"addHoleFitDocs" warning (pure ()) } ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -366,7 +366,7 @@ pprAvail :: AvailInfo -> SDoc pprAvail (Avail n) = ppr n pprAvail (AvailTC n ns) - = ppr n <> braces (fsep (punctuate comma (map ppr ns))) + = ppr n <> braces (pprWithCommas ppr ns) instance Binary AvailInfo where put_ bh (Avail aa) = do ===================================== compiler/GHC/Unit/Types.hs-boot ===================================== @@ -2,7 +2,6 @@ module GHC.Unit.Types where import GHC.Prelude () -import {-# SOURCE #-} GHC.Utils.Outputable import Language.Haskell.Syntax.Module.Name (ModuleName) import Data.Kind (Type) @@ -15,4 +14,3 @@ type Unit = GenUnit UnitId moduleName :: GenModule a -> ModuleName moduleUnit :: GenModule a -> a -pprModule :: Module -> SDoc ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -944,16 +944,16 @@ instance Outputable UTCTime where ppr = text . formatShow iso8601Format instance (Outputable a) => Outputable [a] where - ppr xs = brackets (fsep (punctuate comma (map ppr xs))) + ppr xs = brackets (pprWithCommas ppr xs) instance (Outputable a) => Outputable (NonEmpty a) where ppr = ppr . NEL.toList instance (Outputable a) => Outputable (Set a) where - ppr s = braces (fsep (punctuate comma (map ppr (Set.toList s)))) + ppr s = braces (pprWithCommas ppr (Set.toList s)) instance Outputable IntSet.IntSet where - ppr s = braces (fsep (punctuate comma (map ppr (IntSet.toList s)))) + ppr s = braces (pprWithCommas ppr (IntSet.toList s)) instance (Outputable a, Outputable b) => Outputable (a, b) where ppr (x,y) = parens (sep [ppr x <> comma, ppr y]) ===================================== compiler/GHC/Utils/Outputable.hs-boot deleted ===================================== @@ -1,9 +0,0 @@ -module GHC.Utils.Outputable where - -import GHC.Prelude - -data SDoc -data PprStyle -data SDocContext - -text :: String -> SDoc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb1e236fc6ff37c28cee4cf9a2966ee4a0c4c375 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb1e236fc6ff37c28cee4cf9a2966ee4a0c4c375 You're receiving 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 Sep 21 22:32:34 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Wed, 21 Sep 2022 18:32:34 -0400 Subject: [Git][ghc/ghc][wip/nr/indentable] 2 commits: fix bug: wasm loops don't loop; they fall through Message-ID: <632b91025ee51_3a3c155184c98549e@gitlab.mail> Norman Ramsey pushed to branch wip/nr/indentable at Glasgow Haskell Compiler / GHC Commits: a0edb89a by Norman Ramsey at 2022-09-21T18:31:51-04:00 fix bug: wasm loops don't loop; they fall through - - - - - 3e9e2c7c by Norman Ramsey at 2022-09-21T18:32:13-04:00 add draft Indentable module (to replace Outputable) - - - - - 4 changed files: - + compiler/GHC/Utils/Indentable.hs - compiler/GHC/Wasm/ControlFlow/FromCmm.hs - compiler/ghc.cabal.in - testsuite/tests/wasm/should_run/control-flow/RunWasm.hs Changes: ===================================== compiler/GHC/Utils/Indentable.hs ===================================== @@ -0,0 +1,54 @@ +{-# LANGUAGE OverloadedStrings #-} + +module GHC.Utils.Indentable + ( IndentedBuilder + , Indentation + , newline + , nestBy + , nest + , indentTo + , (<+>) + , Indentable(..) + ) + +where + +import GHC.Prelude + +import Data.ByteString.Builder +import Data.Monoid +import Data.String + +type Indentation = Builder + +class Indentable a where + toIndentable :: a -> IndentedBuilder + +newtype IndentedBuilder = IB (Indentation -> Builder) + +newline :: IndentedBuilder +newline = IB $ \indent -> "\n" <> indent + +instance Semigroup IndentedBuilder where + IB f <> IB f' = IB $ \indent -> f indent <> f' indent + +instance IsString IndentedBuilder where + fromString s = IB $ const (fromString s) + +instance Monoid IndentedBuilder where + mempty = IB $ const mempty + +nestBy :: Indentation -> IndentedBuilder -> IndentedBuilder +nestBy moreIndent (IB f) = IB (\indent -> f (indent <> moreIndent)) + +nest :: Int -> IndentedBuilder -> IndentedBuilder +nest k = nestBy $ fromString $ take k spaces + +spaces :: String +spaces = ' ' : spaces + +indentTo :: Indentation -> IndentedBuilder -> Builder +indentTo indentation (IB f) = f indentation + +(<+>) :: IndentedBuilder -> IndentedBuilder -> IndentedBuilder +s <+> s' = s <> " " <> s' ===================================== compiler/GHC/Wasm/ControlFlow/FromCmm.hs ===================================== @@ -183,8 +183,7 @@ structuredControl platform txExpr txBlock g = CmmSwitch {} -> children -- N.B. Unlike `if`, translation of Switch uses only labels. _ -> filter hasMergeRoot children - loopContext = LoopHeadedBy (entryLabel x) `inside` - (context `withFallthrough` entryLabel x) + loopContext = LoopHeadedBy (entryLabel x) `inside` context hasMergeRoot = isMergeNode . Tree.rootLabel nodeWithin fty x (y_n:ys) (Just zlabel) context = ===================================== compiler/ghc.cabal.in ===================================== @@ -791,6 +791,7 @@ Library GHC.Utils.FV GHC.Utils.GlobalVars GHC.Utils.IO.Unsafe + GHC.Utils.Indentable GHC.Utils.Json GHC.Utils.Lexeme GHC.Utils.Logger ===================================== testsuite/tests/wasm/should_run/control-flow/RunWasm.hs ===================================== @@ -36,11 +36,11 @@ withPushedValue _ _ = error "looked for pushed value, but did not find one" run :: forall s e m . ControlTestMonad s e m => Stack s e -> m () run [] = return () -run (EndLoop s : stack) = run (Run s : EndLoop s : stack) +run (EndLoop _ : stack) = run stack run (EndBlock : stack) = run stack run (EndIf : stack) = run stack run (Pushed e : frame : stack) = run (frame : Pushed e : stack) -run (Pushed e : []) = return () +run (Pushed _ : []) = return () run (Run s : stack) = step s where step :: UntypedControl s e -> m () step (U WasmFallthrough) = run stack @@ -63,7 +63,7 @@ run (Run s : stack) = step s step (U (WasmActions s)) = takeAction @s @e s >> run stack step (U (WasmSeq s s')) = run (Run (U s) : Run (U s') : stack) - br 0 (EndLoop s : stack) = run (EndLoop s : stack) + br 0 (EndLoop us : stack) = run (Run us : EndLoop us : stack) br 0 (EndBlock : stack) = run stack br 0 (EndIf : stack) = run stack br k ((Run _) : stack) = br k stack View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9023c8dbdf201aff916d74aff3f91d760f0e515c...3e9e2c7ce37d5e1a898c4ee3274622fd26050826 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9023c8dbdf201aff916d74aff3f91d760f0e515c...3e9e2c7ce37d5e1a898c4ee3274622fd26050826 You're receiving 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 Sep 21 23:10:14 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Wed, 21 Sep 2022 19:10:14 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/nr/applicative-control-flow Message-ID: <632b99d6c8fc1_3a3c15513ec99116b@gitlab.mail> Norman Ramsey pushed new branch wip/nr/applicative-control-flow at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/nr/applicative-control-flow You're receiving 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 Sep 22 10:35:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 22 Sep 2022 06:35:40 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Add fragmentation statistic to GHC.Stats Message-ID: <632c3a7c2dac8_3a3c15513d8108283@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 9d582d90 by Matthew Pickering at 2022-09-22T06:35:23-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 - - - - - 4691807a by Krzysztof Gogolewski at 2022-09-22T06:35:24-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 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Cache.hs - compiler/GHC/Unit/Types.hs-boot - compiler/GHC/Utils/Outputable.hs - − compiler/GHC/Utils/Outputable.hs-boot - ghc/ghc-bin.cabal.in - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - libraries/base/Control/Monad/Fix.hs - libraries/base/Control/Monad/Zip.hs - libraries/base/Data/Functor/Classes.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Enum.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Stats.hsc - libraries/base/base.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0024750c8b92f56c76692521c61101ee1d29564a...4691807a9826e21f3e1b3bcd0e6b83fc5a8cb0cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0024750c8b92f56c76692521c61101ee1d29564a...4691807a9826e21f3e1b3bcd0e6b83fc5a8cb0cd You're receiving 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 Sep 22 12:56:24 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 22 Sep 2022 08:56:24 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Add encodeDouble/Float RTS functions Message-ID: <632c5b78d87a4_3a3c15513c41119113@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 390df0aa by Sylvain Henry at 2022-09-22T14:59:13+02:00 Add encodeDouble/Float RTS functions - - - - - 1 changed file: - rts/js/arith.js Changes: ===================================== rts/js/arith.js ===================================== @@ -613,3 +613,19 @@ function h$decodeDoubleInt64(d) { // prim ubx tup returns don't return the first value! RETURN_UBX_TUP3(ret3,ret1,ret2); } + +function h$__int_encodeDouble(j,e) { + return (j|0) ** (e|0); +} + +function h$__word_encodeDouble(j,e) { + return (j>>>0) ** (e|0); +} + +function h$__int_encodeFloat(j,e) { + return h$fround((j|0) ** (e|0)); +} + +function h$__word_encodeFloat(j,e) { + return h$fround((j>>>0) ** (e|0)); +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/390df0aa9e0995c4f68154323e4e94c340781d6e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/390df0aa9e0995c4f68154323e4e94c340781d6e You're receiving 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 Sep 22 13:03:22 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 22 Sep 2022 09:03:22 -0400 Subject: [Git][ghc/ghc][wip/js-staging] encodeDouble: correctly handle 0 base Message-ID: <632c5d1a1b11e_3a3c155181011193a1@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 765da290 by Sylvain Henry at 2022-09-22T15:06:25+02:00 encodeDouble: correctly handle 0 base - - - - - 1 changed file: - rts/js/arith.js Changes: ===================================== rts/js/arith.js ===================================== @@ -615,17 +615,21 @@ function h$decodeDoubleInt64(d) { } function h$__int_encodeDouble(j,e) { + if (!j) return 0; return (j|0) ** (e|0); } function h$__word_encodeDouble(j,e) { + if (!j) return 0; return (j>>>0) ** (e|0); } function h$__int_encodeFloat(j,e) { + if (!j) return 0; return h$fround((j|0) ** (e|0)); } function h$__word_encodeFloat(j,e) { + if (!j) return 0; return h$fround((j>>>0) ** (e|0)); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/765da2901c14e7eae70a2996fc60c71aff3566a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/765da2901c14e7eae70a2996fc60c71aff3566a8 You're receiving 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 Sep 22 13:25:44 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 22 Sep 2022 09:25:44 -0400 Subject: [Git][ghc/ghc][master] Update filepath to filepath-1.4.100.0 Message-ID: <632c625829715_3a3c15513ec11270bb@gitlab.mail> Marge Bot pushed to branch master 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 - - - - - 4 changed files: - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs - libraries/filepath - libraries/template-haskell/template-haskell.cabal.in Changes: ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -81,6 +81,7 @@ stage0Packages = do , directory , process , exceptions + , filepath , ghc , runGhc , ghcBoot @@ -122,7 +123,6 @@ stage1Packages = do , containers , deepseq , exceptions - , filepath , ghc , ghcBignum , ghcCompact ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -213,11 +213,6 @@ packageArgs = do , package hpcBin ? builder (Cabal Flags) ? arg "-build-tool-depends" - --------------------------------- template-haskell ---------------------------------- - - , package templateHaskell - ? mconcat [ builder (Cabal Flags) ? notStage0 ? arg "+vendor-filepath" - , builder Ghc ? notStage0 ? arg ("-i" <> (root pkgPath filepath)) ] ] ghcBignumArgs :: Args ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit 4d7092ad3a8357b18a8fcbeb6fcf38045460eb98 +Subproject commit 872e19fce06ddd40bd0771dbd3cad2c3c6ed5e7d ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -27,14 +27,6 @@ source-repository head location: https://gitlab.haskell.org/ghc/ghc.git subdir: libraries/template-haskell - --- We give the option to vendor filepath to avoid making filepath non-reinstallable.. --- see #21738 for why we are doing this now and what the plan is for the future. -Flag vendor-filepath - Description: Vendor the dependency on filepath - Default: False - Manual: True - Library default-language: Haskell2010 other-extensions: @@ -68,25 +60,16 @@ Library ghc-prim, pretty == 1.1.* - if flag(vendor-filepath) - other-modules: - System.FilePath - System.FilePath.Posix - System.FilePath.Windows - hs-source-dirs: ./vendored-filepath . - default-extensions: - ImplicitPrelude - else - build-depends: filepath - hs-source-dirs: . + other-modules: + System.FilePath + System.FilePath.Posix + System.FilePath.Windows + hs-source-dirs: ./vendored-filepath . + default-extensions: + ImplicitPrelude ghc-options: -Wall -- We need to set the unit ID to template-haskell (without a -- version number) as it's magic. ghc-options: -this-unit-id template-haskell - - -- This should match the default-extensions used in 'ghc.cabal'. This way, - -- GHCi can be used to load it along with the compiler. - Default-Extensions: - NoImplicitPrelude View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9034fadaf641c3821db6e066faaf1a62ed236c13 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9034fadaf641c3821db6e066faaf1a62ed236c13 You're receiving 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 Sep 22 13:26:32 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 22 Sep 2022 09:26:32 -0400 Subject: [Git][ghc/ghc][master] Minor refactor around Outputable Message-ID: <632c628880ae5_3a3c15513c411306c2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 12 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Hs.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Unit/Types.hs-boot - compiler/GHC/Utils/Outputable.hs - − compiler/GHC/Utils/Outputable.hs-boot Changes: ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -1481,28 +1481,28 @@ pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel] -> maybe_underscore $ ftext str <> text "_fast" RtsLabel (RtsSelectorInfoTable upd_reqd offset) - -> maybe_underscore $ hcat [ text "stg_sel_", text (show offset) + -> maybe_underscore $ hcat [ text "stg_sel_", int offset , if upd_reqd then text "_upd_info" else text "_noupd_info" ] RtsLabel (RtsSelectorEntry upd_reqd offset) - -> maybe_underscore $ hcat [ text "stg_sel_", text (show offset) + -> maybe_underscore $ hcat [ text "stg_sel_", int offset , if upd_reqd then text "_upd_entry" else text "_noupd_entry" ] RtsLabel (RtsApInfoTable upd_reqd arity) - -> maybe_underscore $ hcat [ text "stg_ap_", text (show arity) + -> maybe_underscore $ hcat [ text "stg_ap_", int arity , if upd_reqd then text "_upd_info" else text "_noupd_info" ] RtsLabel (RtsApEntry upd_reqd arity) - -> maybe_underscore $ hcat [ text "stg_ap_", text (show arity) + -> maybe_underscore $ hcat [ text "stg_ap_", int arity , if upd_reqd then text "_upd_entry" else text "_noupd_entry" ===================================== compiler/GHC/Cmm/DebugBlock.hs ===================================== @@ -524,7 +524,7 @@ instance OutputableP Platform UnwindExpr where pprUnwindExpr :: Rational -> Platform -> UnwindExpr -> SDoc pprUnwindExpr p env = \case - UwConst i -> ppr i + UwConst i -> int i UwReg g 0 -> ppr g UwReg g x -> pprUnwindExpr p env (UwPlus (UwReg g 0) (UwConst x)) UwDeref e -> char '*' <> pprUnwindExpr 3 env e ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -386,7 +386,7 @@ cmmNativeGens logger config ncgImpl h dbgMap = go let newFileIds = sortBy (comparing snd) $ nonDetEltsUFM $ fileIds' `minusUFM` fileIds -- See Note [Unique Determinism and code generation] - pprDecl (f,n) = text "\t.file " <> ppr n <+> + pprDecl (f,n) = text "\t.file " <> int n <+> pprFilePathString (unpackFS f) emitNativeCode logger config h $ vcat $ ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -373,60 +373,60 @@ pprInstr platform instr = case instr of -- AArch64 Instruction Set -- 1. Arithmetic Instructions ------------------------------------------------ ADD o1 o2 o3 - | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> text "\tfadd" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - | otherwise -> text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - CMN o1 o2 -> text "\tcmn" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfadd") o1 o2 o3 + | otherwise -> op3 (text "\tadd") o1 o2 o3 + CMN o1 o2 -> op2 (text "\tcmn") o1 o2 CMP o1 o2 - | isFloatOp o1 && isFloatOp o2 -> text "\tfcmp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - | otherwise -> text "\tcmp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - MSUB o1 o2 o3 o4 -> text "\tmsub" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 + | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfcmp") o1 o2 + | otherwise -> op2 (text "\tcmp") o1 o2 + MSUB o1 o2 o3 o4 -> op4 (text "\tmsub") o1 o2 o3 o4 MUL o1 o2 o3 - | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> text "\tfmul" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - | otherwise -> text "\tmul" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - SMULH o1 o2 o3 -> text "\tsmulh" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - SMULL o1 o2 o3 -> text "\tsmull" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfmul") o1 o2 o3 + | otherwise -> op3 (text "\tmul") o1 o2 o3 + SMULH o1 o2 o3 -> op3 (text "\tsmulh") o1 o2 o3 + SMULL o1 o2 o3 -> op3 (text "\tsmull") o1 o2 o3 NEG o1 o2 - | isFloatOp o1 && isFloatOp o2 -> text "\tfneg" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - | otherwise -> text "\tneg" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + | isFloatOp o1 && isFloatOp o2 -> op2 (text "\tfneg") o1 o2 + | otherwise -> op2 (text "\tneg") o1 o2 SDIV o1 o2 o3 | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 - -> text "\tfdiv" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - SDIV o1 o2 o3 -> text "\tsdiv" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + -> op3 (text "\tfdiv") o1 o2 o3 + SDIV o1 o2 o3 -> op3 (text "\tsdiv") o1 o2 o3 SUB o1 o2 o3 - | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> text "\tfsub" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - | otherwise -> text "\tsub" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - UDIV o1 o2 o3 -> text "\tudiv" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + | isFloatOp o1 && isFloatOp o2 && isFloatOp o3 -> op3 (text "\tfsub") o1 o2 o3 + | otherwise -> op3 (text "\tsub") o1 o2 o3 + UDIV o1 o2 o3 -> op3 (text "\tudiv") o1 o2 o3 -- 2. Bit Manipulation Instructions ------------------------------------------ - SBFM o1 o2 o3 o4 -> text "\tsbfm" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 - UBFM o1 o2 o3 o4 -> text "\tubfm" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 + SBFM o1 o2 o3 o4 -> op4 (text "\tsbfm") o1 o2 o3 o4 + UBFM o1 o2 o3 o4 -> op4 (text "\tubfm") o1 o2 o3 o4 -- signed and unsigned bitfield extract - SBFX o1 o2 o3 o4 -> text "\tsbfx" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 - UBFX o1 o2 o3 o4 -> text "\tubfx" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 - SXTB o1 o2 -> text "\tsxtb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - UXTB o1 o2 -> text "\tuxtb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - SXTH o1 o2 -> text "\tsxth" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - UXTH o1 o2 -> text "\tuxth" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + SBFX o1 o2 o3 o4 -> op4 (text "\tsbfx") o1 o2 o3 o4 + UBFX o1 o2 o3 o4 -> op4 (text "\tubfx") o1 o2 o3 o4 + SXTB o1 o2 -> op2 (text "\tsxtb") o1 o2 + UXTB o1 o2 -> op2 (text "\tuxtb") o1 o2 + SXTH o1 o2 -> op2 (text "\tsxth") o1 o2 + UXTH o1 o2 -> op2 (text "\tuxth") o1 o2 -- 3. Logical and Move Instructions ------------------------------------------ - AND o1 o2 o3 -> text "\tand" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ANDS o1 o2 o3 -> text "\tands" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ASR o1 o2 o3 -> text "\tasr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - BIC o1 o2 o3 -> text "\tbic" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - BICS o1 o2 o3 -> text "\tbics" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - EON o1 o2 o3 -> text "\teon" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - EOR o1 o2 o3 -> text "\teor" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - LSL o1 o2 o3 -> text "\tlsl" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - LSR o1 o2 o3 -> text "\tlsr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + AND o1 o2 o3 -> op3 (text "\tand") o1 o2 o3 + ANDS o1 o2 o3 -> op3 (text "\tands") o1 o2 o3 + ASR o1 o2 o3 -> op3 (text "\tasr") o1 o2 o3 + BIC o1 o2 o3 -> op3 (text "\tbic") o1 o2 o3 + BICS o1 o2 o3 -> op3 (text "\tbics") o1 o2 o3 + EON o1 o2 o3 -> op3 (text "\teon") o1 o2 o3 + EOR o1 o2 o3 -> op3 (text "\teor") o1 o2 o3 + LSL o1 o2 o3 -> op3 (text "\tlsl") o1 o2 o3 + LSR o1 o2 o3 -> op3 (text "\tlsr") o1 o2 o3 MOV o1 o2 - | isFloatOp o1 || isFloatOp o2 -> text "\tfmov" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - | otherwise -> text "\tmov" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - MOVK o1 o2 -> text "\tmovk" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - MVN o1 o2 -> text "\tmvn" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - ORN o1 o2 o3 -> text "\torn" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ORR o1 o2 o3 -> text "\torr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - ROR o1 o2 o3 -> text "\tror" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - TST o1 o2 -> text "\ttst" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + | isFloatOp o1 || isFloatOp o2 -> op2 (text "\tfmov") o1 o2 + | otherwise -> op2 (text "\tmov") o1 o2 + MOVK o1 o2 -> op2 (text "\tmovk") o1 o2 + MVN o1 o2 -> op2 (text "\tmvn") o1 o2 + ORN o1 o2 o3 -> op3 (text "\torn") o1 o2 o3 + ORR o1 o2 o3 -> op3 (text "\torr") o1 o2 o3 + ROR o1 o2 o3 -> op3 (text "\tror") o1 o2 o3 + TST o1 o2 -> op2 (text "\ttst") o1 o2 -- 4. Branch Instructions ---------------------------------------------------- J t -> pprInstr platform (B t) @@ -459,83 +459,91 @@ pprInstr platform instr = case instr of -- address. Not observing the correct size when loading will lead -- inevitably to crashes. STR _f o1@(OpReg W8 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tstrb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tstrb") o1 o2 STR _f o1@(OpReg W16 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tstrh" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - STR _f o1 o2 -> text "\tstr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tstrh") o1 o2 + STR _f o1 o2 -> op2 (text "\tstr") o1 o2 #if defined(darwin_HOST_OS) LDR _f o1 (OpImm (ImmIndex lbl' off)) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@page" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@pageoff" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl <> text "@page") $$ + op_add o1 (pprAsmLabel platform lbl <> text "@pageoff") $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@gotpageoff" <> text "]" + op_adrp o1 (pprAsmLabel platform lbl <> text "@gotpage") $$ + op_ldr o1 (pprAsmLabel platform lbl <> text "@gotpageoff") LDR _f o1 (OpImm (ImmCLbl lbl)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@page" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl <> text "@pageoff" + op_adrp o1 (pprAsmLabel platform lbl <> text "@page") $$ + op_add o1 (pprAsmLabel platform lbl <> text "@pageoff") + #else LDR _f o1 (OpImm (ImmIndex lbl' off)) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text ":lo12:" <> pprAsmLabel platform lbl $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> char '#' <> int off -- TODO: check that off is in 12bits. + op_adrp o1 (pprAsmLabel platform lbl) $$ + op_add o1 (text ":lo12:" <> pprAsmLabel platform lbl) $$ + op_add o1 (char '#' <> int off) -- TODO: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> text ":got:" <> pprAsmLabel platform lbl $$ - text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> text ":got_lo12:" <> pprAsmLabel platform lbl <> text "]" + op_adrp o1 (text ":got:" <> pprAsmLabel platform lbl) $$ + op_ldr o1 (text ":got_lo12:" <> pprAsmLabel platform lbl) LDR _f o1 (OpImm (ImmCLbl lbl)) -> - text "\tadrp" <+> pprOp platform o1 <> comma <+> pprAsmLabel platform lbl $$ - text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> text ":lo12:" <> pprAsmLabel platform lbl + op_adrp o1 (pprAsmLabel platform lbl) $$ + op_add o1 (text ":lo12:" <> pprAsmLabel platform lbl) + #endif LDR _f o1@(OpReg W8 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tldrb" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tldrb") o1 o2 LDR _f o1@(OpReg W16 (RegReal (RealRegSingle i))) o2 | i < 32 -> - text "\tldrh" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - LDR _f o1 o2 -> text "\tldr" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op2 (text "\tldrh") o1 o2 + LDR _f o1 o2 -> op2 (text "\tldr") o1 o2 - STP _f o1 o2 o3 -> text "\tstp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 - LDP _f o1 o2 o3 -> text "\tldp" <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + STP _f o1 o2 o3 -> op3 (text "\tstp") o1 o2 o3 + LDP _f o1 o2 o3 -> op3 (text "\tldp") o1 o2 o3 -- 8. Synchronization Instructions ------------------------------------------- DMBSY -> text "\tdmb sy" -- 9. Floating Point Instructions -------------------------------------------- - FCVT o1 o2 -> text "\tfcvt" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - SCVTF o1 o2 -> text "\tscvtf" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - FCVTZS o1 o2 -> text "\tfcvtzs" <+> pprOp platform o1 <> comma <+> pprOp platform o2 - FABS o1 o2 -> text "\tfabs" <+> pprOp platform o1 <> comma <+> pprOp platform o2 + FCVT o1 o2 -> op2 (text "\tfcvt") o1 o2 + SCVTF o1 o2 -> op2 (text "\tscvtf") o1 o2 + FCVTZS o1 o2 -> op2 (text "\tfcvtzs") o1 o2 + FABS o1 o2 -> op2 (text "\tfabs") o1 o2 + where op2 op o1 o2 = op <+> pprOp platform o1 <> comma <+> pprOp platform o2 + op3 op o1 o2 o3 = op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 + op4 op o1 o2 o3 o4 = op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4 + op_ldr o1 rest = text "\tldr" <+> pprOp platform o1 <> comma <+> text "[" <> pprOp platform o1 <> comma <+> rest <> text "]" + op_adrp o1 rest = text "\tadrp" <+> pprOp platform o1 <> comma <+> rest + op_add o1 rest = text "\tadd" <+> pprOp platform o1 <> comma <+> pprOp platform o1 <> comma <+> rest pprBcond :: Cond -> SDoc pprBcond c = text "b." <> pprCond c ===================================== compiler/GHC/Core/Coercion/Axiom.hs ===================================== @@ -485,7 +485,7 @@ instance Outputable CoAxBranch where , cab_lhs = lhs , cab_rhs = rhs }) = text "CoAxBranch" <+> parens (ppr loc) <> colon - <+> brackets (fsep (punctuate comma (map pprType lhs))) + <+> brackets (pprWithCommas pprType lhs) <+> text "=>" <+> pprType rhs {- ===================================== compiler/GHC/Hs.hs ===================================== @@ -124,7 +124,7 @@ instance Outputable (HsModule GhcPs) where Nothing -> pp_header (text "where") Just es -> vcat [ pp_header lparen, - nest 8 (fsep (punctuate comma (map ppr (unLoc es)))), + nest 8 (pprWithCommas ppr (unLoc es)), nest 4 (text ") where") ], pp_nonnull imports, ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1691,7 +1691,7 @@ instance DisambECP (HsCmd GhcPs) where mkHsWildCardPV l = cmdFail l (text "_") mkHsTySigPV l a sig _ = cmdFail (locA l) (ppr a <+> text "::" <+> ppr sig) mkHsExplicitListPV l xs _ = cmdFail l $ - brackets (fsep (punctuate comma (map ppr xs))) + brackets (pprWithCommas ppr xs) mkHsSplicePV (L l sp) = cmdFail l (pprUntypedSplice True Nothing sp) mkHsRecordPV _ l _ a (fbinds, ddLoc) _ = do let (fs, ps) = partitionEithers fbinds ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -489,8 +489,7 @@ addHoleFitDocs fits = { let warning = text "WARNING: Couldn't find any documentation for the following modules:" $+$ nest 2 - (fsep (punctuate comma - (either text ppr <$> Set.toList mods)) $+$ + (pprWithCommas (either text ppr) (Set.toList mods) $+$ text "Make sure the modules are compiled with '-haddock'.") ; warnPprTrace (not $ Set.null mods)"addHoleFitDocs" warning (pure ()) } ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -366,7 +366,7 @@ pprAvail :: AvailInfo -> SDoc pprAvail (Avail n) = ppr n pprAvail (AvailTC n ns) - = ppr n <> braces (fsep (punctuate comma (map ppr ns))) + = ppr n <> braces (pprWithCommas ppr ns) instance Binary AvailInfo where put_ bh (Avail aa) = do ===================================== compiler/GHC/Unit/Types.hs-boot ===================================== @@ -2,7 +2,6 @@ module GHC.Unit.Types where import GHC.Prelude () -import {-# SOURCE #-} GHC.Utils.Outputable import Language.Haskell.Syntax.Module.Name (ModuleName) import Data.Kind (Type) @@ -15,4 +14,3 @@ type Unit = GenUnit UnitId moduleName :: GenModule a -> ModuleName moduleUnit :: GenModule a -> a -pprModule :: Module -> SDoc ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -944,16 +944,16 @@ instance Outputable UTCTime where ppr = text . formatShow iso8601Format instance (Outputable a) => Outputable [a] where - ppr xs = brackets (fsep (punctuate comma (map ppr xs))) + ppr xs = brackets (pprWithCommas ppr xs) instance (Outputable a) => Outputable (NonEmpty a) where ppr = ppr . NEL.toList instance (Outputable a) => Outputable (Set a) where - ppr s = braces (fsep (punctuate comma (map ppr (Set.toList s)))) + ppr s = braces (pprWithCommas ppr (Set.toList s)) instance Outputable IntSet.IntSet where - ppr s = braces (fsep (punctuate comma (map ppr (IntSet.toList s)))) + ppr s = braces (pprWithCommas ppr (IntSet.toList s)) instance (Outputable a, Outputable b) => Outputable (a, b) where ppr (x,y) = parens (sep [ppr x <> comma, ppr y]) ===================================== compiler/GHC/Utils/Outputable.hs-boot deleted ===================================== @@ -1,9 +0,0 @@ -module GHC.Utils.Outputable where - -import GHC.Prelude - -data SDoc -data PprStyle -data SDocContext - -text :: String -> SDoc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/615e22789a04e74d7e02239b4580b95b077c3ae0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/615e22789a04e74d7e02239b4580b95b077c3ae0 You're receiving 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 Sep 22 16:51:49 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 22 Sep 2022 12:51:49 -0400 Subject: [Git][ghc/ghc][wip/T21623] 2 commits: Fix fragile rule setup in GHC.Float Message-ID: <632c92a536451_3a3c155182411489c8@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: be252113 by Simon Peyton Jones at 2022-09-22T17:52:50+01:00 Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] - - - - - d3fb90e8 by Simon Peyton Jones at 2022-09-22T17:53:43+01:00 Wibbles - - - - - 6 changed files: - compiler/GHC/Tc/TyCl/Utils.hs - libraries/base/GHC/Float.hs - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - testsuite/tests/ghci/scripts/T16575.stdout - testsuite/tests/typecheck/should_compile/T17021a.hs Changes: ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -85,6 +85,8 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Control.Monad +import GHC.Utils.Trace + {- ************************************************************************ * * @@ -885,7 +887,8 @@ mkRecSelBind (tycon, fl) mkOneRecordSelector :: [ConLike] -> RecSelParent -> FieldLabel -> FieldSelectors -> (Id, LHsBind GhcRn) mkOneRecordSelector all_cons idDetails fl has_sel - = (sel_id, L (noAnnSrcSpan loc) sel_bind) + = pprTrace "mkOneRec" (ppr con1 $$ ppr sel_name $$ ppr field_ty $$ ppr data_ty $$ ppr is_naughty) + (sel_id, L (noAnnSrcSpan loc) sel_bind) where loc = getSrcSpan sel_name loc' = noAnnSrcSpan loc @@ -902,13 +905,16 @@ mkOneRecordSelector all_cons idDetails fl has_sel con1 = assert (not (null cons_w_field)) $ head cons_w_field -- Selector type; Note [Polymorphic selectors] - field_ty = conLikeFieldType con1 lbl - data_tv_set= tyCoVarsOfType data_ty - data_tvbs = filter (\tvb -> binderVar tvb `elemVarSet` data_tv_set) $ - conLikeUserTyVarBinders con1 + field_ty = conLikeFieldType con1 lbl + data_tv_set = tyCoVarsOfTypes (data_ty : req_theta) + data_tvbs = filter (\tvb -> binderVar tvb `elemVarSet` data_tv_set) $ + conLikeUserTyVarBinders con1 + -- is_naughty: see Note [Naughty record selectors] is_naughty = not (tyCoVarsOfType field_ty `subVarSet` data_tv_set) - || has_sel == NoFieldSelectors + || has_sel == NoFieldSelectors -- No field selectors => all are naughty + -- thus suppressing making a binding + -- A slight hack! sel_ty | is_naughty = unitTy -- See Note [Naughty record selectors] | otherwise = mkForAllTys (tyVarSpecToBinders data_tvbs) $ ===================================== libraries/base/GHC/Float.hs ===================================== @@ -345,7 +345,8 @@ instance Fractional Float where recip x = 1.0 / x rationalToFloat :: Integer -> Integer -> Float -{-# NOINLINE [1] rationalToFloat #-} +{-# NOINLINE [0] rationalToFloat #-} +-- Re NOINLINE pragma, see Note [realToFrac natural-to-float] rationalToFloat n 0 | n == 0 = 0/0 | n < 0 = (-1)/0 @@ -577,7 +578,8 @@ instance Fractional Double where recip x = 1.0 / x rationalToDouble :: Integer -> Integer -> Double -{-# NOINLINE [1] rationalToDouble #-} +{-# NOINLINE [0] rationalToDouble #-} +-- Re NOINLINE pragma, see Note [realToFrac natural-to-float] rationalToDouble n 0 | n == 0 = 0/0 | n < 0 = (-1)/0 @@ -1488,6 +1490,25 @@ with the native backend, and 0.143 seconds with the C backend. A few more details in #2251, and the patch message "Add RULES for realToFrac from Int". + +Note [realToFrac natural-to-float] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (realToFrac @Natural @Float ..dicts.. (NS lit#)) +We want to constant-fold this. For many types this is guaranteed +by a RULE for realToFrac: eg. RULE "realToFrac/Float->Double" above. + +In case there is a similar rule, we do not inline realToFrac in stage 2. +But for whatever reason, there is no such RULE for Natural. So in stage 1 +we end up with + rationalToFloat (integerFromNatural (NS lit)) +and that turns into + rationalToFloat (IS lit#) (IS 1#) + +Now we'd have a BUILTIN constant folding rule for rationalToFloat; but +to allow that rule to fire reliably we should delay inlining rationalToFloat +until stage 0. (It may get an inlining from CPR analysis.) + +Hence the NOINLINE[0] rationalToFloat, and similarly rationalToDouble. -} -- Utils ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -61,6 +61,7 @@ GHC.Core.SimpleOpt GHC.Core.Stats GHC.Core.Subst GHC.Core.Tidy +GHC.Core.TyCo.Compare GHC.Core.TyCo.FVs GHC.Core.TyCo.Ppr GHC.Core.TyCo.Rep ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -61,6 +61,7 @@ GHC.Core.SimpleOpt GHC.Core.Stats GHC.Core.Subst GHC.Core.Tidy +GHC.Core.TyCo.Compare GHC.Core.TyCo.FVs GHC.Core.TyCo.Ppr GHC.Core.TyCo.Rep ===================================== testsuite/tests/ghci/scripts/T16575.stdout ===================================== @@ -1,5 +1,9 @@ +Loaded package environment from /home/simonpj/.ghc/x86_64-linux-9.5.20220920/environments/default +GHCi, version 9.5.20220920: https://www.haskell.org/ghc/ :? for help +ghci> ghci> [1 of 1] Compiling Ghost ( T16575.hs, interpreted ) +Ok, one module loaded. Collecting type info for 1 module(s) ... -T16575.hs:(4,15)-(4,18): GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS +ghci> T16575.hs:(4,15)-(4,18): GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS T16575.hs:(4,15)-(4,18): Ghost.X -> GHC.Base.String T16575.hs:(4,15)-(4,18): [Ghost.X] -> GHC.Show.ShowS T16575.hs:(7,7)-(7,8): Ghost.X -> Ghost.X -> GHC.Types.Bool @@ -25,5 +29,6 @@ T16575.hs:(8,5)-(8,5): Ghost.X T16575.hs:(8,10)-(8,10): Ghost.X T16575.hs:(9,5)-(9,5): Ghost.X T16575.hs:(9,10)-(9,10): Ghost.X - :: [X] -> ShowS - :: X -> X -> Bool +ghci> ghci> ghci> ghci> ghci> :: [X] -> ShowS +ghci> ghci> ghci> ghci> ghci> ghci> :: X -> X -> Bool +ghci> ghci> ghci> ghci> ghci> Leaving GHCi. ===================================== testsuite/tests/typecheck/should_compile/T17021a.hs ===================================== @@ -12,7 +12,7 @@ type family Id x where --type LevId :: TYPE (Id LiftedRep) -> TYPE (Id LiftedRep) --newtype LevId x = MkLevId x -otype LevId2 :: (r ~ Id LiftedRep) => TYPE r -> TYPE r +type LevId2 :: (r ~ Id LiftedRep) => TYPE r -> TYPE r newtype LevId2 x = MkLevId2 x {- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/883cb4793c9f65f82dec512a28639dacec77dc39...d3fb90e8c932fc792793401b199fca50f9db840b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/883cb4793c9f65f82dec512a28639dacec77dc39...d3fb90e8c932fc792793401b199fca50f9db840b You're receiving 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 Sep 22 21:18:30 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 22 Sep 2022 17:18:30 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <632cd126cd8da_3a3c15518101173266@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 42383304 by Andreas Klebinger at 2022-09-22T23:17:05+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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 - - - - - 7 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,9 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +98,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +268,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1866,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1915,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1934,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2725,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> (LResult a)) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2884,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2937,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2968,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2984,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3024,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3040,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3060,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -177,6 +178,7 @@ import GHC.Unit.Module import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import qualified Data.Data as Data +import GHC.Data.Unboxed {- ----------------------------------------------- @@ -2521,12 +2523,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2540,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,9 +295,11 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S +import GHC.Utils.Trace -- import GHC.Utils.Trace -- $type_classification @@ -556,7 +559,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2790,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [nonDetCmpType and type object pointer comparison] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by the same heap +object. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2813,14 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + | 1# <- reallyUnsafePtrEquality# t1 t2 + = pprTrace "typeShortCut" (ppr t1) EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,53 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/423833042ebb2a5b14e89845539feb524d6be447 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/423833042ebb2a5b14e89845539feb524d6be447 You're receiving 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 Sep 22 21:28:42 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 22 Sep 2022 17:28:42 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <632cd38a51060_3a3c15514001176981@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 9344e29c by Andreas Klebinger at 2022-09-22T23:27:37+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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 - - - - - 7 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,9 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +98,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +268,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1866,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1915,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1934,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2725,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> (LResult a)) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2884,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2937,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2968,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2984,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3024,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3040,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3060,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -177,6 +178,7 @@ import GHC.Unit.Module import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import qualified Data.Data as Data +import GHC.Data.Unboxed {- ----------------------------------------------- @@ -2521,12 +2523,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2540,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,9 +295,11 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S +import GHC.Utils.Trace -- import GHC.Utils.Trace -- $type_classification @@ -556,7 +559,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2790,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [nonDetCmpType and type object pointer comparison] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by the same heap +object. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2813,14 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,52 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9344e29c5ce637f2a6be1a1fb078c87f8717b80d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9344e29c5ce637f2a6be1a1fb078c87f8717b80d You're receiving 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 Sep 22 21:41:01 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 22 Sep 2022 17:41:01 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <632cd66d7fe4f_3a3c155184c11790f9@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: c1f2df48 by Andreas Klebinger at 2022-09-22T23:39:53+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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 - - - - - 7 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,9 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +98,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +268,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1866,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1915,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1934,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2725,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> (LResult a)) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2884,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2937,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2968,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2984,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3024,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3040,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3060,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -2521,12 +2522,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,9 +295,11 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S +import GHC.Utils.Trace -- import GHC.Utils.Trace -- $type_classification @@ -556,7 +559,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2790,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [nonDetCmpType and type object pointer comparison] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by the same heap +object. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2813,14 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,52 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1f2df48fa78d420be637a38c6ca7b96e2c557a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1f2df48fa78d420be637a38c6ca7b96e2c557a4 You're receiving 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 Sep 22 22:10:20 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 22 Sep 2022 18:10:20 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <632cdd4c9aec9_3a3c155184c11820bb@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 35643f4e by Andreas Klebinger at 2022-09-23T00:09:14+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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 - - - - - 7 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,9 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +98,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +268,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1866,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1915,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1934,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2725,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> (LResult a)) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2884,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2937,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2968,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2984,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3024,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3040,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3060,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -2521,12 +2522,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,10 +295,10 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S --- import GHC.Utils.Trace -- $type_classification -- #type_classification# @@ -556,7 +557,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2788,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [nonDetCmpType and type object pointer comparison] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by the same heap +object. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2811,14 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,52 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35643f4e0930909e3aa40069e9af36b476c73498 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/35643f4e0930909e3aa40069e9af36b476c73498 You're receiving 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 Sep 23 10:10:14 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 23 Sep 2022 06:10:14 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: JS.Primops: Add listThreads op Message-ID: <632d8606d8e32_3a3c15514f01253042@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 3854b21f by doyougnu at 2022-09-23T06:09:44-04:00 JS.Primops: Add listThreads op - - - - - 6b188264 by doyougnu at 2022-09-23T06:09:48-04:00 JS.Primops: Add Read/WriteAddrOp ops - - - - - 1 changed file: - compiler/GHC/StgToJS/Prim.hs Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -928,6 +928,7 @@ genPrim prof ty op = case op of IsCurrentThreadBoundOp -> \[r] [] -> PrimInline $ r |= one_ NoDuplicateOp -> \[] [] -> PrimInline mempty -- don't need to do anything as long as we have eager blackholing ThreadStatusOp -> \[stat,cap,locked] [tid] -> PrimInline $ appT [stat, cap, locked] "h$threadStatus" [tid] + ListThreadsOp -> \[r] [] -> PrimInline $ r |= var "h$threads" ------------------------------- Weak Pointers ----------------------------------- @@ -1199,12 +1200,6 @@ genPrim prof ty op = case op of FetchOrAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BOr r a o v FetchXorAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BXor r a o v - ------------------------------- Unhandled primops ------------------- - - ShrinkSmallMutableArrayOp_Char -> unhandledPrimop op - GetSizeofSmallMutableArrayOp -> unhandledPrimop op - InterlockedExchange_Addr -> \[r_a,r_o] [a1,o1,a2,o2] -> PrimInline $ mconcat [ r_a |= a1 , r_o |= o1 @@ -1217,8 +1212,14 @@ genPrim prof ty op = case op of ] - AtomicReadAddrOp_Word -> unhandledPrimop op - AtomicWriteAddrOp_Word -> unhandledPrimop op +------------------------------ Unhandled primops ------------------- + + ShrinkSmallMutableArrayOp_Char -> unhandledPrimop op + GetSizeofSmallMutableArrayOp -> unhandledPrimop op + + + AtomicReadAddrOp_Word -> \[r] [a,o] -> PrimInline $ r |= dv_u32 a o + AtomicWriteAddrOp_Word -> \[] [a,o,w] -> PrimInline $ dv_s_u32 a o w NewIOPortOp -> unhandledPrimop op ReadIOPortOp -> unhandledPrimop op @@ -1235,7 +1236,6 @@ genPrim prof ty op = case op of SetThreadAllocationCounter -> unhandledPrimop op GetThreadLabelOp -> unhandledPrimop op - ListThreadsOp -> unhandledPrimop op LabelThreadOp -> unhandledPrimop op -- \[] [t,la,lo] -> PrimInline $ t .^ "label" |= ValExpr (JList [la, lo]) ------------------------------- Vector ----------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/765da2901c14e7eae70a2996fc60c71aff3566a8...6b188264d4000c0698d73219ba0016edd27c2dbb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/765da2901c14e7eae70a2996fc60c71aff3566a8...6b188264d4000c0698d73219ba0016edd27c2dbb You're receiving 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 Sep 23 11:28:00 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 23 Sep 2022 07:28:00 -0400 Subject: [Git][ghc/ghc][wip/js-staging] JS: Linker and Compactor: cleanup and docs Message-ID: <632d984055479_3a3c15514f0125741e@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 720c6576 by doyougnu at 2022-09-23T07:27:30-04:00 JS: Linker and Compactor: cleanup and docs Compactor: Cleanup: Remove dead comments JS.Linker.Types: cleanup and document module - - - - - 2 changed files: - compiler/GHC/StgToJS/Linker/Compactor.hs - compiler/GHC/StgToJS/Linker/Types.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Compactor.hs ===================================== @@ -6,7 +6,7 @@ ----------------------------------------------------------------------------- -- | --- Module : GHC.StgToJS.Linker +-- Module : GHC.StgToJS.Linker.Compactor -- Copyright : (c) The University of Glasgow 2001 -- License : BSD-style (see the file LICENSE) -- @@ -23,10 +23,10 @@ -- - rewrite all variables starting with h$$ to shorter names, these are internal names -- - write all function metadata compactly -- --- TODO: Jeff (2022,03): I've adapted this to ghcHEAD but have not actually --- implemented the compactor. The key work function is @packString@ which --- currently explodes if called. The todo is to fix this, and actually implement --- the compactor once we have a linker that actually works. +-- Note: - This module is not yet complete (as of 23/09/2022), for the complete +-- version to adapt see GHCJS's Gen2/Compactor.hs module. For now we have only +-- the functions that constitue the API for the module so that the JS Backend +-- Linker and RTS can compile and run. ----------------------------------------------------------------------------- module GHC.StgToJS.Linker.Compactor @@ -102,181 +102,6 @@ packStrings :: HasDebugCallStack -> [LinkedUnit] -> (CompactorState, [LinkedUnit]) packStrings _settings _cstate _code = panic "Compactor.packstrings not yet implemented!" - -- let allStatics :: [StaticInfo] - -- allStatics = concatMap (\(_,_,x) -> x) code - - -- origStringTable :: StringTable - -- origStringTable = cstate ^. stringTable - - -- allStrings :: Set ByteString - -- allStrings = S.fromList $ - -- filter (not . isExisting) - -- (mapMaybe (staticString . siVal) allStatics) - -- where - -- isExisting bs = isJust (M.lookup bs $ stOffsets origStringTable) - - -- staticString :: StaticVal -> Maybe ByteString - -- staticString (StaticUnboxed (StaticUnboxedString bs)) = Just bs - -- staticString (StaticUnboxed (StaticUnboxedStringOffset bs)) = Just bs - -- staticString _ = Nothing - - -- allStringsList :: [ByteString] - -- allStringsList = S.toList allStrings - - -- -- we may see two kinds of null characters - -- -- - string separator, packed as \0 - -- -- - within a string, packed as \cz\0 - -- -- we transform the strings to - -- transformPackedLiteral :: ShortText -> ShortText - -- transformPackedLiteral = mconcat. fmap f - -- where - -- f :: Char -> ShortText - -- f '\0' = "\^Z\0" - -- f '\^Z' = "\^Z\^Z" - -- f x = x - - -- allStringsPacked :: ShortText - -- allStringsPacked = T.intercalate "\0" $ - -- map (\str -> maybe (packBase64 str) - -- transformPackedLiteral - -- (U.decodeModifiedUTF8 str)) - -- allStringsList - - -- packBase64 :: ByteString -> ShortText - -- packBase64 bs - -- | BS.null bs = mempty - -- | otherwise = - -- let (h,t) = BS.splitAt 128 bs - -- esc = T.singleton '\^Z' <> - -- T.singleton (chr . fromIntegral $ BS.length h + 0x1f) - -- b64 = esc <> fromJust (U.decodeModifiedUTF8 (B64.encode h)) - -- in maybe b64 transformPackedLiteral (U.decodeModifiedUTF8 h) <> - -- packBase64 t - - -- allStringsWithOffset :: [(ByteString, Int)] - -- allStringsWithOffset = snd $ - -- mapAccumL (\o b -> let o' = o + fromIntegral (BS.length b) + 1 - -- in o' `seq` (o', (b, o))) - -- 0 - -- allStringsList - - -- -- the offset of each of the strings in the big blob - -- offsetIndex :: HashMap ByteString Int - -- offsetIndex = M.fromList allStringsWithOffset - - -- stringSymbol :: Ident - -- stringSymbol = head $ cstate ^. identSupply - - -- stringSymbolT :: ShortText - -- stringSymbolT = let (TxtI t) = stringSymbol in t - - -- stringSymbolIdx :: Int - -- stringSymbolIdx = snd (bounds $ stTableIdents origStringTable) + 1 - - -- -- append the new string symbol - -- newTableIdents :: Array Int ShortText - -- newTableIdents = - -- listArray (0, stringSymbolIdx) - -- (elems (stTableIdents origStringTable) ++ [stringSymbolT]) - - -- newOffsetsMap :: Map ByteString (Int, Int) - -- newOffsetsMap = M.union (stOffsets origStringTable) - -- (fmap (stringSymbolIdx,) offsetIndex) - - -- newIdentsMap :: HashMap ShortText (Either Int Int) - -- newIdentsMap = - -- let f (StaticInfo s (StaticUnboxed (StaticUnboxedString bs)) _) - -- = Just (s, Left . fst $ newOffsetsMap M.! bs) - -- f (StaticInfo s (StaticUnboxed (StaticUnboxedStringOffset bs)) _) - -- = Just (s, Right . snd $ newOffsetsMap M.! bs) - -- f _ = Nothing - -- in M.union (stIdents origStringTable) - -- (M.fromList $ mapMaybe f allStatics) - - -- newStringTable :: StringTable - -- newStringTable = StringTable newTableIdents newOffsetsMap newIdentsMap - - -- newOffsetsInverted :: HashMap (Int, Int) ByteString - -- newOffsetsInverted = M.fromList . - -- map (\(x,y) -> (y,x)) . - -- M.toList $ - -- newOffsetsMap - - -- replaceSymbol :: ShortText -> Maybe JVal - -- replaceSymbol t = - -- let f (Left i) = JVar (TxtI $ newTableIdents ! i) - -- f (Right o) = JInt (fromIntegral o) - -- in fmap f (M.lookup t newIdentsMap) - - -- cstate0 :: CompactorState - -- cstate0 = cstate & identSupply %~ tail - -- & stringTable .~ newStringTable - - -- initStr :: JStat - -- initStr = - -- DeclStat stringSymbol <> - -- AssignStat (ValExpr $ JVar stringSymbol) - -- (ApplExpr (ApplExpr (ValExpr $ JVar (TxtI "h$pstr")) - -- [ValExpr (JStr allStringsPacked)]) - -- []) - - -- rewriteValsE :: JExpr -> JExpr - -- rewriteValsE (ApplExpr e xs) - -- | Just t <- appMatchStringLit e xs = ValExpr (JStr t) - -- rewriteValsE (ValExpr v) = ValExpr (rewriteVals v) - -- rewriteValsE e = e & exprsE %~ rewriteValsE - - -- rewriteVals :: JVal -> JVal - -- rewriteVals (JVar (TxtI t)) - -- | Just v <- replaceSymbol t = v - -- rewriteVals (JList es) = JList (map rewriteValsE es) - -- rewriteVals (JHash m) = JHash (fmap rewriteValsE m) - -- rewriteVals (JFunc args body) = JFunc args (body & exprsS %~ rewriteValsE) - -- rewriteVals v = v - - -- rewriteStat :: JStat -> JStat - -- rewriteStat st = st & exprsS %~ rewriteValsE - - -- appMatchStringLit :: JExpr -> [JExpr] -> Maybe ShortText - -- appMatchStringLit (ValExpr (JVar (TxtI "h$decodeUtf8z"))) - -- [ValExpr (JVar (TxtI x)), ValExpr (JVar (TxtI y))] - -- | Just (Left i) <- M.lookup x newIdentsMap - -- , Just (Right j) <- M.lookup y newIdentsMap - -- , Just bs <- M.lookup (i,j) newOffsetsInverted = - -- U.decodeModifiedUTF8 bs - -- appMatchStringLit _ _ = Nothing - - -- rewriteStatic :: StaticInfo -> Maybe StaticInfo - -- rewriteStatic (StaticInfo _i - -- (StaticUnboxed StaticUnboxedString{}) - -- _cc) = - -- Nothing - -- rewriteStatic (StaticInfo _i - -- (StaticUnboxed StaticUnboxedStringOffset {}) - -- _cc) = - -- Nothing - -- rewriteStatic si = Just (si & staticInfoArgs %~ rewriteStaticArg) - - -- rewriteStaticArg :: StaticArg -> StaticArg - -- rewriteStaticArg a@(StaticObjArg t) = - -- case M.lookup t newIdentsMap of - -- Just (Right v) -> StaticLitArg (IntLit $ fromIntegral v) - -- Just (Left idx) -> StaticObjArg (newTableIdents ! idx) - -- _ -> a - -- rewriteStaticArg (StaticConArg v es) - -- = StaticConArg v (map rewriteStaticArg es) - -- rewriteStaticArg x = x - - -- initStatic :: LinkedUnit - -- initStatic = - -- let (TxtI ss) = stringSymbol - -- in (initStr, [], [StaticInfo ss (StaticThunk Nothing) Nothing]) - - -- rewriteBlock :: LinkedUnit -> LinkedUnit - -- rewriteBlock (stat, ci, si) - -- = (rewriteStat stat, ci, mapMaybe rewriteStatic si) - - -- in (cstate0, initStatic : map rewriteBlock code) renameInternals :: HasDebugCallStack => JSLinkConfig @@ -294,7 +119,6 @@ renameInternals ln_cfg cfg cs0 rtsDeps stats0a = (cs, stats, meta) renamed :: State CompactorState ([JStat], JStat) renamed - -- \| csDebugAlloc cfg || csProf cfg = do | True = do cs <- get @@ -309,65 +133,6 @@ renameInternals ln_cfg cfg cs0 rtsDeps stats0a = (cs, stats, meta) mconcat (map (staticInitStat $ csProf cfg) statics) <> mconcat (map (closureInfoStat True) infos) return (renamedStats, meta) - {- - | otherwise = do - -- collect all global objects and entries, add them to the renaming table - mapM_ (\(_, cis, sis) -> do - mapM_ (renameEntry . TxtI . ciVar) cis - mapM_ (renameObj . siVar) sis - mapM_ collectLabels sis) stats0 - - -- sort our entries, store the results - -- propagate all renamings throughtout the code - cs <- get - -- Safari on iOS 10 (64 bit only?) crashes on very long arrays - -- safariCrashWorkaround :: [Ident] -> JExpr - -- safariCrashWorkaround xs = - -- case chunksOf 10000 xs of - -- (y:ys) | not (null ys) - -- -> ApplExpr (SelExpr (toJExpr y) (TxtI "concat")) - -- (map toJExpr ys) - -- _ -> toJExpr xs - let renamedStats = map (\(s,_,_) -> identsS' (lookupRenamed cs) s) - stats0 - sortedInfo = concatMap (\(_,xs,_) -> map (renameClosureInfo cs) - xs) - stats0 - -- entryArr = safariCrashWorkaround $ - entryArr = toJExpr - . map (TxtI . fst) - . List.sortBy (compare `on` snd) - . M.toList - $ csEntries cs - lblArr = map (TxtI . fst) - . List.sortBy (compare `on` snd) - . M.toList - $ csLabels cs - ss = concatMap (\(_,_,xs) -> map (renameStaticInfo cs) xs) - stats0 - infoBlock = encodeStr (concatMap (encodeInfo cs) sortedInfo) - staticBlock = encodeStr (concatMap (encodeStatic cs) ss) - stbs' = identsS' (lookupRenamed cs) stbs - staticDecls = mconcat (map staticDeclStat ss) <> stbs' - meta = staticDecls `mappend` - appS "h$scheduleInit" [ entryArr - , var "h$staticDelayed" - , toJExpr lblArr - , toJExpr infoBlock - , toJExpr staticBlock - ] - -- error "scheduleInit" - {- - [j| h$scheduleInit( `entryArr` - , h$staticDelayed - , `lblArr` - , `infoBlock` - , `staticBlock`); - h$staticDelayed = []; - |] -} - - return (renamedStats, meta) - -} -- | initialize a global object. all global objects have to be declared (staticInfoDecl) first -- (this is only used with -debug, normal init would go through the static data table) @@ -413,28 +178,6 @@ renameObj xs = do modify (addStaticEntry xs') -- and now the table return xs' -{- -renameEntry :: Ident - -> State CompactorState Ident -renameEntry i = do - i'@(TxtI i'') <- renameVar i - modify (addEntry i'') - return i' - -collectLabels :: StaticInfo -> State CompactorState () -collectLabels si = mapM_ go (labelsV . siVal $ si) - where - go :: FastString -> State CompactorState () - go = modify . addLabel - labelsV (StaticData _ args) = concatMap labelsA args - labelsV (StaticList args _) = concatMap labelsA args - labelsV _ = [] - labelsA (StaticLitArg l) = labelsL l - labelsA _ = [] - labelsL (LabelLit _ lbl) = [lbl] - labelsL _ = [] --} - lookupRenamed :: CompactorState -> Ident -> Ident lookupRenamed cs i@(TxtI t) = fromMaybe i (lookupUniqMap (csNameMap cs) t) @@ -494,244 +237,11 @@ staticIdentsV f (StaticData con args) = StaticData (f con) (staticIdentsA f <$> staticIdentsV f (StaticList xs t) = StaticList (staticIdentsA f <$> xs) (f <$> t) staticIdentsV _ x = x --- staticIdentsA :: Traversal' StaticArg ShortText staticIdentsA :: (FastString -> FastString) -> StaticArg -> StaticArg staticIdentsA f (StaticObjArg t) = StaticObjArg $! f t staticIdentsA _ x = x -{- -{- - simple encoding of naturals using only printable low char points, - rely on gzip to compress repeating sequences, - most significant bits first - 1 byte: ascii code 32-123 (0-89), \ and " unused - 2 byte: 124 a b (90-8189) - 3 byte: 125 a b c (8190-737189) --} -encodeStr :: HasDebugCallStack => [Int] -> String -encodeStr = concatMap encodeChr - where - c :: HasDebugCallStack => Int -> Char - c i | i > 90 || i < 0 = error ("encodeStr: c " ++ show i) - | i >= 59 = chr (34+i) - | i >= 2 = chr (33+i) - | otherwise = chr (32+i) - encodeChr :: HasDebugCallStack => Int -> String - encodeChr i - | i < 0 = panic "encodeStr: negative" - | i <= 89 = [c i] - | i <= 8189 = let (c1, c2) = (i - 90) `divMod` 90 in [chr 124, c c1, c c2] - | i <= 737189 = let (c2a, c3) = (i - 8190) `divMod` 90 - (c1, c2) = c2a `divMod` 90 - in [chr 125, c c1, c c2, c c3] - | otherwise = panic "encodeStr: overflow" - -entryIdx :: HasDebugCallStack - => String - -> CompactorState - -> FastString - -> Int -entryIdx msg cs i = fromMaybe lookupParent (lookupUniqMap (csEntries cs) i') - where - (TxtI i') = lookupRenamed cs (TxtI i) - lookupParent = maybe err - (+ csNumEntries cs) - (lookupUniqMap (csParentEntries cs) i') - err = panic (msg ++ ": invalid entry: " ++ unpackFS i') - -objectIdx :: HasDebugCallStack - => String - -> CompactorState - -> FastString - -> Int -objectIdx msg cs i = fromMaybe lookupParent (lookupUniqMap (csStatics cs) i') - where - (TxtI i') = lookupRenamed cs (TxtI i) - lookupParent = maybe err - (+ csNumStatics cs) - (lookupUniqMap (csParentStatics cs) i') - err = panic (msg ++ ": invalid static: " ++ unpackFS i') - -labelIdx :: HasDebugCallStack - => String - -> CompactorState - -> FastString - -> Int -labelIdx msg cs l = fromMaybe lookupParent (lookupUniqMap (csLabels cs) l) - where - lookupParent = maybe err - (+ csNumLabels cs) - (lookupUniqMap (csParentLabels cs) l) - err = panic (msg ++ ": invalid label: " ++ unpackFS l) - -encodeInfo :: HasDebugCallStack - => CompactorState - -> ClosureInfo -- ^ information to encode - -> [Int] -encodeInfo cs (ClosureInfo _var regs name layout typ static) - | CIThunk <- typ = 0 : ls - | (CIFun _arity regs0) <- typ, regs0 /= argSize regs - = panic ("encodeInfo: inconsistent register metadata for " ++ unpackFS name) - | (CIFun arity _regs0) <- typ = [1, arity, encodeRegs regs] ++ ls - | (CICon tag) <- typ = [2, tag] ++ ls - | CIStackFrame <- typ = [3, encodeRegs regs] ++ ls --- (CIPap ar) <- typ = [4, ar] ++ ls -- these should only appear during runtime - | otherwise = panic $ - "encodeInfo, unexpected closure type: " ++ show typ - where - ls = encodeLayout layout ++ encodeSrt static - encodeLayout CILayoutVariable = [0] - encodeLayout (CILayoutUnknown s) = [s+1] - encodeLayout (CILayoutFixed s _vs) = [s+1] - encodeSrt (CIStaticRefs rs) = length rs : map (objectIdx "encodeInfo" cs) rs - encodeRegs CIRegsUnknown = 0 - encodeRegs (CIRegs skip regTypes) = let nregs = sum (map varSize regTypes) - in encodeRegsTag skip nregs - encodeRegsTag skip nregs - | skip < 0 || skip > 1 = panic "encodeRegsTag: unexpected skip" - | otherwise = 1 + nregs `shiftL` 1 + skip - argSize (CIRegs skip regTypes) = sum (map varSize regTypes) - 1 + skip - argSize _ = 0 - -encodeStatic :: HasDebugCallStack - => CompactorState - -> StaticInfo - -> [Int] -encodeStatic cs si = - -- U.trace' ("encodeStatic: " ++ show si) - encodeStatic0 cs si - -encodeStatic0 :: HasDebugCallStack - => CompactorState - -> StaticInfo - -> [Int] -encodeStatic0 cs (StaticInfo _to sv _) - | StaticFun f args <- sv = - [1, entry f, length args] ++ concatMap encodeArg args - | StaticThunk (Just (t, args)) <- sv = - [2, entry t, length args] ++ concatMap encodeArg args - | StaticThunk Nothing <- sv = - [0] - | StaticUnboxed (StaticUnboxedBool b) <- sv = - [3 + fromEnum b] - | StaticUnboxed (StaticUnboxedInt _i) <- sv = - [5] -- ++ encodeInt i - | StaticUnboxed (StaticUnboxedDouble _d) <- sv = - [6] -- ++ encodeDouble d - | (StaticUnboxed _) <- sv = [] -- unboxed strings have their own table --- | StaticString t <- sv = [7, T.length t] ++ map encodeChar (unpackFS t) --- | StaticBin bs <- sv = [8, BS.length bs] ++ map fromIntegral (BS.unpack bs) - | StaticList [] Nothing <- sv = - [8] - | StaticList args t <- sv = - [9, length args] ++ - maybe [0] (\t' -> [1, obj t']) t ++ - concatMap encodeArg (reverse args) - | StaticData con args <- sv = - (if length args <= 6 - then [11+length args] - else [10,length args]) ++ - [entry con] ++ - concatMap encodeArg args - where - obj = objectIdx "encodeStatic" cs - entry = entryIdx "encodeStatic" cs - lbl = labelIdx "encodeStatic" cs - -- an argument is either a reference to a heap object or a primitive value - encodeArg (StaticLitArg (BoolLit b)) = - [0 + fromEnum b] - encodeArg (StaticLitArg (IntLit 0)) = - [2] - encodeArg (StaticLitArg (IntLit 1)) = - [3] - encodeArg (StaticLitArg (IntLit i)) = - 4 : encodeInt i - encodeArg (StaticLitArg NullLit) = - [5] - encodeArg (StaticLitArg (DoubleLit d)) = - 6 : encodeDouble d - encodeArg (StaticLitArg (StringLit s)) = - 7 : encodeString s - encodeArg (StaticLitArg (BinLit b)) = - 8 : encodeBinary b - encodeArg (StaticLitArg (LabelLit b l)) = - [9, fromEnum b, lbl l] - encodeArg (StaticConArg con args) = - [10, entry con, length args] ++ concatMap encodeArg args - encodeArg (StaticObjArg t) = - [11 + obj t] - -- encodeArg x = panic ("encodeArg: unexpected: " ++ show x) - -- encodeChar = ord -- fixme make characters more readable - --- serialization/deserialization -encodeString :: FastString -> [Int] -encodeString = encodeBinary . BSC.pack . unpackFS - --- ByteString is prefixed with length, then blocks of 4 numbers encoding 3 bytes -encodeBinary :: BS.ByteString -> [Int] -encodeBinary bs = BS.length bs : go bs - where - go b | BS.null b = [] - | l == 1 = let b0 = b `BS.index` 0 - in map fromIntegral [ b0 `shiftR` 2, (b0 Bits..&. 3) `shiftL` 4 ] - | l == 2 = let b0 = b `BS.index` 0 - b1 = b `BS.index` 1 - in map fromIntegral [ b0 `shiftR` 2 - , ((b0 Bits..&. 3) `shiftL` 4) Bits..|. (b1 `shiftR` 4) - , (b1 Bits..&. 15) `shiftL` 2 - ] - | otherwise = let b0 = b `BS.index` 0 - b1 = b `BS.index` 1 - b2 = b `BS.index` 2 - in map fromIntegral [ b0 `shiftR` 2 - , ((b0 Bits..&. 3) `shiftL` 4) Bits..|. (b1 `shiftR` 4) - , ((b1 Bits..&. 15) `shiftL` 2) Bits..|. (b2 `shiftR` 6) - , b2 Bits..&. 63 - ] ++ go (BS.drop 3 b) - where l = BS.length b - -encodeInt :: Integer -> [Int] -encodeInt i - | i >= -10 && i < encodeMax - 11 = [fromIntegral i + 12] - | i > 2^(31::Int)-1 || i < -2^(31::Int) - = panic "encodeInt: integer outside 32 bit range" - | otherwise = let i' :: Int32 = fromIntegral i - in [ 0 - , fromIntegral ((i' `shiftR` 16) Bits..&. 0xffff) - , fromIntegral (i' Bits..&. 0xffff) - ] - --- encode a possibly 53 bit int -encodeSignificand :: Integer -> [Int] -encodeSignificand i - | i >= -10 && i < encodeMax - 11 = [fromIntegral i + 12] - | i > 2^(53::Int) || i < -2^(53::Int) - = panic ("encodeInt: integer outside 53 bit range: " ++ show i) - | otherwise = let i' = abs i - in (if i < 0 then 0 else 1) : - map (\r -> fromIntegral ((i' `shiftR` r) Bits..&. 0xffff)) - [48,32,16,0] - -encodeDouble :: SaneDouble -> [Int] -encodeDouble (SaneDouble d) - | isNegativeZero d = [0] - | d == 0 = [1] - | isInfinite d && d > 0 = [2] - | isInfinite d = [3] - | isNaN d = [4] - | abs exponent <= 30 - = (6 + fromIntegral exponent + 30) : encodeSignificand significand - | otherwise - = [5] ++ encodeInt (fromIntegral exponent) ++ encodeSignificand significand - where - (significand, exponent) = decodeFloat d - -encodeMax :: Integer -encodeMax = 737189 - --} - {- | The Base data structure contains the information we need to do incremental linking against a base bundle. @@ -762,17 +272,14 @@ compact :: JSLinkConfig -> [LinkedUnit] -> (CompactorState, [JStat], JStat) compact ln_cfg cfg cs0 rtsDeps0 input0 --- | dumpHashes' input = let rtsDeps1 = rtsDeps0 ++ map (<> "_e") rtsDeps0 ++ map (<> "_con_e") rtsDeps0 - -- (cs1, input1) = packStrings ln_cfg cs0 input0 in renameInternals ln_cfg cfg cs0 rtsDeps1 input0 -- hash compactification - dedupeBodies :: [FastString] -> [LinkedUnit] -> (JStat, [LinkedUnit]) @@ -954,18 +461,10 @@ findLocals (BlockStat ss) = concatMap findLocals ss findLocals (DeclStat (TxtI i)) = [i] findLocals _ = [] -{- -nub' :: Ord a => [a] -> [a] -nub' = go S.empty - where - go _ [] = [] - go s (x:xs) - | x `S.member` s = go s xs - | otherwise = x : go (S.insert x s) xs --} data HashIdx = HashIdx (UniqMap FastString Hash) (Map Hash FastString) + dedupe :: [FastString] -> [LinkedUnit] -> [LinkedUnit] ===================================== compiler/GHC/StgToJS/Linker/Types.hs ===================================== @@ -65,6 +65,7 @@ import System.Process import Prelude +-- | return a list of fresh @Ident@ newLocals :: [Ident] newLocals = filter (not . isJsKeyword) $ map (TxtI . mkFastString) $ @@ -74,9 +75,12 @@ newLocals = filter (not . isJsKeyword) $ chars0 = ['a'..'z']++['A'..'Z'] chars = chars0++['0'..'9'] +-- | Rename @newLocals@ to 'h$$' such that these will be compacted by the +-- compactor. renamedVars :: [Ident] renamedVars = map (\(TxtI xs) -> TxtI ("h$$"<>xs)) newLocals + -------------------------------------------------------------------------------- -- CompactorState -------------------------------------------------------------------------------- @@ -99,29 +103,39 @@ data CompactorState = CompactorState , csStringTable :: !StringTable } +-- | A Table of Strings representing @Ident at s and their payloads in +-- @CompactorState@ data StringTable = StringTable - { stTableIdents :: !(Array Int FastString) + { stTableIdents :: !(Array Int FastString) -- ^ An array of table identifiers, used in the compactor , stOffsets :: !(M.Map ByteString (Int, Int)) -- ^ content of the table , stIdents :: !(UniqMap FastString (Either Int Int)) -- ^ identifiers in the table } --- instance DB.Binary Ident where --- put (TxtI s) = DB.put $ unpackFS s --- get = TxtI . mkFastString <$> DB.get - --- instance DB.Binary StringTable where --- put (StringTable tids offs idents) = do --- DB.put tids --- DB.put (M.toList offs) --- -- The lexical sorting allows us to use nonDetEltsUniqMap without introducing non-determinism --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap idents) --- get = StringTable <$> DB.get --- <*> fmap M.fromList DB.get --- <*> fmap listToUniqMap DB.get +-- | The empty @CompactorState@ +emptyCompactorState :: CompactorState +emptyCompactorState = CompactorState renamedVars + mempty + mempty + 0 + mempty + 0 + mempty + 0 + mempty + mempty + mempty + emptyStringTable +-- | The empty @StringTable@ emptyStringTable :: StringTable emptyStringTable = StringTable (listArray (0,-1) []) M.empty emptyUniqMap + +-------------------------------------------------------------------------------- +-- CompactorState helper functors +-------------------------------------------------------------------------------- + +-- | Update @csEntries@ in @CompactorState@ entries :: Functor f => (UniqMap FastString Int -> f (UniqMap FastString Int)) -> CompactorState @@ -129,6 +143,7 @@ entries :: Functor f entries f cs = fmap (\x -> cs { csEntries = x }) (f $ csEntries cs) {-# INLINE entries #-} +-- | Update @csIdentSupply@ in @CompactorState@ identSupply :: Functor f => ([Ident] -> f [Ident]) -> CompactorState @@ -136,6 +151,7 @@ identSupply :: Functor f identSupply f cs = fmap (\x -> cs { csIdentSupply = x }) (f $ csIdentSupply cs) {-# INLINE identSupply #-} +-- | Update @csLabels@ in @CompactorState@ labels :: Functor f => (UniqMap FastString Int -> f (UniqMap FastString Int)) -> CompactorState @@ -143,6 +159,7 @@ labels :: Functor f labels f cs = fmap (\x -> cs { csLabels = x }) (f $ csLabels cs) {-# INLINE labels #-} +-- | Update @csNameMap@ in @CompactorState@ nameMap :: Functor f => (UniqMap FastString Ident -> f (UniqMap FastString Ident)) -> CompactorState @@ -150,6 +167,7 @@ nameMap :: Functor f nameMap f cs = fmap (\x -> cs { csNameMap = x }) (f $ csNameMap cs) {-# INLINE nameMap #-} +-- | Update @csNumEntries@ in @CompactorState@ numEntries :: Functor f => (Int -> f Int) -> CompactorState @@ -157,6 +175,7 @@ numEntries :: Functor f numEntries f cs = fmap (\x -> cs { csNumEntries = x }) (f $ csNumEntries cs) {-# INLINE numEntries #-} +-- | Update @csNumLabels@ in @CompactorState@ numLabels :: Functor f => (Int -> f Int) -> CompactorState @@ -164,6 +183,7 @@ numLabels :: Functor f numLabels f cs = fmap (\x -> cs { csNumLabels = x }) (f $ csNumLabels cs) {-# INLINE numLabels #-} +-- | Update @csNumStatics@ in @CompactorState@ numStatics :: Functor f => (Int -> f Int) -> CompactorState @@ -171,6 +191,7 @@ numStatics :: Functor f numStatics f cs = fmap (\x -> cs { csNumStatics = x }) (f $ csNumStatics cs) {-# INLINE numStatics #-} +-- | Update @csParentEntries@ in @CompactorState@ parentEntries :: Functor f => (UniqMap FastString Int -> f (UniqMap FastString Int)) -> CompactorState @@ -178,6 +199,7 @@ parentEntries :: Functor f parentEntries f cs = fmap (\x -> cs { csParentEntries = x }) (f $ csParentEntries cs) {-# INLINE parentEntries #-} +-- | Update @csParentLabels@ in @CompactorState@ parentLabels :: Functor f => (UniqMap FastString Int -> f (UniqMap FastString Int)) -> CompactorState @@ -185,6 +207,7 @@ parentLabels :: Functor f parentLabels f cs = fmap (\x -> cs { csParentLabels = x }) (f $ csParentLabels cs) {-# INLINE parentLabels #-} +-- | Update @csParentStatics@ in @CompactorState@ parentStatics :: Functor f => (UniqMap FastString Int -> f (UniqMap FastString Int)) -> CompactorState @@ -192,6 +215,7 @@ parentStatics :: Functor f parentStatics f cs = fmap (\x -> cs { csParentStatics = x }) (f $ csParentStatics cs) {-# INLINE parentStatics #-} +-- | Update @csStatics@ in @CompactorState@ statics :: Functor f => (UniqMap FastString Int -> f (UniqMap FastString Int)) -> CompactorState @@ -199,6 +223,7 @@ statics :: Functor f statics f cs = fmap (\x -> cs { csStatics = x }) (f $ csStatics cs) {-# INLINE statics #-} +-- | Update @csStringTable@ in @CompactorState@ stringTable :: Functor f => (StringTable -> f StringTable) -> CompactorState @@ -206,37 +231,12 @@ stringTable :: Functor f stringTable f cs = fmap (\x -> cs { csStringTable = x }) (f $ csStringTable cs) {-# INLINE stringTable #-} -emptyCompactorState :: CompactorState -emptyCompactorState = CompactorState renamedVars - mempty - mempty - 0 - mempty - 0 - mempty - 0 - mempty - mempty - mempty - emptyStringTable --- | make a base state from a CompactorState: empty the current symbols sets, --- move everything to the parent -makeCompactorParent :: CompactorState -> CompactorState -makeCompactorParent (CompactorState is nm es nes ss nss ls nls pes pss pls sts) - = CompactorState is - nm - emptyUniqMap 0 - emptyUniqMap 0 - emptyUniqMap 0 - (plusUniqMap (fmap (+nes) pes) es) - (plusUniqMap (fmap (+nss) pss) ss) - (plusUniqMap (fmap (+nls) pls) ls) - sts +-------------------------------------------------------------------------------- +-- CompactorState Insertions +-------------------------------------------------------------------------------- --- Helper functions used in Linker.Compactor. We live with some redundant code --- to avoid the lens mayhem in Gen2 GHCJS. TODO: refactor to avoid redundant --- code +-- | Given a static entry, add the entry to @CompactorState@ addStaticEntry :: FastString -- ^ The static entry to add -> CompactorState -- ^ the old state -> CompactorState -- ^ the new state @@ -251,6 +251,7 @@ addStaticEntry new cs = newCnt = cnt + 1 in cs {csStatics = newStatics, csNumStatics = newCnt} +-- | Given an entry function, add the entry function to @CompactorState@ addEntry :: FastString -- ^ The entry function to add -> CompactorState -- ^ the old state -> CompactorState -- ^ the new state @@ -264,6 +265,7 @@ addEntry new cs = newCnt = cnt + 1 in cs {csEntries = newEntries, csNumEntries = newCnt} +-- | Given a label, add the label to @CompactorState@ addLabel :: FastString -- ^ The label to add -> CompactorState -- ^ the old state -> CompactorState -- ^ the new state @@ -276,6 +278,8 @@ addLabel new cs = newLabels = addToUniqMap cur_lbls new cnt newCnt = cnt + 1 in cs {csEntries = newLabels, csNumLabels = newCnt} + + -------------------------------------------------------------------------------- -- Base -------------------------------------------------------------------------------- @@ -287,10 +291,7 @@ data Base = Base { baseCompactorState :: CompactorState , baseUnits :: Set (Module, Int) } --- instance DB.Binary Base where --- get = getBase "" --- put = putBase - +-- | Custom Show for the @Base@ bundle showBase :: Base -> String showBase b = unlines [ "Base:" @@ -300,99 +301,23 @@ showBase b = unlines show (sizeUniqMap . csNameMap . baseCompactorState $ b) ] +-- | The empty @Base@ bundle emptyBase :: Base emptyBase = Base emptyCompactorState [] S.empty --- putBase :: Base -> DB.Put --- putBase (Base cs packages funs) = do --- DB.putByteString "GHCJSBASE" --- DB.putLazyByteString versionTag --- putCs cs --- putList DB.put packages --- -- putList putPkg pkgs --- putList DB.put mods --- putList putFun (S.toList funs) --- where --- pi :: Int -> DB.Put --- pi = DB.putWord32le . fromIntegral --- uniq :: Ord a => [a] -> [a] --- uniq = S.toList . S.fromList --- -- pkgs = uniq (map fst $ S.toList funs) --- -- pkgsM = M.fromList (zip pkgs [(0::Int)..]) --- mods = uniq (map fst $ S.toList funs) --- modsM = M.fromList (zip mods [(0::Int)..]) --- putList f xs = pi (length xs) >> mapM_ f xs --- -- serialise the compactor state --- putCs (CompactorState [] _ _ _ _ _ _ _ _ _ _ _) = --- panic "putBase: putCs exhausted renamer symbol names" --- putCs (CompactorState (ns:_) nm es _ ss _ ls _ pes pss pls sts) = do --- DB.put ns --- -- We can use nonDetEltsUniqMap without introducing non-determinism by sorting lexically --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap nm) --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap es) --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap ss) --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap ls) --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pes) --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pss) --- DB.put (sortOn (LexicalFastString . fst) $ nonDetEltsUniqMap pls) --- DB.put sts --- -- putPkg mod = DB.put mod --- -- fixme group things first --- putFun (m,s) = --pi (pkgsM M.! p) >> --- pi (modsM M.! m) >> DB.put s - --- getBase :: FilePath -> DB.Get Base --- getBase file = getBase' --- where --- gi :: DB.Get Int --- gi = fromIntegral <$> DB.getWord32le --- getList f = DB.getWord32le >>= \n -> replicateM (fromIntegral n) f --- getFun ms = (,) <$> --- -- ((ps!) <$> gi) <*> --- ((ms!) <$> gi) <*> DB.get --- la xs = listArray (0, length xs - 1) xs --- -- getPkg = DB.get --- getCs = do --- n <- DB.get --- nm <- listToUniqMap <$> DB.get --- es <- listToUniqMap <$> DB.get --- ss <- listToUniqMap <$> DB.get --- ls <- listToUniqMap <$> DB.get --- pes <- listToUniqMap <$> DB.get --- pss <- listToUniqMap <$> DB.get --- pls <- listToUniqMap <$> DB.get --- CompactorState (dropWhile (/=n) renamedVars) --- nm --- es --- (sizeUniqMap es) --- ss --- (sizeUniqMap ss) --- ls --- (sizeUniqMap ls) --- pes --- pss --- pls <$> DB.get --- getBase' = do --- hdr <- DB.getByteString 9 --- when (hdr /= "GHCJSBASE") --- (panic $ "getBase: invalid base file: " <> file) --- vt <- DB.getLazyByteString (fromIntegral versionTagLength) --- when (vt /= versionTag) --- (panic $ "getBase: incorrect version: " <> file) --- cs <- makeCompactorParent <$> getCs --- linkedPackages <- getList DB.get --- -- pkgs <- la <$> getList getPkg --- mods <- la <$> getList DB.get --- funs <- getList (getFun mods) --- return (Base cs linkedPackages $ S.fromList funs) - --- -- | lazily render the base metadata into a bytestring --- renderBase :: Base -> BL.ByteString --- renderBase = DB.runPut . putBase --- --- -- | lazily load base metadata from a file, see @UseBase at . --- loadBase :: FilePath -> IO Base --- loadBase file = DB.runGet (getBase file) <$> BL.readFile file +-- | make a @Base@ state from a @CompactorState@: empty the current symbols +-- sets, move everything to the parent +makeCompactorParent :: CompactorState -> CompactorState +makeCompactorParent (CompactorState is nm es nes ss nss ls nls pes pss pls sts) + = CompactorState is + nm + emptyUniqMap 0 + emptyUniqMap 0 + emptyUniqMap 0 + (plusUniqMap (fmap (+nes) pes) es) + (plusUniqMap (fmap (+nss) pss) ss) + (plusUniqMap (fmap (+nls) pls) ls) + sts -- | There are 3 ways the linker can use @Base at . We can not use it, and thus not -- do any incremental linking. We can load it from a file, where we assume that @@ -419,9 +344,9 @@ instance Semigroup UseBase where x <> NoBase = x _ <> x = x + -------------------------------------------------------------------------------- -- Linker Config --- TODO: Jeff: (2022,03): Move to separate module? Linker.Config? Or Merge with StgToJSConfig? -------------------------------------------------------------------------------- data JSLinkConfig = @@ -444,6 +369,7 @@ data JSLinkConfig = , lcDedupe :: Bool } +-- | Check if we are using the @Base@ bundle, or not. usingBase :: JSLinkConfig -> Bool usingBase s | NoBase <- lcUseBase s = False | otherwise = True @@ -482,13 +408,16 @@ instance Semigroup JSLinkConfig where (jslsrc1 <> jslsrc2) (dd1 || dd2) + -------------------------------------------------------------------------------- -- Linker Environment -------------------------------------------------------------------------------- --- | A LinkableUnit is a pair of a module and the index of the block in the + +-- | A @LinkableUnit@ is a pair of a module and the index of the block in the -- object file type LinkableUnit = (Module, Int) +-- | A @LinkedUnit@ is a payload of JS code with its closures and any static info. data LinkedUnit = LinkedUnit { lu_js_code :: !JStat , lu_closures :: ![ClosureInfo] @@ -512,6 +441,7 @@ data GhcjsEnv = GhcjsEnv , pluginState :: MVar (Maybe HscEnv) } +-- | return a fresh @GhcjsEnv@ newGhcjsEnv :: IO GhcjsEnv newGhcjsEnv = GhcjsEnv <$> newMVar M.empty <*> newMVar emptyTHRunnerState @@ -519,6 +449,11 @@ newGhcjsEnv = GhcjsEnv <$> newMVar M.empty <*> newMVar M.empty <*> newMVar Nothing + +-------------------------------------------------------------------------------- +-- Template Haskell +-------------------------------------------------------------------------------- + data THRunnerState = THRunnerState { activeRunners :: Map String THRunner , idleRunners :: [THRunner] @@ -533,21 +468,30 @@ data THRunner = , thrExceptions :: MVar (I.IntMap E.SomeException) } +emptyTHRunnerState :: THRunnerState +emptyTHRunnerState = THRunnerState mempty mempty + + +-------------------------------------------------------------------------------- +-- Template Haskell helpers +-------------------------------------------------------------------------------- + +-- | Add an idle runner to the set of @idleRunners@ in @THRunnerState@ consIdleRunner :: THRunner -> THRunnerState -> THRunnerState consIdleRunner r s = s { idleRunners = r : idleRunners s } +-- | Remove an idle runner from the set of @idleRunners@ in @THRunnerState@ unconsIdleRunner :: THRunnerState -> Maybe (THRunner, THRunnerState) unconsIdleRunner s | (r:xs) <- idleRunners s = Just (r, s { idleRunners = xs }) | otherwise = Nothing +-- | Remove an active runner from the set of @activeRunners@ in @THRunnerState@ deleteActiveRunner :: String -> THRunnerState -> THRunnerState deleteActiveRunner m s = s { activeRunners = M.delete m (activeRunners s) } +-- | Add an active runner to the set of @activeRunners@ in @THRunnerState@ insertActiveRunner :: String -> THRunner -> THRunnerState -> THRunnerState insertActiveRunner m runner s = s { activeRunners = M.insert m runner (activeRunners s) } - -emptyTHRunnerState :: THRunnerState -emptyTHRunnerState = THRunnerState mempty mempty View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/720c6576aec6526354a1d998782b2a0e1186c509 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/720c6576aec6526354a1d998782b2a0e1186c509 You're receiving 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 Sep 23 12:03:46 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 23 Sep 2022 08:03:46 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Linker: Add docs to utility modules Message-ID: <632da0a27c1f6_3a3c15513c41277225@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 5d06a2d6 by doyougnu at 2022-09-23T08:03:21-04:00 StgToJS.Linker: Add docs to utility modules StgToJS.Linker.Utils: more docs StgToJS.Linker.Archive: more docs - - - - - 2 changed files: - compiler/GHC/StgToJS/Linker/Archive.hs - compiler/GHC/StgToJS/Linker/Utils.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Archive.hs ===================================== @@ -13,7 +13,10 @@ -- Josh Meredith -- Stability : experimental -- +-- Various utilies used in the JS Linker which wrap around ar. +-- ----------------------------------------------------------------------------- + module GHC.StgToJS.Linker.Archive ( Entry(..), Index, IndexEntry(..), Meta(..) , writeArchive @@ -36,6 +39,7 @@ import GHC.Settings.Constants (hiVersion) type Index = [IndexEntry] +-- | An @IndexEntry@ is a payload and an offset into the archive data IndexEntry = IndexEntry { ieEntry :: !Entry -- ^ Entry identifier , ieOffset :: !(Bin ByteString) -- ^ Offset in the archive @@ -47,9 +51,10 @@ instance Binary IndexEntry where put_ bh b get bh = IndexEntry <$> get bh <*> get bh +-- | An @Entry@ is either a module or a JavaScript source file. data Entry - = Object !ModuleName - | JsSource !FilePath + = Object !ModuleName -- ^ A Haskell Module + | JsSource !FilePath -- ^ A JS Source file deriving (Show) instance Binary Entry where @@ -69,9 +74,12 @@ instance Binary Meta where put_ bh (Meta a) = put_ bh a get bh = Meta <$> get bh +-- | A header indicating we are in JS land. magic :: FixedLengthEncoding Word64 magic = FixedLengthEncoding 0x435241534a434847 -- "GHCJSARC" +-- | Write payload, entries, to @FilePath@, path, using @Meta@, meta, to +-- construct the payload header. writeArchive :: FilePath -> Meta -> [(Entry, ByteString)] -> IO () writeArchive path meta entries = do bh <- openBinMem (4*1024*1000) @@ -99,6 +107,8 @@ data Header = Header , hdrHandle :: !BinHandle } +-- | Given a binary handle, retrieve the header from the archive. Note this +-- function is unsafe and may panic. getArchiveHeader :: BinHandle -> IO Header getArchiveHeader bh = do is_magic <- (== magic) <$> get bh @@ -115,18 +125,22 @@ getArchiveHeader bh = do , hdrHandle = bh } +-- | Read the meta data from an archive pointed to by 'file'. readMeta :: FilePath -> IO Meta readMeta file = do bh <- readBinMem file hdr <- getArchiveHeader bh pure $! hdrMeta hdr +-- | Read the index from an archive pointed to by 'file'. readIndex :: FilePath -> IO Index readIndex file = do bh <- readBinMem file hdr <- getArchiveHeader bh pure $! hdrIndex hdr +-- | Read the all payloads that satisfy the input predicate, 'pred', in the +-- archive pointed to by 'hdr'. getArchiveEntries :: Header -> (Entry -> Bool) -> IO [ByteString] getArchiveEntries hdr pred = mapMaybeM read_entry (hdrIndex hdr) where @@ -137,6 +151,9 @@ getArchiveEntries hdr pred = mapMaybeM read_entry (hdrIndex hdr) Just <$> get bh | otherwise = pure Nothing +-- | Get a single payload by searching @IndexEntry at s in 'hdr', returns the first +-- entry that satisfies the input predicate, 'pred', in the archive pointed to +-- by 'hdr'. Returns Nothing if 'pred' fails for all entries. getArchiveEntry :: Header -> (Entry -> Bool) -> IO (Maybe ByteString) getArchiveEntry hdr pred = go (hdrIndex hdr) where ===================================== compiler/GHC/StgToJS/Linker/Utils.hs ===================================== @@ -37,6 +37,8 @@ import GHC.Platform import Data.List (isPrefixOf) import System.Directory (createDirectoryIfMissing) +-- | Given a FilePath and payload, write a file to disk creating any directories +-- along the way if needed. writeBinaryFile :: FilePath -> ByteString -> IO () writeBinaryFile file bs = do createDirectoryIfMissing True (takeDirectory file) @@ -48,15 +50,19 @@ writeBinaryFile file bs = do let (b1, b2) = B.splitAt 1073741824 b in b1 : if B.null b1 then [] else chunks b2 +-- | Retrieve library directories provided by the @UnitId@ in @UnitState@ getInstalledPackageLibDirs :: UnitState -> UnitId -> [FilePath] getInstalledPackageLibDirs us = fmap unpack . maybe mempty unitLibraryDirs . lookupUnitId us +-- | Retrieve the names of the libraries provided by @UnitId@ getInstalledPackageHsLibs :: UnitState -> UnitId -> [String] getInstalledPackageHsLibs us = fmap unpack . maybe mempty unitLibraries . lookupUnitId us +-- | A constant holding the compiler version getCompilerVersion :: String getCompilerVersion = cProjectVersion +-- | A constant holding the JavaScript executable Filename extension jsexeExtension :: String jsexeExtension = "jsexe" @@ -66,11 +72,14 @@ commonCppDefs profiling = case profiling of True -> commonCppDefs_profiled False -> commonCppDefs_vanilla --- Use CAFs for commonCppDefs_* so that they are shared for every CPP file +-- | CPP definitions for normal operation and profiling. Use CAFs for +-- commonCppDefs_* so that they are shared for every CPP file commonCppDefs_vanilla, commonCppDefs_profiled :: ByteString commonCppDefs_vanilla = genCommonCppDefs False commonCppDefs_profiled = genCommonCppDefs True +-- | Generate CPP Definitions depending on a profiled or normal build. This +-- occurs at link time. genCommonCppDefs :: Bool -> ByteString genCommonCppDefs profiling = mconcat [ @@ -270,6 +279,8 @@ genCommonCppDefs profiling = mconcat , "#define CALL_UBX_TUP10(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,c) { (r1) = (c); (r2) = h$ret1; (r3) = h$ret2; (r4) = h$ret3; (r5) = h$ret4; (r6) = h$ret5; (r7) = h$ret6; (r8) = h$ret7; (r9) = h$ret8; (r10) = h$ret9; }\n" ] +-- | Construct the Filename for the "binary" of Haskell code compiled to +-- JavaScript. jsExeFileName :: DynFlags -> FilePath jsExeFileName dflags | Just s <- outputFile_ dflags = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5d06a2d631598615af41b07b476d5ab06d347616 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5d06a2d631598615af41b07b476d5ab06d347616 You're receiving 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 Sep 23 12:05:41 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 23 Sep 2022 08:05:41 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] 28 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <632da11526f3_3a3c1551824127966f@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 53dcbf07 by Matthew Pickering at 2022-09-23T12:31:43+01: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 - - - - - 0209dc47 by Matthew Pickering at 2022-09-23T12:40:05+01:00 Add test for #22162 - - - - - d7c40b2b by Matthew Pickering at 2022-09-23T12:40:08+01:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 5c15580b by Matthew Pickering at 2022-09-23T12:49:54+01:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 18278bdf by Matthew Pickering at 2022-09-23T12:50:07+01:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Monad.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Types.hs - compiler/GHC/HsToCore/Quote.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a33a77294ebf412635446ffa8bf00c8b38a9aae6...18278bdfcfa847f66e6482b13136b9ab3eea11f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a33a77294ebf412635446ffa8bf00c8b38a9aae6...18278bdfcfa847f66e6482b13136b9ab3eea11f1 You're receiving 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 Sep 23 12:07:33 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 23 Sep 2022 08:07:33 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] 3 commits: ci: Add job to test interface file determinism guarantees Message-ID: <632da185d4da8_3a3c15514f0128389f@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: dc768ef9 by Matthew Pickering at 2022-09-23T13:07:25+01:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 951cea92 by Matthew Pickering at 2022-09-23T13:07:25+01:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - bf83c40c by Matthew Pickering at 2022-09-23T13:07:25+01:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 5 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -396,6 +396,33 @@ test-cabal-reinstall-x86_64-linux-deb10: rules: - if: $NIGHTLY +######################################## +# Testing ABI is invariant across builds +######################################## + +abi-test-nightly: + stage: full-build + needs: + - job: x86_64-linux-fedora33-release-hackage + - job: x86_64-linux-fedora33-release + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + dependencies: null + before_script: + - mkdir -p normal + - mkdir -p hackage + - tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C normal/ + - tar -xf ghc-x86_64-linux-fedora33-release-hackage_docs.tar.xz -C hackage/ + script: + - .gitlab/ci.sh compare_interfaces_of "normal/ghc-*" "hackage/ghc-*" + artifacts: + paths: + - out + rules: + - if: $NIGHTLY + - if: '$RELEASE_JOB == "yes"' + ############################################################ # Packaging ############################################################ @@ -744,6 +771,46 @@ perf: rules: - if: '$CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/' +############################################################ +# ABI testing +############################################################ + +abi-test: + stage: testing + needs: + - job: x86_64-linux-fedora33-release + optional: true + - job: nightly-x86_64-linux-fedora33-release + optional: true + - job: release-x86_64-linux-fedora33-release + optional: true + dependencies: null + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - export HC=$root/bin/ghc + - .gitlab/ci.sh abi_test + artifacts: + paths: + - out + rules: + - if: '$CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/' + ############################################################ # Documentation deployment via GitLab Pages ===================================== .gitlab/ci.sh ===================================== @@ -637,6 +637,36 @@ function test_hadrian() { } +function summarise_hi_files() { + for iface in $(find . -type f -name "*.hi" | sort); do echo "$iface $($HC --show-iface $iface | grep " ABI hash:")"; done | tee $OUT/abis + for iface in $(find . -type f -name "*.hi" | sort); do echo "$iface $($HC --show-iface $iface | grep " interface hash:")"; done | tee $OUT/interfaces + for iface in $(find . -type f -name "*.hi" | sort); do + fname="$OUT/$(dirname $iface)" + mkdir -p $fname + $HC --show-iface $iface > "$OUT/$iface" + done +} + +function cabal_abi_test() { + if [ -z "$OUT" ]; then + fail "OUT not set" + fi + + cp -r libraries/Cabal $DIR + pushd $DIR + echo $PWD + + start_section "Cabal test: $OUT" + mkdir -p "$OUT" + run "$HC" \ + -hidir tmp -odir tmp -fforce-recomp -haddock \ + -iCabal/Cabal/src -XNoPolyKinds Distribution.Simple -j1 \ + "$@" 2>&1 | tee $OUT/log + summarise_hi_files + popd + end_section "Cabal test: $OUT" +} + function cabal_test() { if [ -z "$OUT" ]; then fail "OUT not set" @@ -667,6 +697,35 @@ function run_perf_test() { OUT=out/Cabal-O2 cabal_test -O2 } +function check_interfaces(){ + difference=$(diff "$1/$3" "$2/$3") || warn "diff failed" + if [ -z "$difference" ] + then + info "$1 and $2 $3 match" + else + echo $difference + for line in $(echo "$difference" | tr ' ' '\n' | grep ".hi" | sort | uniq); do + diff "$1/$line" "$2/$line" + done + fail "$3" + fi +} + +function abi_test() { + for i in {1..20}; do info "iteration $i"; run_abi_test; done +} + +function run_abi_test() { + if [ -z "$HC" ]; then + fail "HC not set" + fi + mkdir -p out + OUT="$PWD/out/run1" DIR=$(mktemp -d XXXX-looooooooong) cabal_abi_test -O0 + OUT="$PWD/out/run2" DIR=$(mktemp -d XXXX-short) cabal_abi_test -O0 + check_interfaces out/run1 out/run2 abis "Mismatched ABI hash" + check_interfaces out/run1 out/run2 interfaces "Mismatched interface hashes" +} + function save_cache () { info "Storing cabal cache from $CABAL_DIR to $CABAL_CACHE..." rm -Rf "$CABAL_CACHE" @@ -716,6 +775,22 @@ function lint_author(){ done } +function abi_of(){ + DIR=$(realpath $1) + mkdir -p "$OUT" + pushd $DIR + summarise_hi_files + popd +} + +# Checks that the interfaces in folder $1 match the interfaces in folder $2 +function compare_interfaces_of(){ + OUT=$PWD/out/run1 abi_of $1 + OUT=$PWD/out/run2 abi_of $2 + check_interfaces out/run1 out/run2 abis "Mismatched ABI hash" + check_interfaces out/run1 out/run2 interfaces "Mismatched interface hashes" +} + setup_locale @@ -811,8 +886,10 @@ case $1 in exit $res ;; run_hadrian) shift; run_hadrian "$@" ;; perf_test) run_perf_test ;; + abi_test) abi_test ;; cabal_test) cabal_test ;; lint_author) shift; lint_author "$@" ;; + compare_interfaces_of) shift; compare_interfaces_of "$@" ;; clean) clean ;; save_cache) save_cache ;; shell) shift; shell "$@" ;; ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -41,7 +41,7 @@ import GHC.HsToCore.Coverage import GHC.HsToCore.Docs import GHC.Tc.Types -import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances ) +import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances, initIfaceLoad ) import GHC.Tc.Module ( runTcInteractive ) import GHC.Core.Type @@ -239,8 +239,9 @@ deSugar hsc_env ; let plugins = hsc_plugins hsc_env ; let fc = hsc_FC hsc_env ; let unit_env = hsc_unit_env hsc_env - ; usages <- mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names - dep_files merged needed_mods needed_pkgs + ; usages <- initIfaceLoad hsc_env $ + mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names + dep_files merged needed_mods needed_pkgs -- id_mod /= mod when we are processing an hsig, but hsigs -- never desugared and compiled (there's no code!) -- Consequently, this should hold for any ModGuts that make ===================================== compiler/GHC/HsToCore/Usage.hs ===================================== @@ -15,10 +15,13 @@ import GHC.Driver.Env import GHC.Tc.Types +import GHC.Iface.Load + import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Fingerprint import GHC.Utils.Panic +import GHC.Utils.Monad import GHC.Types.Name import GHC.Types.Name.Set ( NameSet, allUses ) @@ -70,18 +73,18 @@ data UsageConfig = UsageConfig } mkUsageInfo :: UsageConfig -> Plugins -> FinderCache -> UnitEnv -> Module -> ImportedMods -> NameSet -> [FilePath] - -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IO [Usage] + -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IfG [Usage] mkUsageInfo uc plugins fc unit_env this_mod dir_imp_mods used_names dependent_files merged needed_links needed_pkgs = do - eps <- readIORef (euc_eps (ue_eps unit_env)) - hashes <- mapM getFileHash dependent_files + eps <- liftIO $ readIORef (euc_eps (ue_eps unit_env)) + hashes <- liftIO $ mapM getFileHash dependent_files let hu = unsafeGetHomeUnit unit_env hug = ue_home_unit_graph unit_env -- Dependencies on object files due to TH and plugins - object_usages <- mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs - let mod_usages = mk_mod_usage_info (eps_PIT eps) uc hug hu this_mod + object_usages <- liftIO $ mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs + mod_usages <- mk_mod_usage_info uc hu this_mod dir_imp_mods used_names - usages = mod_usages ++ [ UsageFile { usg_file_path = f + let usages = mod_usages ++ [ UsageFile { usg_file_path = f , usg_file_hash = hash , usg_file_label = Nothing } | (f, hash) <- zip dependent_files hashes ] @@ -189,16 +192,14 @@ mkObjectUsage pit plugins fc hug th_links_needed th_pkgs_needed = do librarySpecToUsage (DLLPath fn) = traverse (fing Nothing) [fn] librarySpecToUsage _ = return [] -mk_mod_usage_info :: PackageIfaceTable - -> UsageConfig - -> HomeUnitGraph +mk_mod_usage_info :: UsageConfig -> HomeUnit -> Module -> ImportedMods -> NameSet - -> [Usage] -mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names - = mapMaybe mkUsage usage_mods + -> IfG [Usage] +mk_mod_usage_info uc home_unit this_mod direct_imports used_names + = mapMaybeM mkUsageM usage_mods where safe_implicit_imps_req = uc_safe_implicit_imps_req uc @@ -234,22 +235,23 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names in extendModuleEnvWith (\_ xs -> occ:xs) mv_map mod' [occ] where occ = nameOccName name + mkUsageM :: Module -> IfG (Maybe Usage) + mkUsageM mod | mod == this_mod = return Nothing + mkUsageM mod = do + iface <- loadSysInterface (text "mk_mod_usage") mod + return $ mkUsage mod iface + + -- We want to create a Usage for a home module if -- a) we used something from it; has something in used_names -- b) we imported it, even if we used nothing from it -- (need to recompile if its export list changes: export_fprint) - mkUsage :: Module -> Maybe Usage - mkUsage mod - | isNothing maybe_iface -- We can't depend on it if we didn't - -- load its interface. - || mod == this_mod -- We don't care about usages of - -- things in *this* module - = Nothing - + mkUsage :: Module -> ModIface -> Maybe Usage + mkUsage mod iface | not (isHomeModule home_unit mod) - = Just UsagePackageModule{ usg_mod = mod, - usg_mod_hash = mod_hash, - usg_safe = imp_safe } + = Just $ UsagePackageModule{ usg_mod = mod, + usg_mod_hash = mod_hash, + usg_safe = imp_safe } -- for package modules, we record the module hash only | (null used_occs @@ -269,11 +271,6 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names usg_entities = Map.toList ent_hashs, usg_safe = imp_safe } where - maybe_iface = lookupIfaceByModule hpt pit mod - -- In one-shot mode, the interfaces for home-package - -- modules accumulate in the PIT not HPT. Sigh. - - Just iface = maybe_iface finsts_mod = mi_finsts (mi_final_exts iface) hash_env = mi_hash_fn (mi_final_exts iface) mod_hash = mi_mod_hash (mi_final_exts iface) ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -222,7 +222,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary -- but if you pass that in here, we'll decide it's the local -- module and does not need to be recorded as a dependency. -- See Note [Identity versus semantic module] - usages <- mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names + usages <- initIfaceLoad hsc_env $ mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names dep_files merged needed_links needed_pkgs docs <- extractDocs (ms_hspp_opts mod_summary) tc_result View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18278bdfcfa847f66e6482b13136b9ab3eea11f1...bf83c40c9deaf52bc1a7d51c9fb33a724acbcf99 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18278bdfcfa847f66e6482b13136b9ab3eea11f1...bf83c40c9deaf52bc1a7d51c9fb33a724acbcf99 You're receiving 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 Sep 23 12:11:29 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 23 Sep 2022 08:11:29 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] 2 commits: ci: Add job for testing interface stability across builds Message-ID: <632da2715c439_3a3c15513ec12862f2@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 2b71b471 by Matthew Pickering at 2022-09-23T13:11:22+01:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - cc6c7a60 by Matthew Pickering at 2022-09-23T13:11:22+01:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 5 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -396,6 +396,33 @@ test-cabal-reinstall-x86_64-linux-deb10: rules: - if: $NIGHTLY +######################################## +# Testing ABI is invariant across builds +######################################## + +abi-test-nightly: + stage: full-build + needs: + - job: nightly-x86_64-linux-fedora33-release-hackage + - job: nightly-x86_64-linux-fedora33-release + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + dependencies: null + before_script: + - mkdir -p normal + - mkdir -p hackage + - tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C normal/ + - tar -xf ghc-x86_64-linux-fedora33-release-hackage_docs.tar.xz -C hackage/ + script: + - .gitlab/ci.sh compare_interfaces_of "normal/ghc-*" "hackage/ghc-*" + artifacts: + paths: + - out + rules: + - if: $NIGHTLY + - if: '$RELEASE_JOB == "yes"' + ############################################################ # Packaging ############################################################ ===================================== .gitlab/ci.sh ===================================== @@ -775,6 +775,22 @@ function lint_author(){ done } +function abi_of(){ + DIR=$(realpath $1) + mkdir -p "$OUT" + pushd $DIR + summarise_hi_files + popd +} + +# Checks that the interfaces in folder $1 match the interfaces in folder $2 +function compare_interfaces_of(){ + OUT=$PWD/out/run1 abi_of $1 + OUT=$PWD/out/run2 abi_of $2 + check_interfaces out/run1 out/run2 abis "Mismatched ABI hash" + check_interfaces out/run1 out/run2 interfaces "Mismatched interface hashes" +} + setup_locale @@ -873,6 +889,7 @@ case $1 in abi_test) abi_test ;; cabal_test) cabal_test ;; lint_author) shift; lint_author "$@" ;; + compare_interfaces_of) shift; compare_interfaces_of "$@" ;; clean) clean ;; save_cache) save_cache ;; shell) shift; shell "$@" ;; ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -41,7 +41,7 @@ import GHC.HsToCore.Coverage import GHC.HsToCore.Docs import GHC.Tc.Types -import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances ) +import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances, initIfaceLoad ) import GHC.Tc.Module ( runTcInteractive ) import GHC.Core.Type @@ -239,8 +239,9 @@ deSugar hsc_env ; let plugins = hsc_plugins hsc_env ; let fc = hsc_FC hsc_env ; let unit_env = hsc_unit_env hsc_env - ; usages <- mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names - dep_files merged needed_mods needed_pkgs + ; usages <- initIfaceLoad hsc_env $ + mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names + dep_files merged needed_mods needed_pkgs -- id_mod /= mod when we are processing an hsig, but hsigs -- never desugared and compiled (there's no code!) -- Consequently, this should hold for any ModGuts that make ===================================== compiler/GHC/HsToCore/Usage.hs ===================================== @@ -15,10 +15,13 @@ import GHC.Driver.Env import GHC.Tc.Types +import GHC.Iface.Load + import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Fingerprint import GHC.Utils.Panic +import GHC.Utils.Monad import GHC.Types.Name import GHC.Types.Name.Set ( NameSet, allUses ) @@ -70,18 +73,18 @@ data UsageConfig = UsageConfig } mkUsageInfo :: UsageConfig -> Plugins -> FinderCache -> UnitEnv -> Module -> ImportedMods -> NameSet -> [FilePath] - -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IO [Usage] + -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IfG [Usage] mkUsageInfo uc plugins fc unit_env this_mod dir_imp_mods used_names dependent_files merged needed_links needed_pkgs = do - eps <- readIORef (euc_eps (ue_eps unit_env)) - hashes <- mapM getFileHash dependent_files + eps <- liftIO $ readIORef (euc_eps (ue_eps unit_env)) + hashes <- liftIO $ mapM getFileHash dependent_files let hu = unsafeGetHomeUnit unit_env hug = ue_home_unit_graph unit_env -- Dependencies on object files due to TH and plugins - object_usages <- mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs - let mod_usages = mk_mod_usage_info (eps_PIT eps) uc hug hu this_mod + object_usages <- liftIO $ mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs + mod_usages <- mk_mod_usage_info uc hu this_mod dir_imp_mods used_names - usages = mod_usages ++ [ UsageFile { usg_file_path = f + let usages = mod_usages ++ [ UsageFile { usg_file_path = f , usg_file_hash = hash , usg_file_label = Nothing } | (f, hash) <- zip dependent_files hashes ] @@ -189,16 +192,14 @@ mkObjectUsage pit plugins fc hug th_links_needed th_pkgs_needed = do librarySpecToUsage (DLLPath fn) = traverse (fing Nothing) [fn] librarySpecToUsage _ = return [] -mk_mod_usage_info :: PackageIfaceTable - -> UsageConfig - -> HomeUnitGraph +mk_mod_usage_info :: UsageConfig -> HomeUnit -> Module -> ImportedMods -> NameSet - -> [Usage] -mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names - = mapMaybe mkUsage usage_mods + -> IfG [Usage] +mk_mod_usage_info uc home_unit this_mod direct_imports used_names + = mapMaybeM mkUsageM usage_mods where safe_implicit_imps_req = uc_safe_implicit_imps_req uc @@ -234,22 +235,23 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names in extendModuleEnvWith (\_ xs -> occ:xs) mv_map mod' [occ] where occ = nameOccName name + mkUsageM :: Module -> IfG (Maybe Usage) + mkUsageM mod | mod == this_mod = return Nothing + mkUsageM mod = do + iface <- loadSysInterface (text "mk_mod_usage") mod + return $ mkUsage mod iface + + -- We want to create a Usage for a home module if -- a) we used something from it; has something in used_names -- b) we imported it, even if we used nothing from it -- (need to recompile if its export list changes: export_fprint) - mkUsage :: Module -> Maybe Usage - mkUsage mod - | isNothing maybe_iface -- We can't depend on it if we didn't - -- load its interface. - || mod == this_mod -- We don't care about usages of - -- things in *this* module - = Nothing - + mkUsage :: Module -> ModIface -> Maybe Usage + mkUsage mod iface | not (isHomeModule home_unit mod) - = Just UsagePackageModule{ usg_mod = mod, - usg_mod_hash = mod_hash, - usg_safe = imp_safe } + = Just $ UsagePackageModule{ usg_mod = mod, + usg_mod_hash = mod_hash, + usg_safe = imp_safe } -- for package modules, we record the module hash only | (null used_occs @@ -269,11 +271,6 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names usg_entities = Map.toList ent_hashs, usg_safe = imp_safe } where - maybe_iface = lookupIfaceByModule hpt pit mod - -- In one-shot mode, the interfaces for home-package - -- modules accumulate in the PIT not HPT. Sigh. - - Just iface = maybe_iface finsts_mod = mi_finsts (mi_final_exts iface) hash_env = mi_hash_fn (mi_final_exts iface) mod_hash = mi_mod_hash (mi_final_exts iface) ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -222,7 +222,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary -- but if you pass that in here, we'll decide it's the local -- module and does not need to be recorded as a dependency. -- See Note [Identity versus semantic module] - usages <- mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names + usages <- initIfaceLoad hsc_env $ mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names dep_files merged needed_links needed_pkgs docs <- extractDocs (ms_hspp_opts mod_summary) tc_result View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bf83c40c9deaf52bc1a7d51c9fb33a724acbcf99...cc6c7a6004df1549f72ea516baab3e55ae12d735 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bf83c40c9deaf52bc1a7d51c9fb33a724acbcf99...cc6c7a6004df1549f72ea516baab3e55ae12d735 You're receiving 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 Sep 23 13:18:12 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Fri, 23 Sep 2022 09:18:12 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <632db214841f5_3a3c155184c129283e@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: aeff9b06 by Andreas Klebinger at 2022-09-23T15:17:07+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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 ------------------------- Metric Decrease: T1969 ------------------------- - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,8 @@ -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +97,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +267,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1865,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1914,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1933,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2724,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> (LResult a)) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2883,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2936,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2967,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2983,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3023,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3039,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3059,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -2521,12 +2522,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,10 +295,10 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S --- import GHC.Utils.Trace -- $type_classification -- #type_classification# @@ -556,7 +557,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2788,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [nonDetCmpType and type object pointer comparison] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by the same heap +object. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2811,14 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,50 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.CmdLine ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.Backpack.Syntax View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeff9b06f05429b0969e1f44a2a8ae7c9be95cc7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeff9b06f05429b0969e1f44a2a8ae7c9be95cc7 You're receiving 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 Sep 23 14:28:33 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 23 Sep 2022 10:28:33 -0400 Subject: [Git][ghc/ghc][wip/T21717] 57 commits: Add native delimited continuations to the RTS Message-ID: <632dc2912d957_3a3c155182413023b6@gitlab.mail> Sebastian Graf pushed to branch wip/T21717 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - fb9bd6d4 by Sebastian Graf at 2022-09-23T16:22:07+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. The fallout in terms of regressions is small, as the testsuite and NoFib shows. TODO NoFib Fixes #21717. - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/924138272a9b43435c512506a6e7a4ef53bad8f7...fb9bd6d42edd5e823b2b798ba0cd3e71544fd402 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/924138272a9b43435c512506a6e7a4ef53bad8f7...fb9bd6d42edd5e823b2b798ba0cd3e71544fd402 You're receiving 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 Sep 23 14:31:57 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 23 Sep 2022 10:31:57 -0400 Subject: [Git][ghc/ghc][wip/T21717] Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <632dc35d344d5_3a3c155184c1302628@gitlab.mail> Sebastian Graf pushed to branch wip/T21717 at Glasgow Haskell Compiler / GHC Commits: 9c11dbb0 by Sebastian Graf at 2022-09-23T16:31:38+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. The fallout in terms of regressions is small, as the testsuite and NoFib shows. TODO NoFib Fixes #21717. - - - - - 19 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/simplCore/should_compile/T21261.hs - testsuite/tests/simplCore/should_compile/T21261.stderr - − testsuite/tests/simplCore/should_compile/T21261_pedantic.hs - − testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/stranal/should_compile/T18894.stderr - testsuite/tests/stranal/sigs/T20746.stderr - testsuite/tests/stranal/sigs/T21081.stderr - testsuite/tests/stranal/sigs/T21119.stderr - + testsuite/tests/stranal/sigs/T21717.hs - + testsuite/tests/stranal/sigs/T21717.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -509,9 +509,6 @@ this transformation. So we try to limit it as much as possible: Of course both (1) and (2) are readily defeated by disguising the bottoms. -Another place where -fpedantic-bottoms comes up is during eta-reduction. -See Note [Eta reduction soundness], the bit about -fpedantic-bottoms. - 4. Note [Newtype arity] ~~~~~~~~~~~~~~~~~~~~~~~~ Non-recursive newtypes are transparent, and should not get in the way. @@ -2382,20 +2379,13 @@ case where `e` is trivial): `e = \x y. bot`. Could we relax to "*At least one call in the same trace* is with n args"? - (NB: Strictness analysis can only answer this relaxed question, not the - original formulation.) - Consider what happens for + No. Consider what happens for ``g2 c = c True `seq` c False 42`` Here, `g2` will call `c` with 2 arguments (if there is a call at all). But it is unsound to eta-reduce the arg in `g2 (\x y. e x y)` to `g2 e` when `e = \x. if x then bot else id`, because the latter will diverge when - the former would not. - - On the other hand, with `-fno-pedantic-bottoms` , we will have eta-expanded - the definition of `e` and then eta-reduction is sound - (see Note [Dealing with bottom]). - Consequence: We have to check that `-fpedantic-bottoms` is off; otherwise - eta-reduction based on demands is in fact unsound. + the former would not. Fortunately, the strictness analyser will report + "Not always called with two arguments" for `g2` and we won't eta-expand. See Note [Eta reduction based on evaluation context] for the implementation details. This criterion is tested extensively in T21261. @@ -2541,7 +2531,7 @@ Then this is how the pieces are put together: Because it's irrelevant! When we simplify an expression, we do so under the assumption that it is currently under evaluation.) This sub-demand literally says "Whenever this expression is evaluated, it - is also called with two arguments, potentially multiple times". + is called with at least two arguments, potentially multiple times". * Then the simplifier takes apart the lambda and simplifies the lambda group and then calls 'tryEtaReduce' when rebuilding the lambda, passing the ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1643,11 +1643,7 @@ rebuildLam env bndrs body cont mb_rhs = contIsRhs cont -- See Note [Eta reduction based on evaluation context] - eval_sd - | sePedanticBottoms env = topSubDmd - -- See Note [Eta reduction soundness], criterion (S) - -- the bit about -fpedantic-bottoms - | otherwise = contEvalContext cont + eval_sd = contEvalContext cont -- NB: cont is never ApplyToVal, because beta-reduction would -- have happened. So contEvalContext can panic on ApplyToVal. ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -598,26 +598,6 @@ multCard (Card a) (Card b) bit1 = (a .&. b) .&. 0b010 bitN = (a .|. b) .&. shiftL bit1 1 .&. 0b100 --- | Denotes '∪' on lower and '+' on upper bounds of 'Card'. -lubPlusCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -lubPlusCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .|. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = ((a .|. b) .|. shiftL (a .&. b) 1) .&. 0b100 - --- | Denotes '+' on lower and '∪' on upper bounds of 'Card'. -plusLubCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -plusLubCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .&. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = (a .|. b) .&. 0b100 - {- ************************************************************************ * * @@ -626,11 +606,11 @@ plusLubCard (Card a) (Card b) ************************************************************************ -} --- | A demand describes a /scaled evaluation context/, e.g. how many times --- and how deep the denoted thing is evaluated. +-- | A demand describes +-- +-- * How many times a variable is evaluated, via a 'Card'inality, and +-- * How deep its value was evaluated in turn, via a 'SubDemand'. -- --- The "how many" component is represented by a 'Card'inality. --- The "how deep" component is represented by a 'SubDemand'. -- Examples (using Note [Demand notation]): -- -- * 'seq' puts demand @1A@ on its first argument: It evaluates the argument @@ -674,8 +654,8 @@ viewDmdPair BotDmd = (C_10, botSubDmd) viewDmdPair AbsDmd = (C_00, botSubDmd) viewDmdPair (D n sd) = (n, sd) --- | @c :* sd@ is a demand that says \"evaluated @c@ times, and each time it --- was evaluated, it was at least as deep as @sd@\". +-- | @c :* sd@ is a demand that says \"evaluated @c@ times, and any trace in +-- which it is evaluated will evaluate at least as deep as @sd@\". -- -- Matching on this pattern synonym is a complete match. -- If the matched demand was 'AbsDmd', it will match as @C_00 :* seqSubDmd at . @@ -695,8 +675,9 @@ pattern n :* sd <- (viewDmdPair -> (n, sd)) where n :* sd = D n sd & assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) {-# COMPLETE (:*) #-} --- | A sub-demand describes an /evaluation context/, e.g. how deep the --- denoted thing is evaluated. See 'Demand' for examples. +-- | A sub-demand describes an /evaluation context/ (in the sense of an +-- operational semantics), e.g. how deep the denoted thing is going to be +-- evaluated. See 'Demand' for examples. -- -- See Note [SubDemand denotes at least one evaluation] for a more detailed -- description of what a sub-demand means. @@ -714,14 +695,17 @@ data SubDemand -- @Poly b n@ is semantically equivalent to @Prod b [n :* Poly b n, ...] -- or @Call n (Poly Boxed n)@. 'viewCall' and 'viewProd' do these rewrites. -- - -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === CL(L)@, - -- @B === P(B,B,...)@ and @B === CB(B)@, - -- @!A === !P(A,A,...)@ and @!A === !CA(B)@, + -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === C(L)@, + -- @B === P(B,B,...)@ and @B === C(B)@, + -- @!A === !P(A,A,...)@ and @!A === C(A)@, -- and so on. -- -- We'll only see 'Poly' with 'C_10' (B), 'C_00' (A), 'C_0N' (L) and sometimes -- 'C_1N' (S) through 'plusSubDmd', never 'C_01' (M) or 'C_11' (1) (grep the -- source code). Hence 'CardNonOnce', which is closed under 'lub' and 'plus'. + -- + -- Why doesn't this constructor simply carry a 'Demand' instead of its fields? + -- See Note [Call SubDemand vs. evaluation Demand]. | Call !CardNonAbs !SubDemand -- ^ @Call n sd@ describes the evaluation context of @n@ function -- applications (with one argument), where the result of each call is @@ -803,7 +787,7 @@ viewProd _ _ -- equality @Call C_0N (Poly C_0N) === Poly C_0N@, simplifying to 'Poly' 'SubDemand's -- when possible. mkCall :: CardNonAbs -> SubDemand -> SubDemand -mkCall C_1N sd@(Poly Boxed C_1N) = sd +--mkCall C_1N sd@(Poly Boxed C_1N) = sd -- NO! #21085 strikes. See Note [mkCall and plusSubDmd] mkCall C_0N sd@(Poly Boxed C_0N) = sd mkCall n sd = assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) $ Call n sd @@ -838,17 +822,6 @@ unboxDeeplyDmd BotDmd = BotDmd unboxDeeplyDmd dmd@(D n sd) | isStrict n = D n (unboxDeeplySubDmd sd) | otherwise = dmd -multSubDmd :: Card -> SubDemand -> SubDemand -multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod --- The following three equations don't have an impact on Demands, only on --- Boxity. They are needed so that we don't trigger the assertions in `:*` --- when called from `multDmd`. -multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` -multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` -multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality -multSubDmd n (Poly b m) = Poly b (multCard n m) -multSubDmd n (Call n' sd) = mkCall (multCard n n') sd -multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) multDmd :: Card -> Demand -> Demand multDmd C_11 dmd = dmd -- An optimisation @@ -866,170 +839,83 @@ multDmd n BotDmd = if isStrict n then BotDmd else AbsDmd -- See Note [SubDemand denotes at least one evaluation] for the strictifyCard multDmd n (D m sd) = multCard n m :* multSubDmd (strictifyCard n) sd -{- Note [Manual specialisation of lub*Dmd/plus*Dmd] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As Note [SubDemand denotes at least one evaluation] points out, we need all 4 -different combinations of lub/plus demand operations on upper and lower bounds - lubDmd, plusDmd, lubPlusDmd, plusLubDmd -and the same for lubSubDmd, etc. In order to share as much code as possible -and for the programmer to see immediately how the operations differ, we have -one implementation of opDmd (and opSubDmd) that dispatches on a 'OpMode'. - -For good perf, we specialise this one implementation to the four different -modes. So ideally we'd write -``` -lubSubDmd = opSubDmd (Lub, Lub) -opSubDmd (l, u) = ... opSubDmd ... -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -But unfortunately, 'opSubDmd' will be picked as a loop-breaker and thus never -inline into 'lubSubDmd', so its body will never actually be specialised for -the op mode `(Lub, Lub)`. So instead we write -``` -lubSubDmd = opSubDmdInl (Lub, Lub) -opSubDmdInl (l, u) = ... opSubDmd ... -{-# INLINE opSubDmdInl #-} -opSubDmd = opSubDmdInl -{-# RULES "lubSubDmd" forall l r. opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -Here, 'opSubDmdInl' will not be picked as the loop-breaker and thus inline into -'lubSubDmd' and 'opSubDmd'. Since the latter will never inline, we'll specialise -all call sites of 'opSubDmd' for the proper op mode. A nice trick! --} - -data LubOrPlus = Lub | Plus deriving Show -instance Outputable LubOrPlus where ppr = text . show - --- | Determines whether to use 'LubOrPlus' for lower bounds and upper bounds, --- respectively. See Note [Manual specialisation of lub*Dmd/plus*Dmd]. -type OpMode = (LubOrPlus, LubOrPlus) +multSubDmd :: Card -> SubDemand -> SubDemand +multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod +-- The following three equations don't have an impact on Demands, only on +-- Boxity. They are needed so that we don't trigger the assertions in `:*` +-- when called from `multDmd`. +multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` +multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` +multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality +multSubDmd n (Poly b m) = Poly b (multCard n m) +multSubDmd n (Call n' sd) = mkCall (multCard n n') sd +multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) --- | Denotes '∪' on 'SubDemand'. -lubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubSubDmd l r = opSubDmdInl (Lub, Lub) l r +lazifyIfStrict :: Card -> SubDemand -> SubDemand +lazifyIfStrict n sd = multSubDmd (glbCard C_01 n) sd -- | Denotes '∪' on 'Demand'. lubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubDmd l r = opDmdInl (Lub, Lub) l r +lubDmd BotDmd dmd2 = dmd2 +lubDmd dmd1 BotDmd = dmd1 +lubDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "lubDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + lubCard n1 n2 :* lubSubDmd sd1 sd2 --- | Denotes '+' on 'SubDemand'. -plusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusSubDmd l r = opSubDmdInl (Plus, Plus) l r +lubSubDmd :: SubDemand -> SubDemand -> SubDemand +-- Shortcuts for neutral and absorbing elements. +-- Below we assume that Boxed always wins. +lubSubDmd (Poly Unboxed C_10) sd = sd +lubSubDmd sd (Poly Unboxed C_10) = sd +lubSubDmd sd@(Poly Boxed C_0N) _ = sd +lubSubDmd _ sd@(Poly Boxed C_0N) = sd +-- Handle Prod +lubSubDmd (Prod b1 ds1) (Poly b2 n2) + | let !d = polyFieldDmd b2 n2 + = mkProd (lubBoxity b1 b2) (strictMap (lubDmd d) ds1) +lubSubDmd (Prod b1 ds1) (Prod b2 ds2) + | equalLength ds1 ds2 + = mkProd (lubBoxity b1 b2) (strictZipWith lubDmd ds1 ds2) +-- Handle Call +lubSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (lubCard n1 n2) (lubSubDmd sd1 sd2) +-- Handle Poly +lubSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (lubCard n1 n2) +-- Other Poly case by commutativity +lubSubDmd sd1 at Poly{} sd2 = lubSubDmd sd2 sd1 +-- Otherwise (Call `lub` Prod) return Top +lubSubDmd _ _ = topSubDmd -- | Denotes '+' on 'Demand'. plusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusDmd l r = opDmdInl (Plus, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -lubPlusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusSubDmd l r = opSubDmdInl (Lub, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'Demand'. -lubPlusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusDmd l r = opDmdInl (Lub, Plus) l r - --- | Denotes '+' on lower bounds and '∪' on upper bounds on 'SubDemand'. -plusLubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubSubDmd l r = opSubDmdInl (Plus, Lub) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -plusLubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubDmd l r = opDmdInl (Plus, Lub) l r - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -{-# RULES "lubDmd" opDmd (Lub, Lub) = lubDmd #-} -{-# RULES "plusSubDmd" opSubDmd (Plus, Plus) = plusSubDmd #-} -{-# RULES "plusDmd" opDmd (Plus, Plus) = plusDmd #-} -{-# RULES "lubPlusSubDmd" opSubDmd (Lub, Plus) = lubPlusSubDmd #-} -{-# RULES "lubPlusDmd" opDmd (Lub, Plus) = lubPlusDmd #-} -{-# RULES "plusLubSubDmd" opSubDmd (Plus, Lub) = plusLubSubDmd #-} -{-# RULES "plusLubDmd" opDmd (Plus, Lub) = plusLubDmd #-} - --- --- And now the actual implementation that is to be specialised: --- +plusDmd AbsDmd dmd2 = dmd2 +plusDmd dmd1 AbsDmd = dmd1 +plusDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "plusDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + -- Why lazify? See Note [SubDemand denotes at least one evaluation] + plusCard n1 n2 :* plusSubDmd (lazifyIfStrict n1 sd1) (lazifyIfStrict n2 sd2) -neutralCard :: OpMode -> Card -neutralCard (Lub, _) = C_10 -neutralCard (Plus, _) = C_00 -{-# INLINE neutralCard #-} - -absorbingCard :: OpMode -> Card -absorbingCard (Lub, _) = C_0N -absorbingCard (Plus, _) = C_1N -{-# INLINE absorbingCard #-} - -opCard :: OpMode -> Card -> Card -> Card -opCard (Lub, Lub) = lubCard -opCard (Lub, Plus) = lubPlusCard -opCard (Plus, Lub) = plusLubCard -opCard (Plus, Plus) = plusCard -{-# INLINE opCard #-} - -opDmdInl, opDmd :: OpMode -> Demand -> Demand -> Demand -opDmdInl m (n1 :* _) dmd2 | n1 == neutralCard m = dmd2 -opDmdInl m dmd1 (n2 :* _) | n2 == neutralCard m = dmd1 -opDmdInl m@(l,u) (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "opDmd" (\it -> ppr l <+> ppr u $$ ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ - opCard m n1 n2 :* case l of - Lub -> opSubDmd m sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, u) sd1 sd2 -- (D1) - (True, False) -> opSubDmd (Plus, u) sd1 (lazifySubDmd sd2) -- (D2) - (False, True) -> opSubDmd (Plus, u) (lazifySubDmd sd1) sd2 -- (D2) - (False, False) -> opSubDmd (Lub, u) sd1 sd2 -- (D3) - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opDmd = opDmdInl -{-# INLINE opDmdInl #-} -{-# NOINLINE opDmd #-} - -opSubDmdInl, opSubDmd :: OpMode -> SubDemand -> SubDemand -> SubDemand +plusSubDmd :: SubDemand -> SubDemand -> SubDemand -- Shortcuts for neutral and absorbing elements. -- Below we assume that Boxed always wins. -opSubDmdInl m (Poly Unboxed n) sd | n == neutralCard m = sd -opSubDmdInl m sd (Poly Unboxed n) | n == neutralCard m = sd -opSubDmdInl m sd@(Poly Boxed n) _ | n == absorbingCard m = sd -opSubDmdInl m _ sd@(Poly Boxed n) | n == absorbingCard m = sd +plusSubDmd (Poly Unboxed C_00) sd = sd +plusSubDmd sd (Poly Unboxed C_00) = sd +plusSubDmd sd@(Poly Boxed C_1N) _ = sd +plusSubDmd _ sd@(Poly Boxed C_1N) = sd -- Handle Prod -opSubDmdInl m (Prod b1 ds1) (Poly b2 n2) +plusSubDmd (Prod b1 ds1) (Poly b2 n2) | let !d = polyFieldDmd b2 n2 - = mkProd (lubBoxity b1 b2) (strictMap (opDmd m d) ds1) -opSubDmdInl m (Prod b1 ds1) (Prod b2 ds2) + = mkProd (lubBoxity b1 b2) (strictMap (plusDmd d) ds1) +plusSubDmd (Prod b1 ds1) (Prod b2 ds2) | equalLength ds1 ds2 - = mkProd (lubBoxity b1 b2) (strictZipWith (opDmd m) ds1 ds2) + = mkProd (lubBoxity b1 b2) (strictZipWith plusDmd ds1 ds2) -- Handle Call -opSubDmdInl m@(l, _) (Call n1 sd1) (viewCall -> Just (n2, sd2)) = - mkCall (opCard m n1 n2) $! case l of - Lub -> opSubDmd (Lub, Lub) sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]. Usage is always lubbed: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, Lub) sd1 sd2 -- (C3) - (False, True) -> opSubDmd (Plus, Lub) (lazifySubDmd sd1) sd2 -- (C2) - (True, False) -> opSubDmd (Plus, Lub) sd1 (lazifySubDmd sd2) -- (C2) - (False, False) -> opSubDmd (Lub, Lub) sd1 sd2 -- (C1) +plusSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (plusCard n1 n2) (lubSubDmd sd1 sd2) -- Handle Poly -opSubDmdInl m (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (opCard m n1 n2) +plusSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (plusCard n1 n2) -- Other Poly case by commutativity -opSubDmdInl m sd1 at Poly{} sd2 = opSubDmd m sd2 sd1 --- Otherwise (Call `op` Prod) return Top -opSubDmdInl _ _ _ = topSubDmd - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opSubDmd = opSubDmdInl -{-# INLINE opSubDmdInl #-} -{-# NOINLINE opSubDmd #-} +plusSubDmd sd1 at Poly{} sd2 = plusSubDmd sd2 sd1 +-- Otherwise (Call `plus` Prod) return Top +plusSubDmd _ _ = topSubDmd -- | Used to suppress pretty-printing of an uninformative demand isTopDmd :: Demand -> Bool @@ -1129,11 +1015,6 @@ strictifyDictDmd _ dmd = dmd lazifyDmd :: Demand -> Demand lazifyDmd = multDmd C_01 - --- | Make a 'SubDemand' lazy. -lazifySubDmd :: SubDemand -> SubDemand -lazifySubDmd = multSubDmd C_01 - -- | Wraps the 'SubDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCalledOnceDmd :: SubDemand -> SubDemand mkCalledOnceDmd sd = mkCall C_11 sd @@ -1166,7 +1047,7 @@ subDemandIfEvaluated (_ :* sd) = sd mkWorkerDemand :: Int -> Demand mkWorkerDemand n = C_01 :* go n where go 0 = topSubDmd - go n = Call C_01 $ go (n-1) + go n = mkCall C_01 $ go (n-1) argsOneShots :: DmdSig -> Arity -> [[OneShotInfo]] -- ^ See Note [Computing one-shot info] @@ -1242,22 +1123,23 @@ NB: The Premise only makes a difference for lower bounds/strictness. Upper bounds/usage are unaffected by adding or leaving out evaluations that never happen. -So if `x` was demanded with `LP(1L)`, so perhaps `` was - f1 x = (x `seq` case x of (a,b) -> a, True) -then `x` will be evaluated lazily, but any time `x` is evaluated, `e` is -evaluated with sub-demand `P(1L)`, e.g., the first field of `e` is evaluated -strictly, too. +The Premise comes into play when we have lazy Demands. For example, if `x` was +demanded with `LP(SL,A)`, so perhaps the full expression was + let x = (e1, e2) in (x `seq` fun y `seq` case x of (a,b) -> a, True) +then `x` will be evaluated lazily, but in any trace in which `x` is evaluated, +the pair in its RHS will ultimately be evaluated deeply with sub-demand +`P(SL,A)`. That means that `e1` is ultimately evaluated strictly, even though +evaluation of the field does not directly follow the eval of `x` due to the +intermittent call `fun y`. How does the additional strictness help? The long version is in #21081. The short version is - * We get to take advantage of call-by-value/let-to-case in more situations. - See example "More let-to-case" below. + * We get to take advantage of call-by-value/let-to-case in more situations, + as above. See example "More let-to-case" below. * Note [Eta reduction based on evaluation context] applies in more situations. See example "More eta reduction" below. * We get to unbox more results, see example "More CPR" below. - * We prevent annoying issues with `Poly` equalities, #21085. In short, we'd get - `L + S = S = CS(S) < CS(L) = C(L+S)(LuS) = L + CS(S)` although `S = CS(S)`. It seems like we don't give up anything in return. Indeed that is the case: @@ -1271,43 +1153,38 @@ It seems like we don't give up anything in return. Indeed that is the case: well as when expanding absent 'Poly's to 'Call' sub-demands in 'viewCall'. Of course, we now have to maintain the Premise when we unpack and rebuild -SubDemands. For strict demands, we know that the Premise indeed always holds for +Demands. For strict demands, we know that the Premise indeed always holds for any program trace abstracted over, whereas we have to be careful for lazy demands. -That makes for a strange definition of `plusDmd`, where we use `plusSubDmd` -throughout for upper bounds (every eval returns the same, memoised heap object), -but what we do on lower bounds depends on the strictness of both arguments: - - D1 `plusSubDmd` on the nested SubDemands if both args are strict. - D2 `plusSubDmd` on the nested SubDemands if one of them is lazy, which we - *lazify* before (that's new), so that e.g. - `LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L)` - Multiplying with `M`/`C_01` is the "lazify" part here. - Example proving that point: - d2 :: - d2 x y = y `seq` (case x of (a,b) -> a, True) - -- What is demand on x in (d2 x x)? NOT SP(SL)!! - D3 `lubPlusSubDmd` on the nested SubDemands if both args are lazy. - This new operation combines `lubSubDmd` on lower bounds with `plusSubDmd` - on upper bounds. - Examples proving that point: - d3 :: - d3 x y = (case x of (a,b) -> a, y `seq` ()) - -- What is demand on x in `snd (d3 x x)`? - -- Not LP(SL)!! d3 might evaluate second argument but not first. - -- Lub lower bounds because we might evaluate one OR the other. - -Similarly, in the handling of Call SubDemands `Cn(sd)` in `plusSubDmd`, we use -`lub` for upper bounds (because every call returns a fresh heap object), but -what we do for lower bounds depends on whether the outer `n`s are strict: - - C1 `lubSubDmd` on the nested SubDemands if both args are lazy. - C2 `plusLubSubDmd` on the nested `sd`s if one of the `n`s is lazy. That one's - nested `sd` we *lazify*, so that e.g. - `CL(SL) + CS(L) = C(L+S)((M*SL)+L) = CS(L+L) = CS(L)` - `plusLubSubDmd` combines `plusSubDmd` on lower bounds with `lubSubDmd` on - upper bounds. - C3 `plusLubSubDmd` on the nested SubDemands if both args are strict. + +In particular, when doing `plusDmd` we have to *lazify* the nested SubDemand +if the outer cardinality is lazy. E.g., + LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L) +Multiplying with `M`/`C_01` is the "lazify" part here and is implemented in +`lazifyIfStrict`. Example proving that point: + d2 :: + d2 x y = y `seq` (case x of (a,b) -> a, True) + -- What is the demand on x in (d2 x x)? NOT SP(SL)!! + +We used to apply the same reasoning to Call SubDemands `Cn(sd)` in `plusSubDmd`, +but that led to #21717, because different calls return different heap objects. +See Note [Call SubDemand vs. evaluation Demand]. + +There's a wrinkle regarding plusDmd of lazy Demands: +Note that we *could* do better when both Demands are lazy. Example + (fun 1, fun 2) +Both args put Demand SCS(L) on `fun`. The lazy pair arg context lazifies +this to LCS(L), and it would be reasonable to report this Demand on `fun` for +the entire pair expression; after all, `fun` is called whenever it is evaluated. +But our definition of `plusDmd` will compute + LCS(L) + LCS(L) = (L+L)(M*CS(L) + M*CS(L)) = L(CL(L)) = L +Which is clearly less precise. +Doing better here could mean to `lub` when both demands are lazy, e.g., + LCS(L) + LCS(L) = (L+L)(CS(L) ⊔ CS(L)) = L(CS(L)) +Indeed that's what we did at one point between 9.4 and 9.6 after !7599, but it +means that we need a function `lubPlusSubDmd` that lubs on lower bounds but +plus'es upper bounds, implying maintenance challenges and complicated +explanations. There are a couple of other examples in T21081. Here is a selection of examples demonstrating the @@ -1355,6 +1232,79 @@ usefulness of The Premise: pair. That in turn means that Nested CPR can unbox the result of the division even though it might throw. +Note [Call SubDemand vs. evaluation Demand] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Although both evaluation Demands and Call SubDemands carry a (Card,SubDemand) +pair, their interpretation is quite different. Example: + + f x = fst x * snd x + -- f :: , because 1P(1L,A)+1P(A,1L) = SP(1L,1L) + g x = fst (x 1) * snd (x 2) + -- g :: , because 1C1(P(1L,A))+1C1(P(A,1L)) = SCS(P(ML,ML)) + +The point about this example is that both demands have P(A,1L)/P(1L,A) as +sub-expressions, but when these sub-demands occur + + 1. under an evaluation demand, we combine with `plusSubDmd` + 2. whereas under a Call sub-demand, we combine with `lubSubDmd` + +And thus (1) yields a stricter demand on the pair components than (2). + +In #21717 we saw that we really need lub in (2), because otherwise we make an +unsound prediction in `g (\n -> if n == 1 then (1,1) else (bot,2))`; we'd say +that the `bot` expression is always evaluated, when it clearly is not. +Operationally, every call to `g` gives back a potentially distinct, +heap-allocated pair with potentially different contents, and we must `lubSubDmd` +over all such calls to approximate how any of those pairs might be used. + +That is in stark contrast to f's argument `x`: Operationally, every eval of +`x` must yield the same pair and `f` evaluates both components of that pair. +The theorem "every eval of `x` returns the same heap object" is a very strong +MUST-alias property and we capitalise on that by using `plusSubDmd` in (1). + +And indeed we *must* use `plusSubDmd` in (1) for sound upper bounds in an +analysis that assumes call-by-need (as opposed to the weaker call-by-name) for +let bindings. Consider + + h x = fst x * fst x + -- h :: + +And the expression `let a=1; p=(a,a)} in h p`. Here, *although* the RHS of `p` +is only evaluated once under call-by-need, `a` is still evaluated twice. +If we had used `lubSubDmd`, we'd see SP(1L,A) and the 1L unsoundly says "exactly +once". + +If the analysis had assumed call-by-name, it would be sound to say "a is used +once in p": p is used multiple times and hence so would a, as if p was a +function. So using `plusSubDmd` does not only yield better strictness, it is +also "holding up the other end of the bargain" of the call-by-need assumption +for upper bounds. + +(To SG's knowledge, the distinction between call-by-name and call-by-need does +not matter for strictness analysis/lower bounds, thus it would be sound to use +`lubSubDmd` all the time there.) + +Note [mkCall and plusSubDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We never rewrite a strict, non-absent Call sub-demand like CS(S) to a +polymorphic sub-demand like S, otherwise #21085 strikes. Consider the +following inequality (would also for M and 1 instead of L and S, but we forbid +such Polys): + + L+S = S = CS(S) < CS(L) = CL(L)+CS(S) + +Note that L=CL(L). If we also had S=CS(S), we'd be in trouble: Now +`plusSubDmd` would no longer maintain the equality relation on sub-demands, +much less monotonicity. Bad! + +Clearly, `n <= Cn(n)` is unproblematic, as is `n >= Cn(n)` for any `n` +except 1 and S. But `CS(S) >= S` would mean trouble, because then we'd get +the problematic `CS(S) = S`. We have just established that `S < CS(S)`! +As such, the rewrite CS(S) to S is anti-monotone and we forbid it, first +and foremost in `mkCall` (which is the only place that rewrites Cn(n) to n). + +Crisis and #21085 averted! + Note [Computing one-shot info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a call @@ -2102,7 +2052,7 @@ If this same function is applied to one arg, all we can say is that it uses x with 1L, and its arg with demand 1P(L,L). Note [Understanding DmdType and DmdSig] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Demand types are sound approximations of an expression's semantics relative to the incoming demand we put the expression under. Consider the following expression: ===================================== testsuite/tests/arityanal/should_compile/Arity11.stderr ===================================== @@ -53,7 +53,7 @@ F11.fib1 = GHC.Num.Integer.IS 0# -- RHS size: {terms: 52, types: 26, coercions: 0, joins: 0/5} F11.$wfib [InlPrag=[2]] :: forall {t} {a}. (t -> t -> Bool) -> (Num t, Num a) => t -> a -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] F11.$wfib = \ (@t) (@a) (ww :: t -> t -> Bool) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> let { @@ -91,7 +91,7 @@ F11.$wfib fib [InlPrag=[2]] :: forall {t} {a}. (Eq t, Num t, Num a) => t -> a [GblId, Arity=4, - Str=<1P(SCS(C1(L)),A)>, + Str=<1P(SCS(C1(L)),A)>, 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= \ (@t) (@a) ($dEq [Occ=Once1!] :: Eq t) ($dNum [Occ=Once1] :: Num t) ($dNum1 [Occ=Once1] :: Num a) (eta [Occ=Once1] :: t) -> case $dEq of { GHC.Classes.C:Eq ww [Occ=Once1] _ [Occ=Dead] -> F11.$wfib @t @a ww $dNum $dNum1 eta }}] fib = \ (@t) (@a) ($dEq :: Eq t) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> case $dEq of { GHC.Classes.C:Eq ww ww1 -> F11.$wfib @t @a ww $dNum $dNum1 eta } @@ -142,4 +142,7 @@ f11 :: (Integer, Integer) f11 = (F11.f4, F11.f1) +------ Local rules for imported ids -------- +"SPEC fib @Integer @Integer" forall ($dEq :: Eq Integer) ($dNum :: Num Integer) ($dNum1 :: Num Integer). fib @Integer @Integer $dEq $dNum $dNum1 = F11.f11_fib + ===================================== testsuite/tests/arityanal/should_compile/Arity14.stderr ===================================== @@ -14,7 +14,7 @@ F14.f2 = GHC.Num.Integer.IS 1# -- RHS size: {terms: 35, types: 23, coercions: 0, joins: 0/3} F14.$wf14 [InlPrag=[2]] :: forall {t}. (t -> t -> Bool) -> Num t => t -> t -> t -> t -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] F14.$wf14 = \ (@t) (ww :: t -> t -> Bool) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> let { @@ -41,7 +41,7 @@ F14.$wf14 f14 [InlPrag=[2]] :: forall {t}. (Ord t, Num t) => t -> t -> t -> t [GblId, Arity=4, - Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, + Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, 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= \ (@t) ($dOrd [Occ=Once1!] :: Ord t) ($dNum [Occ=Once1] :: Num t) (eta [Occ=Once1] :: t) (eta1 [Occ=Once1] :: t) -> case $dOrd of { GHC.Classes.C:Ord _ [Occ=Dead] _ [Occ=Dead] ww2 [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> F14.$wf14 @t ww2 $dNum eta eta1 }}] f14 = \ (@t) ($dOrd :: Ord t) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> case $dOrd of { GHC.Classes.C:Ord ww ww1 ww2 ww3 ww4 ww5 ww6 ww7 -> F14.$wf14 @t ww2 $dNum eta eta1 } ===================================== testsuite/tests/arityanal/should_compile/Arity16.stderr ===================================== @@ -5,7 +5,7 @@ Result size of Tidy Core = {terms: 53, types: 71, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 15, types: 15, coercions: 0, joins: 0/0} map2 [Occ=LoopBreaker] :: forall {t} {a}. (t -> a) -> [t] -> [a] -[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] map2 = \ (@t) (@a) (f :: t -> a) (ds :: [t]) -> case ds of { @@ -27,7 +27,7 @@ lvl1 = Control.Exception.Base.patError @GHC.Types.LiftedRep @() lvl Rec { -- RHS size: {terms: 31, types: 32, coercions: 0, joins: 0/0} zipWith2 [Occ=LoopBreaker] :: forall {t1} {t2} {a}. (t1 -> t2 -> a) -> [t1] -> [t2] -> [a] -[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] zipWith2 = \ (@t) (@t1) (@a) (f :: t -> t1 -> a) (ds :: [t]) (ds1 :: [t1]) -> case ds of { ===================================== testsuite/tests/simplCore/should_compile/T21261.hs ===================================== @@ -34,18 +34,26 @@ f5 c = Just (c 1 2 + c 3 4) yes2_lazy :: (Int -> Int -> Int) -> Maybe Int yes2_lazy c = f5 (\x y -> c x y) --- These last two here are disallowed in T21261_pedantic.hs, which activates --- -fpedantic-bottoms. It would be unsound to eta reduce these bindings with --- -fpedantic-bottoms, but without it's fine to eta reduce: +-- These last two here are tricky. It is unsound to eta reduce +-- the args to f6 and f7 because we could call both functions +-- at a c like `\x -> if x == 1 then undefined else id`. +-- Note that if we do so and *do* eta-reduce, we'll see a crash! +-- Whereas we *don't* see a crash if we keep the original, +-- eta-expanded arguments. +-- +-- This is issue is discussed in Note [Eta reduction soundness], condition (S). +-- +-- This is a variant of #21717 (and tested by T21717), where +-- prior to the fix we observed an unsound strictness signature. f6 :: (Int -> Int -> Int) -> Int f6 c = c 1 `seq` c 2 3 {-# NOINLINE f6 #-} -yes_non_pedantic :: (Int -> Int -> Int) -> Int -yes_non_pedantic c = f6 (\x y -> c x y) +no_tricky :: (Int -> Int -> Int) -> Int +no_tricky c = f6 (\x y -> c x y) f7 :: (Int -> Int -> Int) -> Maybe Int f7 c = Just (c 1 `seq` c 3 4) {-# NOINLINE f7 #-} -yes_non_pedantic_lazy :: (Int -> Int -> Int) -> Maybe Int -yes_non_pedantic_lazy c = f7 (\x y -> c x y) +no_tricky_lazy :: (Int -> Int -> Int) -> Maybe Int +no_tricky_lazy c = f7 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 166, types: 176, coercions: 0, joins: 0/0} + = {terms: 182, types: 191, coercions: 0, joins: 0/0} lvl = I# 3# @@ -29,13 +29,14 @@ no3 f6 = \ c -> case c lvl2 of { __DEFAULT -> c lvl3 lvl } -yes_non_pedantic = f6 +no_tricky = \ c -> f6 (\ x y -> c x y) $wf7 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl lvl1 } #) f7 = \ c -> case $wf7 c of { (# ww #) -> Just ww } -yes_non_pedantic_lazy = f7 +no_tricky_lazy + = \ c -> case $wf7 (\ x y -> c x y) of { (# ww #) -> Just ww } $wf5 = \ c -> ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.hs deleted ===================================== @@ -1,18 +0,0 @@ -{-# OPTIONS_GHC -fpedantic-bottoms #-} -- This flag must inhibit eta reduction based on demands - -module T21261_pedantic where - --- README: See T21261. These examples absolutely should not eta reduce with --- -fpedantic-bottoms. - -f1 :: (Int -> Int -> Int) -> Int -f1 c = c 1 `seq` c 2 3 -{-# NOINLINE f1 #-} -no2 :: (Int -> Int -> Int) -> Int -no2 c = f1 (\x y -> c x y) - -f2 :: (Int -> Int -> Int) -> Maybe Int -f2 c = Just (c 1 `seq` c 3 4) -{-# NOINLINE f2 #-} -no2_lazy :: (Int -> Int -> Int) -> Maybe Int -no2_lazy c = f2 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr deleted ===================================== @@ -1,26 +0,0 @@ - -==================== Tidy Core ==================== -Result size of Tidy Core - = {terms: 59, types: 63, coercions: 0, joins: 0/0} - -lvl = I# 2# - -lvl1 = I# 3# - -lvl2 = I# 1# - -f1 = \ c -> case c lvl2 of { __DEFAULT -> c lvl lvl1 } - -no2 = \ c -> f1 (\ x y -> c x y) - -lvl3 = I# 4# - -$wf2 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl1 lvl3 } #) - -f2 = \ c -> case $wf2 c of { (# ww #) -> Just ww } - -no2_lazy - = \ c -> case $wf2 (\ x y -> c x y) of { (# ww #) -> Just ww } - - - ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -407,8 +407,7 @@ test('T21144', normal, compile, ['-O']) test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. -test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) -test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # We expect to see a SPEC rule for $cm test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/stranal/should_compile/T18894.stderr ===================================== @@ -147,7 +147,7 @@ lvl :: (Int, Int) lvl = (lvl, lvl) -- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} -g1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] :: Int -> (Int, Int) +g1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: Int -> (Int, Int) [LclId, Arity=1, Str=<1!P(1L)>, @@ -266,7 +266,7 @@ lvl = GHC.Types.I# 0# -- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} $wg2 [InlPrag=NOINLINE, Dmd=LCS(C1(!P(M!P(L),1!P(L))))] :: Int -> GHC.Prim.Int# -> (# Int, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -328,9 +328,9 @@ h2 } -- RHS size: {terms: 34, types: 14, coercions: 0, joins: 0/1} -$wg1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] +$wg1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -367,7 +367,7 @@ lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} $wh1 [InlPrag=[2], Dmd=LCS(!P(L))] :: GHC.Prim.Int# -> Int -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, ===================================== testsuite/tests/stranal/sigs/T20746.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -Foo.f: +Foo.f: Foo.foogle: ===================================== testsuite/tests/stranal/sigs/T21081.stderr ===================================== @@ -4,7 +4,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: T21081.blurg2: T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: @@ -50,7 +50,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: <1!P(SL)> T21081.blurg2: <1!P(SL)> T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: ===================================== testsuite/tests/stranal/sigs/T21119.stderr ===================================== @@ -4,7 +4,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x @@ -24,7 +24,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x ===================================== testsuite/tests/stranal/sigs/T21717.hs ===================================== @@ -0,0 +1,22 @@ +-- {-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# OPTIONS_GHC -O -fforce-recomp #-} +-- {-# LANGUAGE PatternSynonyms #-} +-- {-# LANGUAGE BangPatterns #-} +-- {-# LANGUAGE MagicHash, UnboxedTuples #-} + +module Main (g, main) where + +f :: Bool -> (Int, Int) +f True = (42,error "m") +f False = (error "m",42) + +g :: (Bool -> (Int, Int)) -> Int +g f = fst (f True) + snd (f False) +{-# NOINLINE g #-} + +makeUp :: IO Int +makeUp = pure 42 +{-# NOINLINE makeUp #-} + +main = do + print $ g f ===================================== testsuite/tests/stranal/sigs/T21717.stderr ===================================== @@ -0,0 +1,21 @@ + +==================== Strictness signatures ==================== +:Main.main: +Main.g: +Main.main: + + + +==================== Cpr signatures ==================== +:Main.main: +Main.g: 1 +Main.main: + + + +==================== Strictness signatures ==================== +:Main.main: +Main.g: +Main.main: + + ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -T5075.f: +T5075.f: T5075.g: <1L> T5075.h: @@ -14,7 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> +T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> T5075.g: <1L> T5075.h: <1!P(L)> ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -33,5 +33,6 @@ test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) +test('T21717', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c11dbb0673f0e74b8f09a5ee431d2501847dfe2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9c11dbb0673f0e74b8f09a5ee431d2501847dfe2 You're receiving 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 Sep 23 16:42:50 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 23 Sep 2022 12:42:50 -0400 Subject: [Git][ghc/ghc][wip/T21623] More wibbles Message-ID: <632de20ab0c7d_3a3c155184c13244e0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 00011c3c by Simon Peyton Jones at 2022-09-23T17:44:46+01:00 More wibbles - - - - - 13 changed files: - compiler/GHC/Core/ConLike.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Types/Basic.hs - testsuite/tests/ghci/scripts/T16575.stdout - testsuite/tests/simplCore/should_compile/T12603.stdout - testsuite/tests/simplCore/should_compile/T15631.stdout Changes: ===================================== compiler/GHC/Core/ConLike.hs ===================================== @@ -185,10 +185,14 @@ conLikeResTy (PatSynCon ps) tys = patSynInstResTy ps tys -- -- 7) The original result type conLikeFullSig :: ConLike - -> ([TyVar], [TyCoVar], [EqSpec] + -> ([TyVar], [TyCoVar] -- Why tyvars for universal but tycovars for existential? -- See Note [Existential coercion variables] in GHC.Core.DataCon - , ThetaType, ThetaType, [Scaled Type], Type) + , [EqSpec] + , ThetaType -- Provided theta + , ThetaType -- Required theta + , [Scaled Type] -- Arguments + , Type ) -- Result conLikeFullSig (RealDataCon con) = let (univ_tvs, ex_tvs, eq_spec, theta, arg_tys, res_ty) = dataConFullSig con -- Required theta is empty as normal data cons require no additional ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1610,9 +1610,9 @@ lintTyCoBndr tcv thing_inside -- See (FORALL1) and (FORALL2) in GHC.Core.Type ; if (isTyVar tcv) then -- Check that in (forall (a:ki). blah) we have ki:Type - lintL (tcIsLiftedTypeKind (typeKind tcv_type')) $ - hang (text "TyCoVar whose kind does not have kind Type") - 2 (ppr tcv' <+> dcolon <+> ppr (typeKind tcv_type')) + lintL (isLiftedTypeKind (typeKind tcv_type')) $ + hang (text "TyVar whose kind does not have kind Type:") + 2 (ppr tcv' <+> dcolon <+> ppr tcv_type' <+> dcolon <+> ppr (typeKind tcv_type')) else -- Check that in (forall (cv::ty). blah), -- then ty looks like (t1 ~# t2) lintL (isCoVarType tcv_type') $ ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -664,7 +664,7 @@ kindRep_maybe kind | Just (_, rep) <- sORTKind_maybe kind = Just rep | otherwise = Nothing --- | Returns True if the argument is a lifted type or constraint +-- | Returns True if the argument is (lifted) Type or Constraint -- See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim isLiftedTypeKind :: Kind -> Bool isLiftedTypeKind kind @@ -2517,38 +2517,19 @@ seqTypes (ty:tys) = seqType ty `seq` seqTypes tys Note [Kinding rules for types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here are the kinding rules for types - - torc1 is TYPE or CONSTRAINT - torc2 is TYPE or CONSTRAINT - t1 : torc1 rep1 - t2 : torc2 rep2 - (FUN) ---------------- - t1 -> t2 : torc2 LiftedRep - - ty : TYPE rep - `a` is not free in rep -(FORALL) ----------------------- - forall a. ty : TYPE rep - - t1 : TYPE rep1 - t2 : TYPE rep2 - (FUN) ---------------- - t1 -> t2 : Type - - t1 : Constraint - t2 : TYPE rep - (PRED1) ---------------- - t1 => t2 : Type - - t1 : Constraint - t2 : Constraint - (PRED2) --------------------- - t1 => t2 : Constraint +Here are the key kinding rules for types + + torc1 is TYPE or CONSTRAINT + torc2 is TYPE or CONSTRAINT + t1 : torc1 rep1 + t2 : torc2 rep2 + (FUN) ---------------- + t1 -> t2 : torc2 LiftedRep torc is TYPE or CONSTRAINT ty : body_torc rep - ki : Type + bndr_torc is Type or Constraint + ki : bndr_torc `a` is a type variable `a` is not free in rep (FORALL1) ----------------------- @@ -2556,6 +2537,7 @@ Here are the kinding rules for types torc is TYPE or CONSTRAINT ty : body_torc rep + `c` is a coercion variable `c` is not free in rep `c` is free in ty -- Surprise 1! (FORALL2) ------------------------- @@ -2565,6 +2547,10 @@ Here are the 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] ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -388,11 +388,11 @@ deriving instance Data (HsUntypedSplice GhcPs) deriving instance Data (HsUntypedSplice GhcRn) deriving instance Data (HsUntypedSplice GhcTc) -deriving instance Data (HsUntypedSpliceResult (HsExpr GhcRn)) +--deriving instance Data (HsUntypedSpliceResult (HsExpr GhcRn)) -deriving instance Data (HsUntypedSpliceResult (Pat GhcRn)) +--deriving instance Data (HsUntypedSpliceResult (Pat GhcRn)) -deriving instance Data (HsUntypedSpliceResult (HsType GhcRn)) +deriving instance Data a => Data (HsUntypedSpliceResult a) -- deriving instance (DataIdLR p p) => Data (HsQuote p) deriving instance Data (HsQuote GhcPs) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -316,7 +316,7 @@ type instance XKindSig (GhcPass _) = EpAnn [AddEpAnn] type instance XAppKindTy (GhcPass _) = SrcSpan -- Where the `@` lives type instance XSpliceTy GhcPs = NoExtField -type instance XSpliceTy GhcRn = HsUntypedSpliceResult (HsType GhcRn) +type instance XSpliceTy GhcRn = HsUntypedSpliceResult (LHsType GhcRn) type instance XSpliceTy GhcTc = Kind type instance XDocTy (GhcPass _) = EpAnn [AddEpAnn] @@ -1139,8 +1139,7 @@ ppr_mono_ty (HsQualTy { hst_ctxt = ctxt, hst_body = ty }) ppr_mono_ty (HsBangTy _ b ty) = ppr b <> ppr_mono_lty ty ppr_mono_ty (HsRecTy _ flds) = pprConDeclFields flds -ppr_mono_ty (HsTyVar _ prom (L _ name)) = pprTrace "ppr_mono" (ppr name) $ - pprOccWithTick Prefix prom name +ppr_mono_ty (HsTyVar _ prom (L _ name)) = pprOccWithTick Prefix prom name ppr_mono_ty (HsFunTy _ mult ty1 ty2) = ppr_fun_ty mult ty1 ty2 ppr_mono_ty (HsTupleTy _ con tys) -- Special-case unary boxed tuples so that they are pretty-printed as ===================================== compiler/GHC/Rename/Splice.hs ===================================== @@ -33,7 +33,7 @@ import GHC.Rename.Unbound ( isUnboundName ) import GHC.Rename.Module ( rnSrcDecls, findSplice ) import GHC.Rename.Pat ( rnPat ) import GHC.Types.Error -import GHC.Types.Basic ( TopLevelFlag, isTopLevel ) +import GHC.Types.Basic ( TopLevelFlag, isTopLevel, maxPrec ) import GHC.Types.SourceText ( SourceText(..) ) import GHC.Utils.Outputable import GHC.Unit.Module @@ -673,23 +673,31 @@ rnSpliceType splice = ( makePending UntypedTypeSplice name rn_splice , HsSpliceTy (HsUntypedSpliceNested name) rn_splice) + run_type_splice :: HsUntypedSplice GhcRn -> RnM (HsType GhcRn, FreeVars) run_type_splice rn_splice = do { traceRn "rnSpliceType: untyped type splice" empty ; (hs_ty2, mod_finalizers) <- runRnSplice UntypedTypeSplice runMetaT ppr rn_splice ; (hs_ty3, fvs) <- do { let doc = SpliceTypeCtx hs_ty2 ; checkNoErrs $ rnLHsType doc hs_ty2 } - -- checkNoErrs: see Note [Renamer errors] + -- checkNoErrs: see Note [Renamer errors] + -- See Note [Delaying modFinalizers in untyped splices]. - ; return ( HsParTy noAnn - $ flip HsSpliceTy rn_splice - . HsUntypedSpliceTop (ThModFinalizers mod_finalizers) - <$> hs_ty3 + ; return ( HsSpliceTy (HsUntypedSpliceTop (ThModFinalizers mod_finalizers) + (mb_paren hs_ty3)) + rn_splice , fvs ) } -- Wrap the result of the splice in parens so that we don't -- lose the outermost location set by runQuasiQuote (#7918) + -- Wrap a non-atomic result in HsParTy parens; + -- but not if it's atomic to avoid double parens for operators + mb_paren :: LHsType GhcRn -> LHsType GhcRn + mb_paren lhs_ty@(L loc hs_ty) + | hsTypeNeedsParens maxPrec hs_ty = L loc (HsParTy noAnn lhs_ty) + | otherwise = lhs_ty + {- Note [Partial Type Splices] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Partial Type Signatures are partially supported in TH type splices: only ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1046,7 +1046,7 @@ tc_infer_hs_type mode (HsKindSig _ ty sig) -- -- See Note [Delaying modFinalizers in untyped splices]. tc_infer_hs_type mode (HsSpliceTy (HsUntypedSpliceTop _ ty) _) - = tc_infer_hs_type mode ty + = tc_infer_lhs_type mode ty tc_infer_hs_type _ (HsSpliceTy (HsUntypedSpliceNested n) s) = pprPanic "tc_infer_hs_type: invalid nested splice" (pprUntypedSplice True (Just n) s) @@ -1150,7 +1150,7 @@ tc_hs_type _ ty@(HsRecTy {}) _ tc_hs_type mode (HsSpliceTy (HsUntypedSpliceTop mod_finalizers ty) _) exp_kind = do addModFinalizersWithLclEnv mod_finalizers - tc_hs_type mode ty exp_kind + tc_lhs_type mode ty exp_kind tc_hs_type _ (HsSpliceTy (HsUntypedSpliceNested n) s) _ = pprPanic "tc_hs_type: invalid nested splice" (pprUntypedSplice True (Just n) s) ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -316,7 +316,7 @@ no_anon_wc_ty lty = go lty && go ty HsQualTy { hst_ctxt = ctxt , hst_body = ty } -> gos (unLoc ctxt) && go ty - HsSpliceTy (HsUntypedSpliceTop _ ty) _ -> go $ L noSrcSpanA ty + HsSpliceTy (HsUntypedSpliceTop _ ty) _ -> go ty HsSpliceTy (HsUntypedSpliceNested _) _ -> True HsTyLit{} -> True HsTyVar{} -> True ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -85,8 +85,6 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Control.Monad -import GHC.Utils.Trace - {- ************************************************************************ * * @@ -887,8 +885,7 @@ mkRecSelBind (tycon, fl) mkOneRecordSelector :: [ConLike] -> RecSelParent -> FieldLabel -> FieldSelectors -> (Id, LHsBind GhcRn) mkOneRecordSelector all_cons idDetails fl has_sel - = pprTrace "mkOneRec" (ppr con1 $$ ppr sel_name $$ ppr field_ty $$ ppr data_ty $$ ppr is_naughty) - (sel_id, L (noAnnSrcSpan loc) sel_bind) + = (sel_id, L (noAnnSrcSpan loc) sel_bind) where loc = getSrcSpan sel_name loc' = noAnnSrcSpan loc @@ -1039,9 +1036,28 @@ helpfully, rather than saying unhelpfully that 'x' is not in scope. Hence the sel_naughty flag, to identify record selectors that don't really exist. In general, a field is "naughty" if its type mentions a type variable that -isn't in the result type of the constructor. Note that this *allows* -GADT record selectors (Note [GADT record selectors]) whose types may look -like sel :: T [a] -> a +isn't in + * the (original, user-written) result type of the constructor, or + * the "required theta" for the constructor + +Note that this *allows* GADT record selectors (Note [GADT record +selectors]) whose types may look like sel :: T [a] -> a + +The "required theta" part is illustrated by test patsyn/should_run/records_run +where we have + + pattern ReadP :: Read a => a -> String + pattern ReadP {readp} <- (read -> readp) + +The selector is defined like this: + + $selreadp :: ReadP a => String -> a + $selReadP s = readp s + +Perfectly fine! The (ReadP a) constraint lets us contructor a value +of type 'a' from a bare String. NB: "required theta" is empty for +data cons (see conLikeFullSig), so this reasoning only bites for +patttern synonyms. For naughty selectors we make a dummy binding sel = () ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -49,7 +49,8 @@ module GHC.Types.Basic ( CbvMark(..), isMarkedCbv, - PprPrec(..), topPrec, sigPrec, opPrec, funPrec, starPrec, appPrec, + PprPrec(..), topPrec, sigPrec, opPrec, funPrec, + starPrec, appPrec, maxPrec, maybeParen, TupleSort(..), tupleSortBoxity, boxityTupleSort, @@ -744,16 +745,17 @@ pprSafeOverlap False = empty newtype PprPrec = PprPrec Int deriving (Eq, Ord, Show) -- See Note [Precedence in types] -topPrec, sigPrec, funPrec, opPrec, starPrec, appPrec :: PprPrec -topPrec = PprPrec 0 -- No parens -sigPrec = PprPrec 1 -- Explicit type signatures -funPrec = PprPrec 2 -- Function args; no parens for constructor apps - -- See [Type operator precedence] for why both - -- funPrec and opPrec exist. -opPrec = PprPrec 2 -- Infix operator +topPrec, sigPrec, funPrec, opPrec, starPrec, appPrec, maxPrec :: PprPrec +topPrec = PprPrec 0 -- No parens +sigPrec = PprPrec 1 -- Explicit type signatures +funPrec = PprPrec 2 -- Function args; no parens for constructor apps + -- See [Type operator precedence] for why both + -- funPrec and opPrec exist. +opPrec = PprPrec 2 -- Infix operator starPrec = PprPrec 3 -- Star syntax for the type of types, i.e. the * in (* -> *) -- See Note [Star kind precedence] appPrec = PprPrec 4 -- Constructor args; no parens for atomic +maxPrec = appPrec -- Maximum precendence maybeParen :: PprPrec -> PprPrec -> SDoc -> SDoc maybeParen ctxt_prec inner_prec pretty ===================================== testsuite/tests/ghci/scripts/T16575.stdout ===================================== @@ -1,5 +1,4 @@ -Loaded package environment from /home/simonpj/.ghc/x86_64-linux-9.5.20220920/environments/default -GHCi, version 9.5.20220920: https://www.haskell.org/ghc/ :? for help +GHCi, version 9.5.20220917: https://www.haskell.org/ghc/ :? for help ghci> ghci> [1 of 1] Compiling Ghost ( T16575.hs, interpreted ) Ok, one module loaded. Collecting type info for 1 module(s) ... @@ -9,15 +8,15 @@ T16575.hs:(4,15)-(4,18): [Ghost.X] -> GHC.Show.ShowS T16575.hs:(7,7)-(7,8): Ghost.X -> Ghost.X -> GHC.Types.Bool T16575.hs:(6,10)-(6,13): Ghost.X -> Ghost.X -> GHC.Types.Bool T16575.hs:(4,15)-(4,18): GHC.Show.Show Ghost.X -T16575.hs:(4,15)-(4,18): ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X -T16575.hs:(4,15)-(4,18): (Ghost.X -> GHC.Base.String) -> ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X -T16575.hs:(4,15)-(4,18): (GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS) -> (Ghost.X -> GHC.Base.String) -> ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X +T16575.hs:(4,15)-(4,18): ([Ghost.X] -> GHC.Show.ShowS) -=> GHC.Show.Show Ghost.X +T16575.hs:(4,15)-(4,18): (Ghost.X -> GHC.Base.String) -=> ([Ghost.X] -> GHC.Show.ShowS) -=> GHC.Show.Show Ghost.X +T16575.hs:(4,15)-(4,18): (GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS) -=> (Ghost.X -> GHC.Base.String) -=> ([Ghost.X] -> GHC.Show.ShowS) -=> GHC.Show.Show Ghost.X T16575.hs:(4,15)-(4,18): GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS T16575.hs:(4,15)-(4,18): Ghost.X -> GHC.Base.String T16575.hs:(4,15)-(4,18): [Ghost.X] -> GHC.Show.ShowS T16575.hs:(6,10)-(6,13): GHC.Classes.Eq Ghost.X -T16575.hs:(6,10)-(6,13): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> GHC.Classes.Eq Ghost.X -T16575.hs:(6,10)-(6,13): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> GHC.Classes.Eq Ghost.X +T16575.hs:(6,10)-(6,13): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -=> GHC.Classes.Eq Ghost.X +T16575.hs:(6,10)-(6,13): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -=> (Ghost.X -> Ghost.X -> GHC.Types.Bool) -=> GHC.Classes.Eq Ghost.X T16575.hs:(6,10)-(6,13): Ghost.X -> Ghost.X -> GHC.Types.Bool T16575.hs:(6,10)-(6,13): Ghost.X -> Ghost.X -> GHC.Types.Bool T16575.hs:(7,14)-(7,17): GHC.Types.Bool ===================================== testsuite/tests/simplCore/should_compile/T12603.stdout ===================================== @@ -1 +1 @@ -lvl = case GHC.Real.$wf1 2# 8# of v { __DEFAULT -> GHC.Types.I# v } + = case GHC.Real.$wf1 2# 8# of v { __DEFAULT -> ===================================== testsuite/tests/simplCore/should_compile/T15631.stdout ===================================== @@ -1,7 +1,7 @@ case GHC.List.$wlenAcc @a (Foo.f2 @a) 0# of v { __DEFAULT -> case GHC.List.$wlenAcc @a xs 0# of ww1 { __DEFAULT -> case GHC.List.reverse1 @a xs (GHC.Types.[] @a) of { - [] -> case Foo.f1 @a of { GHC.Types.I# v1 -> GHC.Prim.+# ww1 v1 }; + case Foo.f1 @a of { GHC.Types.MkIntBox v1 -> GHC.Prim.+# ww1 v1 }; case GHC.List.$wlenAcc case Foo.$wf @a xs of ww [Occ=Once1] { __DEFAULT -> case Foo.$wf @a xs of ww { __DEFAULT -> GHC.Types.I# ww } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00011c3c6fcbb9ebfbe8a954860d80ebefd4d99c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/00011c3c6fcbb9ebfbe8a954860d80ebefd4d99c You're receiving 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 Sep 23 18:49:17 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 23 Sep 2022 14:49:17 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Object: Add documentation Message-ID: <632dffadc7ee3_3a3c1551824133337c@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: f2304e40 by doyougnu at 2022-09-23T14:48:20-04:00 StgToJS.Object: Add documentation - - - - - 1 changed file: - compiler/GHC/StgToJS/Object.hs Changes: ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -90,12 +90,18 @@ import GHC.Utils.Outputable (ppr, Outputable, hcat, vcat, text) import GHC.Utils.Panic import GHC.Utils.Monad (mapMaybeM) +-- | An object file data Object = Object { objModuleName :: !ModuleName - , objHandle :: !BinHandle -- ^ BinHandle that can be used to read the ObjUnits - , objPayloadOffset :: !(Bin ObjUnit) -- ^ Offset of the payload (units) + -- ^ name of the module + , objHandle :: !BinHandle + -- ^ BinHandle that can be used to read the ObjUnits + , objPayloadOffset :: !(Bin ObjUnit) + -- ^ Offset of the payload (units) , objDeps :: !Deps + -- ^ Dependencies , objIndex :: !Index + -- ^ The Index, serialed unit indices and their linkable units } type BlockId = Int @@ -141,9 +147,10 @@ data BlockDeps = BlockDeps isGlobalUnit :: Int -> Bool isGlobalUnit n = n == 0 +-- | Exported Functions data ExportedFun = ExportedFun - { funModule :: !Module - , funSymbol :: !LexicalFastString + { funModule :: !Module -- ^ The module containing the function + , funSymbol :: !LexicalFastString -- ^ The function } deriving (Eq, Ord) instance Outputable ExportedFun where @@ -176,6 +183,8 @@ getObjUnit syms bh = do pure (ObjUnit syms b c d e f g) +-- | A tag that determines the kind of payload in the .o file. See +-- @StgToJS.Linker.Arhive.magic@ for another kind of magic magic :: String magic = "GHCJSOBJ" @@ -187,10 +196,13 @@ data IndexEntry = IndexEntry , idxOffset :: !(Bin ObjUnit) -- ^ Offset of the unit in the object file } -instance Binary IndexEntry where - put_ bh (IndexEntry a b) = put_ bh a >> put_ bh b - get bh = IndexEntry <$> get bh <*> get bh +-------------------------------------------------------------------------------- +-- Essential oeprations on Objects +-------------------------------------------------------------------------------- + +-- | Given a handle to a Binary payload, add the module, 'mod_name', its +-- dependencies, 'deps', and its linkable units to the payload. putObject :: BinHandle -> ModuleName -- ^ module @@ -287,12 +299,60 @@ readObject file = do bh <- readBinMem file getObject bh +-- | Reads only the part necessary to get the dependencies +readObjectDeps :: FilePath -> IO Deps +readObjectDeps file = do + bh <- readBinMem file + obj <- getObject bh + pure $! objDeps obj + +-- | Get units in the object file, using the given filtering function +getObjectUnits :: Object -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] +getObjectUnits obj pred = mapMaybeM read_entry (zip (objIndex obj) [0..]) + where + bh = objHandle obj + read_entry (e@(IndexEntry syms offset),i) + | pred i e = do + seekBin bh offset + Just <$> getObjUnit syms bh + | otherwise = pure Nothing + +-- | Read units in the object file, using the given filtering function +readObjectUnits :: FilePath -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] +readObjectUnits file pred = do + obj <- readObject file + getObjectUnits obj pred + + +-------------------------------------------------------------------------------- +-- Helper functions +-------------------------------------------------------------------------------- + +putEnum :: Enum a => BinHandle -> a -> IO () +putEnum bh x | n > 65535 = error ("putEnum: out of range: " ++ show n) + | otherwise = put_ bh n + where n = fromIntegral $ fromEnum x :: Word16 + +getEnum :: Enum a => BinHandle -> IO a +getEnum bh = toEnum . fromIntegral <$> (get bh :: IO Word16) + +-- | Helper to convert Int to Int32 toI32 :: Int -> Int32 toI32 = fromIntegral +-- | Helper to convert Int32 to Int fromI32 :: Int32 -> Int fromI32 = fromIntegral + +-------------------------------------------------------------------------------- +-- Binary Instances +-------------------------------------------------------------------------------- + +instance Binary IndexEntry where + put_ bh (IndexEntry a b) = put_ bh a >> put_ bh b + get bh = IndexEntry <$> get bh <*> get bh + instance Binary Deps where put_ bh (Deps m r e b) = do put_ bh m @@ -317,31 +377,6 @@ instance Binary ExpFun where put_ bh (ExpFun isIO args res) = put_ bh isIO >> put_ bh args >> put_ bh res get bh = ExpFun <$> get bh <*> get bh <*> get bh --- | Reads only the part necessary to get the dependencies -readObjectDeps :: FilePath -> IO Deps -readObjectDeps file = do - bh <- readBinMem file - obj <- getObject bh - pure $! objDeps obj - - --- | Get units in the object file, using the given filtering function -getObjectUnits :: Object -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] -getObjectUnits obj pred = mapMaybeM read_entry (zip (objIndex obj) [0..]) - where - bh = objHandle obj - read_entry (e@(IndexEntry syms offset),i) - | pred i e = do - seekBin bh offset - Just <$> getObjUnit syms bh - | otherwise = pure Nothing - --- | Read units in the object file, using the given filtering function -readObjectUnits :: FilePath -> (Word -> IndexEntry -> Bool) -> IO [ObjUnit] -readObjectUnits file pred = do - obj <- readObject file - getObjectUnits obj pred - instance Binary JStat where put_ bh (DeclStat i) = putByte bh 1 >> put_ bh i put_ bh (ReturnStat e) = putByte bh 2 >> put_ bh e @@ -501,15 +536,6 @@ instance Binary ExportedFun where put_ bh (ExportedFun modu symb) = put_ bh modu >> put_ bh symb get bh = ExportedFun <$> get bh <*> get bh - -putEnum :: Enum a => BinHandle -> a -> IO () -putEnum bh x | n > 65535 = error ("putEnum: out of range: " ++ show n) - | otherwise = put_ bh n - where n = fromIntegral $ fromEnum x :: Word16 - -getEnum :: Enum a => BinHandle -> IO a -getEnum bh = toEnum . fromIntegral <$> (get bh :: IO Word16) - instance Binary StaticInfo where put_ bh (StaticInfo ident val cc) = put_ bh ident >> put_ bh val >> put_ bh cc get bh = StaticInfo <$> get bh <*> get bh <*> get bh View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f2304e401ff2ed1241355b64e8e1ac91b6b6d7ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f2304e401ff2ed1241355b64e8e1ac91b6b6d7ce You're receiving 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 Sep 23 21:49:02 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 23 Sep 2022 17:49:02 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/determ024-test Message-ID: <632e29ce6399e_3a3c15513d813452fa@gitlab.mail> Matthew Pickering pushed new branch wip/determ024-test at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/determ024-test You're receiving 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 Sep 23 22:16:29 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 23 Sep 2022 18:16:29 -0400 Subject: [Git][ghc/ghc][wip/hackage-bindist] 17 commits: Add `Eq` and `Ord` instances for `Generically1` Message-ID: <632e303de7500_3a3c15513d8135021c@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 0238585f by Matthew Pickering at 2022-09-23T22:56:29+01: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 - - - - - bb9138a4 by Matthew Pickering at 2022-09-23T22:56:29+01:00 Add test for #22162 - - - - - dc0fd95b by Matthew Pickering at 2022-09-23T22:56:29+01:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - b73d5e91 by Matthew Pickering at 2022-09-23T22:56:29+01:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - a5b8b2fd by Matthew Pickering at 2022-09-23T23:16:16+01:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Stg/InferTags/Rewrite.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Name/Cache.hs - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Unit/Types.hs-boot - compiler/GHC/Utils/Binary.hs - compiler/GHC/Utils/Outputable.hs - − compiler/GHC/Utils/Outputable.hs-boot - docs/users_guide/codegens.rst - docs/users_guide/ghci.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc6c7a6004df1549f72ea516baab3e55ae12d735...a5b8b2fdfbf966720a060b3ee7d70a8d00b4f06f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc6c7a6004df1549f72ea516baab3e55ae12d735...a5b8b2fdfbf966720a060b3ee7d70a8d00b4f06f You're receiving 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 Sep 24 08:08:09 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Sat, 24 Sep 2022 04:08:09 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Refactor Expr Message-ID: <632ebae9fda1_3a3c15514001396334@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: a5c074c8 by Sylvain Henry at 2022-09-24T10:11:14+02:00 Refactor Expr - - - - - fc880b1b by Sylvain Henry at 2022-09-24T10:11:14+02:00 Object: reduce pinned allocation. And don't forget to hClose invalid objects - - - - - 3 changed files: - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Object.hs - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -74,6 +74,7 @@ import qualified Data.Map as M import Control.Monad import Control.Arrow ((&&&)) +-- | Evaluate an expression in the given expression context (continuation) genExpr :: HasDebugCallStack => ExprCtx -> CgStgExpr -> G (JStat, ExprResult) genExpr ctx stg = case stg of StgApp f args -> genApp ctx f args @@ -287,17 +288,32 @@ genBody :: HasDebugCallStack -> CgStgExpr -> G JStat genBody ctx i startReg args e = do - la <- loadArgs startReg args + -- load arguments into local variables + la <- do + args' <- concatMapM genIdArgI args + return (declAssignAll args' (fmap toJExpr [startReg..])) + + -- assert that arguments have valid runtime reps lav <- verifyRuntimeReps args - let ids :: [TypedExpr] - ids = -- take (resultSize args $ idType i) jsRegsFromR1 - reverse . fst $ - foldl' (\(rs, vs) (rep, size) -> - let (vs0, vs1) = splitAt size vs - in (TypedExpr rep vs0:rs,vs1)) - ([], jsRegsFromR1) - (resultSize args $ idType i) - (e, _r) <- genExpr (ctx { ctxTarget = ids }) e + + -- compute PrimReps and their number of slots required to return the result of + -- i applied to args. + let res_vars = resultSize args (idType i) + + -- compute typed expressions for each slot and assign registers + let go_var regs = \case + [] -> [] + ((rep,size):rs) -> + let !(regs0,regs1) = splitAt size regs + !ts = go_var regs1 rs + in TypedExpr rep regs0 : ts + + let tgt = go_var jsRegsFromR1 res_vars + let !ctx' = ctx { ctxTarget = tgt } + + -- generate code for the expression + (e, _r) <- genExpr ctx' e + return $ la <> lav <> e <> returnStack -- find the result type after applying the function to the arguments @@ -339,11 +355,6 @@ resultSize [] t where t' = unwrapType t -loadArgs :: HasDebugCallStack => StgReg -> [Id] -> G JStat -loadArgs start args = do - args' <- concatMapM genIdArgI args - return (declAssignAll args' (fmap toJExpr [start..])) - verifyRuntimeReps :: HasDebugCallStack => [Id] -> G JStat verifyRuntimeReps xs = do runtime_assert <- csRuntimeAssert <$> getSettings ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -72,6 +72,9 @@ import Data.Map (Map) import qualified Data.Map as M import Data.Word import Data.Char +import Foreign.Storable +import Foreign.Marshal.Array +import System.IO import GHC.Settings.Constants (hiVersion) @@ -235,20 +238,28 @@ putObject bh mod_name deps os = do -- | Test if the object file is a JS object isJsObjectFile :: FilePath -> IO Bool -isJsObjectFile fp = - readBinMemN (length magic) fp >>= \case - Nothing -> pure False - Just bh -> getCheckMagic bh +isJsObjectFile fp = do + let !n = length magic + withBinaryFile fp ReadMode $ \hdl -> do + allocaArray n $ \ptr -> do + n' <- hGetBuf hdl ptr n + if (n' /= n) + then pure False + else checkMagic (peekElemOff ptr) + +-- | Check magic +checkMagic :: (Int -> IO Word8) -> IO Bool +checkMagic get_byte = do + let go_magic !i = \case + [] -> pure True + (e:es) -> get_byte i >>= \case + c | fromIntegral (ord e) == c -> go_magic (i+1) es + | otherwise -> pure False + go_magic 0 magic -- | Parse object magic getCheckMagic :: BinHandle -> IO Bool -getCheckMagic bh = do - let go_magic = \case - [] -> pure True - (e:es) -> getByte bh >>= \case - c | fromIntegral (ord e) == c -> go_magic es - | otherwise -> pure False - go_magic magic +getCheckMagic bh = checkMagic (const (getByte bh)) -- | Parse object header getObjectHeader :: BinHandle -> IO (Either String ModuleName) ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -289,19 +289,19 @@ writeBinMem (BinMem _ ix_r _ arr_r) fn = do readBinMem :: FilePath -> IO BinHandle readBinMem filename = do - h <- openBinaryFile filename ReadMode - filesize' <- hFileSize h - let filesize = fromIntegral filesize' - readBinMem_ filesize h + withBinaryFile filename ReadMode $ \h -> do + filesize' <- hFileSize h + let filesize = fromIntegral filesize' + readBinMem_ filesize h readBinMemN :: Int -> FilePath -> IO (Maybe BinHandle) readBinMemN size filename = do - h <- openBinaryFile filename ReadMode - filesize' <- hFileSize h - let filesize = fromIntegral filesize' - if filesize < size - then pure Nothing - else Just <$> readBinMem_ size h + withBinaryFile filename ReadMode $ \h -> do + filesize' <- hFileSize h + let filesize = fromIntegral filesize' + if filesize < size + then pure Nothing + else Just <$> readBinMem_ size h readBinMem_ :: Int -> Handle -> IO BinHandle readBinMem_ filesize h = do @@ -309,7 +309,6 @@ readBinMem_ filesize h = do count <- unsafeWithForeignPtr arr $ \p -> hGetBuf h p filesize when (count /= filesize) $ error ("Binary.readBinMem: only read " ++ show count ++ " bytes") - hClose h arr_r <- newIORef arr ix_r <- newFastMutInt 0 sz_r <- newFastMutInt filesize View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2304e401ff2ed1241355b64e8e1ac91b6b6d7ce...fc880b1bed25ff401820d269821dd3d7eaafd358 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2304e401ff2ed1241355b64e8e1ac91b6b6d7ce...fc880b1bed25ff401820d269821dd3d7eaafd358 You're receiving 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 Sep 26 09:20:06 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 26 Sep 2022 05:20:06 -0400 Subject: [Git][ghc/ghc][wip/T21623] 44 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <63316ec6db3fc_3a3c155184c16435f5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 8c65f023 by Simon Peyton Jones at 2022-09-26T09:05:13+01: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 - - - - - b6af59e8 by Simon Peyton Jones at 2022-09-26T09:05:13+01:00 Revert accidental changes in SameOccInfo fixes mod180, tcfail182 - - - - - faed51e0 by Simon Peyton Jones at 2022-09-26T09:05:44+01:00 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare - - - - - 5714552f by Simon Peyton Jones at 2022-09-26T09:05:44+01:00 Wibbles - - - - - b8107715 by Simon Peyton Jones at 2022-09-26T09:05:44+01:00 More wibbles Reaedy for RAE review - - - - - 1aebc073 by Simon Peyton Jones at 2022-09-26T09:05:44+01:00 Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] - - - - - 3b1e966b by Simon Peyton Jones at 2022-09-26T09:05:44+01:00 Wibbles - - - - - 552c1abe by Simon Peyton Jones at 2022-09-26T09:05:44+01:00 More wibbles - - - - - b6747a88 by Simon Peyton Jones at 2022-09-26T10:21:51+01:00 Update Haddock submodule - - - - - 23 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/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Axiom.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00011c3c6fcbb9ebfbe8a954860d80ebefd4d99c...b6747a88dc7af9321cfcb1a681a4c1b6db14df10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00011c3c6fcbb9ebfbe8a954860d80ebefd4d99c...b6747a88dc7af9321cfcb1a681a4c1b6db14df10 You're receiving 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 Sep 26 10:18:38 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 26 Sep 2022 06:18:38 -0400 Subject: [Git][ghc/ghc][wip/T21623] Remove unused import Message-ID: <63317c7e7549e_3a3c15513d81655853@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 42707eab by Simon Peyton Jones at 2022-09-26T11:20:29+01:00 Remove unused import - - - - - 1 changed file: - compiler/GHC/Core/Type.hs Changes: ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -290,7 +290,7 @@ import GHC.Data.FastString import GHC.Data.Maybe ( orElse, isJust ) import Control.Monad ( guard ) -import qualified Data.Semigroup as S + -- import GHC.Utils.Trace -- $type_classification View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/42707eaba8e8b6901b4b7d3b74600119361d0c11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/42707eaba8e8b6901b4b7d3b74600119361d0c11 You're receiving 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 Sep 26 10:50:45 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 26 Sep 2022 06:50:45 -0400 Subject: [Git][ghc/ghc][wip/T21623] Remove another unused import Message-ID: <633184056294c_3a3c155184c16639b0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: e25f42f0 by Simon Peyton Jones at 2022-09-26T11:52:10+01:00 Remove another unused import - - - - - 1 changed file: - compiler/GHC/Hs/Type.hs Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -115,7 +115,6 @@ import GHC.Types.Basic import GHC.Types.SrcLoc import GHC.Utils.Outputable import GHC.Utils.Misc (count) -import GHC.Utils.Trace import Data.Maybe import Data.Data (Data) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e25f42f0cd0848e06ad840a6d4037e0d63ed4cd7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e25f42f0cd0848e06ad840a6d4037e0d63ed4cd7 You're receiving 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 Sep 26 11:19:06 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 07:19:06 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: Fix pdep (cgrun075) Message-ID: <63318aaa45302_3a3c155181016749a6@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: e9831504 by Sylvain Henry at 2022-09-26T12:39:32+02:00 Fix pdep (cgrun075) - - - - - c1e516ea by Sylvain Henry at 2022-09-26T12:41:27+02:00 Fix error message (don't mention emscripten) - - - - - 807a0131 by Sylvain Henry at 2022-09-26T13:22:17+02:00 Add Float/Word casts - - - - - 3 changed files: - compiler/GHC/Driver/Backend.hs - libraries/base/jsbits/base.js - rts/js/mem.js Changes: ===================================== compiler/GHC/Driver/Backend.hs ===================================== @@ -463,7 +463,7 @@ backendDescription :: Backend -> String backendDescription (Named NCG) = "native code generator" backendDescription (Named LLVM) = "LLVM" backendDescription (Named ViaC) = "compiling via C" -backendDescription (Named JavaScript) = "compiling to JavaScript via emscripten" +backendDescription (Named JavaScript) = "compiling to JavaScript" backendDescription (Named Interpreter) = "byte-code interpreter" backendDescription (Named NoBackend) = "no code generated" ===================================== libraries/base/jsbits/base.js ===================================== @@ -780,3 +780,28 @@ function h$stg_sig_install(sigNo, actionCode, sigSet_d, sigSet_o) { // XXX dummy implementation return 0; } + +const h$word_float_conv_buf = new DataView(new ArrayBuffer(8)); + +function h$stg_word32ToFloatzh(v) { + h$word_float_conv_buf.setUint32(0, v); + return h$word_float_conv_buf.getFloat32(0); +} + +function h$stg_floatToWord32zh(v) { + h$word_float_conv_buf.setFloat32(0, v); + return h$word_float_conv_buf.getUint32(0); +} + +function h$stg_word64ToDoublezh(h,l) { + h$word_float_conv_buf.setUint32(0, h); + h$word_float_conv_buf.setUint32(4, l); + return h$word_float_conv_buf.getFloat64(0); +} + +function h$stg_doubleToWord64zh(v) { + h$word_float_conv_buf.setFloat64(0, v); + var l = h$word_float_conv_buf.getUint32(4); + var h = h$word_float_conv_buf.getUint32(0); + RETURN_UBX_TUP2(h,l); +} ===================================== rts/js/mem.js ===================================== @@ -1338,7 +1338,7 @@ function h$pdep32(src, mask) { k++; } } - return dst; + return (dst >>> 0); } function h$pdep64(src_b, src_a, mask_b, mask_a) { @@ -1360,7 +1360,7 @@ function h$pdep64(src_b, src_a, mask_b, mask_a) { k++; } } - RETURN_UBX_TUP2(dst_b, dst_a); + RETURN_UBX_TUP2((dst_b >>> 0), (dst_a >>> 0)); } function h$pext8(src, mask) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc880b1bed25ff401820d269821dd3d7eaafd358...807a0131c33b0e0457b484083154572070bf5b61 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc880b1bed25ff401820d269821dd3d7eaafd358...807a0131c33b0e0457b484083154572070bf5b61 You're receiving 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 Sep 26 11:51:25 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 07:51:25 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Disable HPC tests with JS backend Message-ID: <6331923d5a53b_3a3c155184c168139d@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: c2991bc0 by Sylvain Henry at 2022-09-26T13:54:32+02:00 Disable HPC tests with JS backend - - - - - 1 changed file: - testsuite/config/ghc Changes: ===================================== testsuite/config/ghc ===================================== @@ -8,16 +8,17 @@ import re # config.compiler_always_flags = ghc_compiler_always_flags.split() -# By default, the 'normal' and 'hpc' ways are enabled. In addition, certain +# By default, the 'normal' way is enabled. In addition, certain # ways are enabled automatically if this GHC supports them. Ways that fall in -# this group are 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', +# this group are 'hpc', 'optasm', 'optllvm', 'profasm', 'threaded1', 'threaded2', # 'profthreaded', 'ghci', and whichever of 'static/dyn' is not this GHC's # default mode. Other ways should be set explicitly from .T files. -config.compile_ways = ['normal', 'hpc'] -config.run_ways = ['normal', 'hpc'] +config.compile_ways = ['normal'] +config.run_ways = ['normal'] # ways that are not enabled by default, but can always be invoked explicitly -config.other_ways = ['prof', 'normal_h', +config.other_ways = ['hpc', + 'prof', 'normal_h', 'prof_hc_hb','prof_hb', 'prof_hd','prof_hy','prof_hr', 'sanity', @@ -34,6 +35,7 @@ config.other_ways = ['prof', 'normal_h', 'compacting_gc', ] + if ghc_with_native_codegen: config.compile_ways.append('optasm') config.run_ways.append('optasm') @@ -65,6 +67,16 @@ if windows: else: config.other_ways += winio_ways +# LLVM +if not config.unregisterised and not config.arch == "js" and config.have_llvm: + config.compile_ways.append('optllvm') + config.run_ways.append('optllvm') + +# HPC +if not config.arch == "js": + config.compile_ways.append('hpc') + config.run_ways.append('hpc') + config.way_flags = { 'normal' : [], 'normal_h' : [], @@ -180,15 +192,6 @@ llvm_ways = [x[0] for x in config.way_flags.items() def get_compiler_info(): - if config.unregisterised: - print("Unregisterised build; skipping LLVM ways...") - elif config.arch == "js": - print("JavaScript backend; skipping LLVM ways...") - elif config.have_llvm: - config.compile_ways.append('optllvm') - config.run_ways.append('optllvm') - else: - print("Failed to find `llc` command; skipping LLVM ways...") # Whether GHC itself was built using the LLVM backend. We need to know this # since some tests in ext-interp fail when stage2 ghc is built using View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2991bc0e278b19d1a6174fb3002c0066bce1b54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2991bc0e278b19d1a6174fb3002c0066bce1b54 You're receiving 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 Sep 26 12:11:58 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Mon, 26 Sep 2022 08:11:58 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/clc-85 Message-ID: <6331970ebd6b9_3a3c15513c416841b0@gitlab.mail> Ryan Scott pushed new branch wip/clc-85 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/clc-85 You're receiving 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 Sep 26 12:16:44 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 08:16:44 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Fix encodeDouble/Float Message-ID: <6331982c8aa28_3a3c155181016925f2@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 980a3103 by Sylvain Henry at 2022-09-26T14:19:55+02:00 Fix encodeDouble/Float - - - - - 1 changed file: - rts/js/arith.js Changes: ===================================== rts/js/arith.js ===================================== @@ -616,20 +616,20 @@ function h$decodeDoubleInt64(d) { function h$__int_encodeDouble(j,e) { if (!j) return 0; - return (j|0) ** (e|0); + return (j|0) * (2 ** (e|0)); } function h$__word_encodeDouble(j,e) { if (!j) return 0; - return (j>>>0) ** (e|0); + return (j>>>0) * (2 ** (e|0)); } function h$__int_encodeFloat(j,e) { if (!j) return 0; - return h$fround((j|0) ** (e|0)); + return h$fround((j|0) * (2 ** (e|0))); } function h$__word_encodeFloat(j,e) { if (!j) return 0; - return h$fround((j>>>0) ** (e|0)); + return h$fround((j>>>0) * (2 ** (e|0))); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/980a3103036aebf41c1c647b443b995143330533 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/980a3103036aebf41c1c647b443b995143330533 You're receiving 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 Sep 26 12:44:18 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 08:44:18 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Implement putchar (fix cgrun015) Message-ID: <63319ea2e4406_3a3c1551838170394d@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 3c7fb646 by Sylvain Henry at 2022-09-26T14:47:28+02:00 Implement putchar (fix cgrun015) - - - - - 1 changed file: - libraries/base/jsbits/base.js Changes: ===================================== libraries/base/jsbits/base.js ===================================== @@ -805,3 +805,12 @@ function h$stg_doubleToWord64zh(v) { var h = h$word_float_conv_buf.getUint32(0); RETURN_UBX_TUP2(h,l); } + + +const h$putchar_buf = h$newByteArray(1); + +function h$putchar(c) { + h$putchar_buf.u8[0] = c; + h$base_write(1, h$putchar_buf, 0, 1, null); + return h$errno; +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c7fb6463c1101c33a6fa81c647213766e27308b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c7fb6463c1101c33a6fa81c647213766e27308b You're receiving 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 Sep 26 13:32:37 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 26 Sep 2022 09:32:37 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] 57 commits: Add native delimited continuations to the RTS Message-ID: <6331a9f528e6e_3a3c159493c1201710259@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 91202a0b by Simon Peyton Jones at 2022-09-26T14:31:44+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 quite a bit, but the trend is slightly down Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change ------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 4,566,082,536 -25.0% GOOD T10421(normal) ghc/alloc 111,994,304 116,148,544 +3.7% BAD T10421a(normal) ghc/alloc 79,150,034 83,423,664 +5.4% T10547(normal) ghc/alloc 28,211,501 28,177,960 -0.1% T12545(normal) ghc/alloc 1,633,149,272 1,614,005,512 -1.2% T13253(normal) ghc/alloc 343,592,469 347,635,808 +1.2% T14052(ghci) ghc/alloc 3,681,055,512 3,749,063,688 +1.8% T15304(normal) ghc/alloc 1,295,512,578 1,277,067,608 -1.4% T16577(normal) ghc/alloc 8,050,423,421 8,291,093,504 +3.0% BAD T17516(normal) ghc/alloc 1,800,051,592 1,840,575,008 +2.3% T17836(normal) ghc/alloc 829,913,981 812,805,232 -2.1% T17836b(normal) ghc/alloc 45,437,680 45,057,120 -0.8% T18223(normal) ghc/alloc 734,732,288 646,329,352 -12.0% GOOD T3064(normal) ghc/alloc 180,023,717 182,061,608 +1.1% T9630(normal) ghc/alloc 1,523,682,706 1,492,863,632 -2.0% GOOD T9961(normal) ghc/alloc 358,760,821 368,223,992 +2.6% BAD geo. mean -0.3% minimum -25.0% maximum +5.4% Metric Decrease: LargeRecord T18223 T9630 Metric Increase: T10421 T16577 T9961 - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55a9bb78a92b7f8cc1bf8786ce74426adccfc763...91202a0b506e823f9d00af4b4f2918dbb433b03c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/55a9bb78a92b7f8cc1bf8786ce74426adccfc763...91202a0b506e823f9d00af4b4f2918dbb433b03c You're receiving 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 Sep 26 14:17:29 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 10:17:29 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Fix decoding of denormalized floats Message-ID: <6331b479d2306_2c9757514783946@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: abf77718 by Sylvain Henry at 2022-09-26T16:20:38+02:00 Fix decoding of denormalized floats - - - - - 1 changed file: - rts/js/arith.js Changes: ===================================== rts/js/arith.js ===================================== @@ -335,12 +335,9 @@ var h$convertInt = new Int32Array(h$convertBuffer); // use direct inspection through typed array for decoding floating point numbers if this test gives // the expected answer. fixme: does this test catch all non-ieee or weird endianness situations? h$convertFloat[0] = 0.75; -// h$convertFloat[0] = 1/0; // to force using fallbacks -var h$decodeFloatInt = h$convertInt[0] === 1061158912 ? h$decodeFloatIntArray : h$decodeFloatIntFallback; -var h$decodeDouble2Int = h$convertInt[0] === 1061158912 ? h$decodeDouble2IntArray : h$decodeDouble2IntFallback; -function h$decodeFloatIntArray(d) { - TRACE_ARITH("decodeFloatIntArray: " + d); +function h$decodeFloatInt(d) { + TRACE_ARITH("decodeFloatInt: " + d); if(isNaN(d)) { RETURN_UBX_TUP2(-12582912, 105); } @@ -351,47 +348,29 @@ function h$decodeFloatIntArray(d) { var s = i&8388607; if(exp === 0) { // zero or denormal if(s === 0) { - TRACE_ARITH("decodeFloatIntArray s: 0 e: 0"); + TRACE_ARITH("decodeFloatInt s: 0 e: 0"); RETURN_UBX_TUP2(0, 0); } else { - h$convertFloat[0] = d*8388608; + h$convertFloat[0] = d*8388608; // put d in the normal range (~ shift left 23 bits) i = h$convertInt[0]; - TRACE_ARITH("decodeFloatIntArray s: " + (sgn * (i&8388607)) + " e: " + ((i&2139095040) >> 23) - 173); - RETURN_UBX_TUP2(sgn*(i&8388607), ((i&2139095040) >> 23) - 173) + s = (i&8388607) | 8388608; + e = ((i >> 23) & 0xff) - 173; // take into account normalization above (150+23) + TRACE_ARITH("decodeFloatInt s: " + (sgn * s) + " e: " + e); + RETURN_UBX_TUP2(sgn*s, e) } } else { - TRACE_ARITH("decodeFloatIntArray s: " + (sgn * (s|8388608)) + " e: " + (exp-150)); + TRACE_ARITH("decodeFloatInt s: " + (sgn * (s|8388608)) + " e: " + (exp-150)); RETURN_UBX_TUP2(sgn * (s|8388608), exp - 150); } } -function h$decodeFloatIntFallback(d) { - TRACE_ARITH("decodeFloatIntFallback: " + d); - if(isNaN(d)) { - RETURN_UBX_TUP2(-12582912, 105); - } - var ret0, ret1; - CALL_UBX_TUP2(ret0, ret1, h$integer_cmm_decodeDoublezhFallback(d)); - var exponent = ret0 + 29; - var significand = ret1.shiftRight(28).add(h$bigOne).shiftRight(1).intValue(); - if(exponent > 105) { - exponent = 105; - significand = d > 0 ? 8388608 : -8388608; - } else if(exponent < -151 || significand === 0) { - significand = 0; - exponent = 0; - } - TRACE_ARITH("decodeFloatIntFallback s: " + significand + " e: " + exponent); - RETURN_UBX_TUP2(significand, exponent); -} - -function h$decodeDouble2IntArray(d) { - TRACE_ARITH("decodeDouble2IntArray: " + d); +function h$decodeDouble2Int(d) { + TRACE_ARITH("decodeDouble2Int: " + d); if(isNaN(d)) { RETURN_UBX_TUP4(1, -1572864, 0, 972); } h$convertDouble[0] = d; - TRACE_ARITH("decodeDouble2IntArray binary: " + h$convertInt[0].toString(2) + " " + h$convertInt[1].toString(2)); + TRACE_ARITH("decodeDouble2Int binary: " + h$convertInt[0].toString(2) + " " + h$convertInt[1].toString(2)); var i1 = h$convertInt[1]; var ret1, ret2 = h$convertInt[0], ret3; var exp = (i1&2146435072)>>>20; @@ -410,26 +389,10 @@ function h$decodeDouble2IntArray(d) { ret3 = exp-1075; ret1 = (i1&1048575)|1048576; } - TRACE_ARITH("decodeDouble2IntArray: exp: " + ret3 + " significand: " + ret1 + " " + ret2); + TRACE_ARITH("decodeDouble2Int: exp: " + ret3 + " significand: " + ret1 + " " + ret2); RETURN_UBX_TUP4(i1<0?-1:1,ret1,ret2,ret3); } -function h$decodeDouble2IntFallback(d) { - TRACE_ARITH("decodeDouble2IntFallback: " + d); - if(isNaN(d)) { - RETURN_UBX_TUP4(1,-1572864,0,972); - } - var exponent, significand; - CALL_UBX_TUP2(exponent, significand, h$integer_cmm_decodeDoublezhFallback(d)); - var sign = d<0?-1:1; - var s = significand.abs(); - var ret1 = s.shiftRight(32).intValue(); - var ret2 = s.intValue(); - var ret3 = exponent; - TRACE_ARITH("decodeDouble2IntFallback: exp: " + ret3 + " significand: " + ret1 + " " + ret2); - RETURN_UBX_TUP4(sign, ret1, ret2, ret3); -} - // round .5 to nearest even number function h$rintDouble(a) { var rounda = Math.round(a); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abf77718cf5df1d10062bcc15de0d867175e8515 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abf77718cf5df1d10062bcc15de0d867175e8515 You're receiving 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 Sep 26 14:54:16 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 10:54:16 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: Fix isFloatDenormalized function Message-ID: <6331bd18c99f1_2c9757dfd40501bb@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 651959f8 by Sylvain Henry at 2022-09-26T16:41:37+02:00 Fix isFloatDenormalized function - - - - - 93f450a7 by Sylvain Henry at 2022-09-26T16:56:39+02:00 Reuse convert buffer - - - - - 711ddddf by Sylvain Henry at 2022-09-26T16:57:28+02:00 Reuse convert buffer bis - - - - - 2 changed files: - libraries/base/jsbits/base.js - rts/js/arith.js Changes: ===================================== libraries/base/jsbits/base.js ===================================== @@ -781,32 +781,6 @@ function h$stg_sig_install(sigNo, actionCode, sigSet_d, sigSet_o) { return 0; } -const h$word_float_conv_buf = new DataView(new ArrayBuffer(8)); - -function h$stg_word32ToFloatzh(v) { - h$word_float_conv_buf.setUint32(0, v); - return h$word_float_conv_buf.getFloat32(0); -} - -function h$stg_floatToWord32zh(v) { - h$word_float_conv_buf.setFloat32(0, v); - return h$word_float_conv_buf.getUint32(0); -} - -function h$stg_word64ToDoublezh(h,l) { - h$word_float_conv_buf.setUint32(0, h); - h$word_float_conv_buf.setUint32(4, l); - return h$word_float_conv_buf.getFloat64(0); -} - -function h$stg_doubleToWord64zh(v) { - h$word_float_conv_buf.setFloat64(0, v); - var l = h$word_float_conv_buf.getUint32(4); - var h = h$word_float_conv_buf.getUint32(0); - RETURN_UBX_TUP2(h,l); -} - - const h$putchar_buf = h$newByteArray(1); function h$putchar(c) { ===================================== rts/js/arith.js ===================================== @@ -324,13 +324,18 @@ function h$isDoubleDenormalized(d) { } function h$isFloatDenormalized(d) { - return (d !== 0 && Math.abs(d) < 2.2250738585072014e-308) ? 1 : 0; + h$convertFloat[0] = d; + var i = h$convertInt[0]; + var exp = (i >> 23) & 0xff; + var s = i&8388607; + return ((s !== 0 && exp === 0) ? 1 : 0); } var h$convertBuffer = new ArrayBuffer(8); var h$convertDouble = new Float64Array(h$convertBuffer); var h$convertFloat = new Float32Array(h$convertBuffer); var h$convertInt = new Int32Array(h$convertBuffer); +var h$convertWord = new Uint32Array(h$convertBuffer); // use direct inspection through typed array for decoding floating point numbers if this test gives // the expected answer. fixme: does this test catch all non-ieee or weird endianness situations? @@ -524,7 +529,6 @@ function h$ctz64(x1,x2) { } var h$fround = null; -var h$truncateFloat_buf = null; if(typeof Math.fround === 'function') { h$fround = function(f) { TRACE_ARITH("fround (native): " + f); @@ -533,9 +537,8 @@ if(typeof Math.fround === 'function') { } else { h$fround = function(f) { TRACE_ARITH("fround (buffer): " + f); - if(!h$truncateFloat_buf) h$truncateFloat_buf = new Float32Array(1); - h$truncateFloat_buf[0] = f; - return h$truncateFloat_buf[0]; + h$convertFloat[0] = f; + return h$convertFloat[0]; } } @@ -596,3 +599,26 @@ function h$__word_encodeFloat(j,e) { if (!j) return 0; return h$fround((j>>>0) * (2 ** (e|0))); } + +function h$stg_word32ToFloatzh(v) { + h$convertWord[0] = v; + return h$convertFloat[0]; +} + +function h$stg_floatToWord32zh(v) { + h$convertFloat[0] = v; + return h$convertWord[0]; +} + +function h$stg_word64ToDoublezh(h,l) { + h$convertWord[0] = l; + h$convertWord[1] = h; + return h$convertDouble[0]; +} + +function h$stg_doubleToWord64zh(v) { + h$convertDouble[0] = v; + var l = h$convertWord[0]; + var h = h$convertWord[1]; + RETURN_UBX_TUP2(h,l); +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/abf77718cf5df1d10062bcc15de0d867175e8515...711ddddfa9ddc88643a73ff91d9151b9920f8077 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/abf77718cf5df1d10062bcc15de0d867175e8515...711ddddfa9ddc88643a73ff91d9151b9920f8077 You're receiving 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 Sep 26 15:19:20 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 26 Sep 2022 11:19:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22206 Message-ID: <6331c2f87ef03_2c975751400600b6@gitlab.mail> Ben Gamari pushed new branch wip/T22206 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22206 You're receiving 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 Sep 26 15:32:16 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 26 Sep 2022 11:32:16 -0400 Subject: [Git][ghc/ghc][wip/T21717] Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <6331c600385c9_2c97575143c650b9@gitlab.mail> Sebastian Graf pushed to branch wip/T21717 at Glasgow Haskell Compiler / GHC Commits: 52178f97 by Sebastian Graf at 2022-09-26T17:29:28+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. - - - - - 19 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/simplCore/should_compile/T21261.hs - testsuite/tests/simplCore/should_compile/T21261.stderr - − testsuite/tests/simplCore/should_compile/T21261_pedantic.hs - − testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/stranal/should_compile/T18894.stderr - testsuite/tests/stranal/sigs/T20746.stderr - testsuite/tests/stranal/sigs/T21081.stderr - testsuite/tests/stranal/sigs/T21119.stderr - + testsuite/tests/stranal/sigs/T21717.hs - + testsuite/tests/stranal/sigs/T21717.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -509,9 +509,6 @@ this transformation. So we try to limit it as much as possible: Of course both (1) and (2) are readily defeated by disguising the bottoms. -Another place where -fpedantic-bottoms comes up is during eta-reduction. -See Note [Eta reduction soundness], the bit about -fpedantic-bottoms. - 4. Note [Newtype arity] ~~~~~~~~~~~~~~~~~~~~~~~~ Non-recursive newtypes are transparent, and should not get in the way. @@ -2382,20 +2379,13 @@ case where `e` is trivial): `e = \x y. bot`. Could we relax to "*At least one call in the same trace* is with n args"? - (NB: Strictness analysis can only answer this relaxed question, not the - original formulation.) - Consider what happens for + No. Consider what happens for ``g2 c = c True `seq` c False 42`` Here, `g2` will call `c` with 2 arguments (if there is a call at all). But it is unsound to eta-reduce the arg in `g2 (\x y. e x y)` to `g2 e` when `e = \x. if x then bot else id`, because the latter will diverge when - the former would not. - - On the other hand, with `-fno-pedantic-bottoms` , we will have eta-expanded - the definition of `e` and then eta-reduction is sound - (see Note [Dealing with bottom]). - Consequence: We have to check that `-fpedantic-bottoms` is off; otherwise - eta-reduction based on demands is in fact unsound. + the former would not. Fortunately, the strictness analyser will report + "Not always called with two arguments" for `g2` and we won't eta-expand. See Note [Eta reduction based on evaluation context] for the implementation details. This criterion is tested extensively in T21261. @@ -2541,7 +2531,7 @@ Then this is how the pieces are put together: Because it's irrelevant! When we simplify an expression, we do so under the assumption that it is currently under evaluation.) This sub-demand literally says "Whenever this expression is evaluated, it - is also called with two arguments, potentially multiple times". + is called with at least two arguments, potentially multiple times". * Then the simplifier takes apart the lambda and simplifies the lambda group and then calls 'tryEtaReduce' when rebuilding the lambda, passing the ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1643,11 +1643,7 @@ rebuildLam env bndrs body cont mb_rhs = contIsRhs cont -- See Note [Eta reduction based on evaluation context] - eval_sd - | sePedanticBottoms env = topSubDmd - -- See Note [Eta reduction soundness], criterion (S) - -- the bit about -fpedantic-bottoms - | otherwise = contEvalContext cont + eval_sd = contEvalContext cont -- NB: cont is never ApplyToVal, because beta-reduction would -- have happened. So contEvalContext can panic on ApplyToVal. ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -598,26 +598,6 @@ multCard (Card a) (Card b) bit1 = (a .&. b) .&. 0b010 bitN = (a .|. b) .&. shiftL bit1 1 .&. 0b100 --- | Denotes '∪' on lower and '+' on upper bounds of 'Card'. -lubPlusCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -lubPlusCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .|. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = ((a .|. b) .|. shiftL (a .&. b) 1) .&. 0b100 - --- | Denotes '+' on lower and '∪' on upper bounds of 'Card'. -plusLubCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -plusLubCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .&. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = (a .|. b) .&. 0b100 - {- ************************************************************************ * * @@ -626,11 +606,11 @@ plusLubCard (Card a) (Card b) ************************************************************************ -} --- | A demand describes a /scaled evaluation context/, e.g. how many times --- and how deep the denoted thing is evaluated. +-- | A demand describes +-- +-- * How many times a variable is evaluated, via a 'Card'inality, and +-- * How deep its value was evaluated in turn, via a 'SubDemand'. -- --- The "how many" component is represented by a 'Card'inality. --- The "how deep" component is represented by a 'SubDemand'. -- Examples (using Note [Demand notation]): -- -- * 'seq' puts demand @1A@ on its first argument: It evaluates the argument @@ -674,8 +654,8 @@ viewDmdPair BotDmd = (C_10, botSubDmd) viewDmdPair AbsDmd = (C_00, botSubDmd) viewDmdPair (D n sd) = (n, sd) --- | @c :* sd@ is a demand that says \"evaluated @c@ times, and each time it --- was evaluated, it was at least as deep as @sd@\". +-- | @c :* sd@ is a demand that says \"evaluated @c@ times, and any trace in +-- which it is evaluated will evaluate at least as deep as @sd@\". -- -- Matching on this pattern synonym is a complete match. -- If the matched demand was 'AbsDmd', it will match as @C_00 :* seqSubDmd at . @@ -695,8 +675,9 @@ pattern n :* sd <- (viewDmdPair -> (n, sd)) where n :* sd = D n sd & assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) {-# COMPLETE (:*) #-} --- | A sub-demand describes an /evaluation context/, e.g. how deep the --- denoted thing is evaluated. See 'Demand' for examples. +-- | A sub-demand describes an /evaluation context/ (in the sense of an +-- operational semantics), e.g. how deep the denoted thing is going to be +-- evaluated. See 'Demand' for examples. -- -- See Note [SubDemand denotes at least one evaluation] for a more detailed -- description of what a sub-demand means. @@ -714,14 +695,17 @@ data SubDemand -- @Poly b n@ is semantically equivalent to @Prod b [n :* Poly b n, ...] -- or @Call n (Poly Boxed n)@. 'viewCall' and 'viewProd' do these rewrites. -- - -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === CL(L)@, - -- @B === P(B,B,...)@ and @B === CB(B)@, - -- @!A === !P(A,A,...)@ and @!A === !CA(B)@, + -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === C(L)@, + -- @B === P(B,B,...)@ and @B === C(B)@, + -- @!A === !P(A,A,...)@ and @!A === C(A)@, -- and so on. -- -- We'll only see 'Poly' with 'C_10' (B), 'C_00' (A), 'C_0N' (L) and sometimes -- 'C_1N' (S) through 'plusSubDmd', never 'C_01' (M) or 'C_11' (1) (grep the -- source code). Hence 'CardNonOnce', which is closed under 'lub' and 'plus'. + -- + -- Why doesn't this constructor simply carry a 'Demand' instead of its fields? + -- See Note [Call SubDemand vs. evaluation Demand]. | Call !CardNonAbs !SubDemand -- ^ @Call n sd@ describes the evaluation context of @n@ function -- applications (with one argument), where the result of each call is @@ -803,7 +787,7 @@ viewProd _ _ -- equality @Call C_0N (Poly C_0N) === Poly C_0N@, simplifying to 'Poly' 'SubDemand's -- when possible. mkCall :: CardNonAbs -> SubDemand -> SubDemand -mkCall C_1N sd@(Poly Boxed C_1N) = sd +--mkCall C_1N sd@(Poly Boxed C_1N) = sd -- NO! #21085 strikes. See Note [mkCall and plusSubDmd] mkCall C_0N sd@(Poly Boxed C_0N) = sd mkCall n sd = assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) $ Call n sd @@ -838,17 +822,6 @@ unboxDeeplyDmd BotDmd = BotDmd unboxDeeplyDmd dmd@(D n sd) | isStrict n = D n (unboxDeeplySubDmd sd) | otherwise = dmd -multSubDmd :: Card -> SubDemand -> SubDemand -multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod --- The following three equations don't have an impact on Demands, only on --- Boxity. They are needed so that we don't trigger the assertions in `:*` --- when called from `multDmd`. -multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` -multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` -multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality -multSubDmd n (Poly b m) = Poly b (multCard n m) -multSubDmd n (Call n' sd) = mkCall (multCard n n') sd -multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) multDmd :: Card -> Demand -> Demand multDmd C_11 dmd = dmd -- An optimisation @@ -866,170 +839,85 @@ multDmd n BotDmd = if isStrict n then BotDmd else AbsDmd -- See Note [SubDemand denotes at least one evaluation] for the strictifyCard multDmd n (D m sd) = multCard n m :* multSubDmd (strictifyCard n) sd -{- Note [Manual specialisation of lub*Dmd/plus*Dmd] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As Note [SubDemand denotes at least one evaluation] points out, we need all 4 -different combinations of lub/plus demand operations on upper and lower bounds - lubDmd, plusDmd, lubPlusDmd, plusLubDmd -and the same for lubSubDmd, etc. In order to share as much code as possible -and for the programmer to see immediately how the operations differ, we have -one implementation of opDmd (and opSubDmd) that dispatches on a 'OpMode'. - -For good perf, we specialise this one implementation to the four different -modes. So ideally we'd write -``` -lubSubDmd = opSubDmd (Lub, Lub) -opSubDmd (l, u) = ... opSubDmd ... -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -But unfortunately, 'opSubDmd' will be picked as a loop-breaker and thus never -inline into 'lubSubDmd', so its body will never actually be specialised for -the op mode `(Lub, Lub)`. So instead we write -``` -lubSubDmd = opSubDmdInl (Lub, Lub) -opSubDmdInl (l, u) = ... opSubDmd ... -{-# INLINE opSubDmdInl #-} -opSubDmd = opSubDmdInl -{-# RULES "lubSubDmd" forall l r. opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -Here, 'opSubDmdInl' will not be picked as the loop-breaker and thus inline into -'lubSubDmd' and 'opSubDmd'. Since the latter will never inline, we'll specialise -all call sites of 'opSubDmd' for the proper op mode. A nice trick! --} - -data LubOrPlus = Lub | Plus deriving Show -instance Outputable LubOrPlus where ppr = text . show - --- | Determines whether to use 'LubOrPlus' for lower bounds and upper bounds, --- respectively. See Note [Manual specialisation of lub*Dmd/plus*Dmd]. -type OpMode = (LubOrPlus, LubOrPlus) +multSubDmd :: Card -> SubDemand -> SubDemand +multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod +-- The following three equations don't have an impact on Demands, only on +-- Boxity. They are needed so that we don't trigger the assertions in `:*` +-- when called from `multDmd`. +multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` +multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` +multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality +multSubDmd n (Poly b m) = Poly b (multCard n m) +multSubDmd n (Call n' sd) = mkCall (multCard n n') sd +multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) --- | Denotes '∪' on 'SubDemand'. -lubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubSubDmd l r = opSubDmdInl (Lub, Lub) l r +lazifyIfStrict :: Card -> SubDemand -> SubDemand +lazifyIfStrict n sd = multSubDmd (glbCard C_01 n) sd -- | Denotes '∪' on 'Demand'. lubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubDmd l r = opDmdInl (Lub, Lub) l r +lubDmd BotDmd dmd2 = dmd2 +lubDmd dmd1 BotDmd = dmd1 +lubDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "lubDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + lubCard n1 n2 :* lubSubDmd sd1 sd2 --- | Denotes '+' on 'SubDemand'. -plusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusSubDmd l r = opSubDmdInl (Plus, Plus) l r +lubSubDmd :: SubDemand -> SubDemand -> SubDemand +-- Shortcuts for neutral and absorbing elements. +-- Below we assume that Boxed always wins. +lubSubDmd (Poly Unboxed C_10) sd = sd +lubSubDmd sd (Poly Unboxed C_10) = sd +lubSubDmd sd@(Poly Boxed C_0N) _ = sd +lubSubDmd _ sd@(Poly Boxed C_0N) = sd +-- Handle Prod +lubSubDmd (Prod b1 ds1) (Poly b2 n2) + | let !d = polyFieldDmd b2 n2 + = mkProd (lubBoxity b1 b2) (strictMap (lubDmd d) ds1) +lubSubDmd (Prod b1 ds1) (Prod b2 ds2) + | equalLength ds1 ds2 + = mkProd (lubBoxity b1 b2) (strictZipWith lubDmd ds1 ds2) +-- Handle Call +lubSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (lubCard n1 n2) (lubSubDmd sd1 sd2) +-- Handle Poly +lubSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (lubCard n1 n2) +-- Other Poly case by commutativity +lubSubDmd sd1 at Poly{} sd2 = lubSubDmd sd2 sd1 +-- Otherwise (Call `lub` Prod) return Top +lubSubDmd _ _ = topSubDmd -- | Denotes '+' on 'Demand'. plusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusDmd l r = opDmdInl (Plus, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -lubPlusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusSubDmd l r = opSubDmdInl (Lub, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'Demand'. -lubPlusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusDmd l r = opDmdInl (Lub, Plus) l r - --- | Denotes '+' on lower bounds and '∪' on upper bounds on 'SubDemand'. -plusLubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubSubDmd l r = opSubDmdInl (Plus, Lub) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -plusLubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubDmd l r = opDmdInl (Plus, Lub) l r - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -{-# RULES "lubDmd" opDmd (Lub, Lub) = lubDmd #-} -{-# RULES "plusSubDmd" opSubDmd (Plus, Plus) = plusSubDmd #-} -{-# RULES "plusDmd" opDmd (Plus, Plus) = plusDmd #-} -{-# RULES "lubPlusSubDmd" opSubDmd (Lub, Plus) = lubPlusSubDmd #-} -{-# RULES "lubPlusDmd" opDmd (Lub, Plus) = lubPlusDmd #-} -{-# RULES "plusLubSubDmd" opSubDmd (Plus, Lub) = plusLubSubDmd #-} -{-# RULES "plusLubDmd" opDmd (Plus, Lub) = plusLubDmd #-} - --- --- And now the actual implementation that is to be specialised: --- +plusDmd AbsDmd dmd2 = dmd2 +plusDmd dmd1 AbsDmd = dmd1 +plusDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "plusDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + -- Why lazify? See Note [SubDemand denotes at least one evaluation] + -- and also Note [Unrealised opportunity in plusDmd] which applies when both + -- n1 and n2 are lazy already + plusCard n1 n2 :* plusSubDmd (lazifyIfStrict n1 sd1) (lazifyIfStrict n2 sd2) -neutralCard :: OpMode -> Card -neutralCard (Lub, _) = C_10 -neutralCard (Plus, _) = C_00 -{-# INLINE neutralCard #-} - -absorbingCard :: OpMode -> Card -absorbingCard (Lub, _) = C_0N -absorbingCard (Plus, _) = C_1N -{-# INLINE absorbingCard #-} - -opCard :: OpMode -> Card -> Card -> Card -opCard (Lub, Lub) = lubCard -opCard (Lub, Plus) = lubPlusCard -opCard (Plus, Lub) = plusLubCard -opCard (Plus, Plus) = plusCard -{-# INLINE opCard #-} - -opDmdInl, opDmd :: OpMode -> Demand -> Demand -> Demand -opDmdInl m (n1 :* _) dmd2 | n1 == neutralCard m = dmd2 -opDmdInl m dmd1 (n2 :* _) | n2 == neutralCard m = dmd1 -opDmdInl m@(l,u) (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "opDmd" (\it -> ppr l <+> ppr u $$ ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ - opCard m n1 n2 :* case l of - Lub -> opSubDmd m sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, u) sd1 sd2 -- (D1) - (True, False) -> opSubDmd (Plus, u) sd1 (lazifySubDmd sd2) -- (D2) - (False, True) -> opSubDmd (Plus, u) (lazifySubDmd sd1) sd2 -- (D2) - (False, False) -> opSubDmd (Lub, u) sd1 sd2 -- (D3) - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opDmd = opDmdInl -{-# INLINE opDmdInl #-} -{-# NOINLINE opDmd #-} - -opSubDmdInl, opSubDmd :: OpMode -> SubDemand -> SubDemand -> SubDemand +plusSubDmd :: SubDemand -> SubDemand -> SubDemand -- Shortcuts for neutral and absorbing elements. -- Below we assume that Boxed always wins. -opSubDmdInl m (Poly Unboxed n) sd | n == neutralCard m = sd -opSubDmdInl m sd (Poly Unboxed n) | n == neutralCard m = sd -opSubDmdInl m sd@(Poly Boxed n) _ | n == absorbingCard m = sd -opSubDmdInl m _ sd@(Poly Boxed n) | n == absorbingCard m = sd +plusSubDmd (Poly Unboxed C_00) sd = sd +plusSubDmd sd (Poly Unboxed C_00) = sd +plusSubDmd sd@(Poly Boxed C_1N) _ = sd +plusSubDmd _ sd@(Poly Boxed C_1N) = sd -- Handle Prod -opSubDmdInl m (Prod b1 ds1) (Poly b2 n2) +plusSubDmd (Prod b1 ds1) (Poly b2 n2) | let !d = polyFieldDmd b2 n2 - = mkProd (lubBoxity b1 b2) (strictMap (opDmd m d) ds1) -opSubDmdInl m (Prod b1 ds1) (Prod b2 ds2) + = mkProd (lubBoxity b1 b2) (strictMap (plusDmd d) ds1) +plusSubDmd (Prod b1 ds1) (Prod b2 ds2) | equalLength ds1 ds2 - = mkProd (lubBoxity b1 b2) (strictZipWith (opDmd m) ds1 ds2) + = mkProd (lubBoxity b1 b2) (strictZipWith plusDmd ds1 ds2) -- Handle Call -opSubDmdInl m@(l, _) (Call n1 sd1) (viewCall -> Just (n2, sd2)) = - mkCall (opCard m n1 n2) $! case l of - Lub -> opSubDmd (Lub, Lub) sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]. Usage is always lubbed: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, Lub) sd1 sd2 -- (C3) - (False, True) -> opSubDmd (Plus, Lub) (lazifySubDmd sd1) sd2 -- (C2) - (True, False) -> opSubDmd (Plus, Lub) sd1 (lazifySubDmd sd2) -- (C2) - (False, False) -> opSubDmd (Lub, Lub) sd1 sd2 -- (C1) +plusSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (plusCard n1 n2) (lubSubDmd sd1 sd2) -- Handle Poly -opSubDmdInl m (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (opCard m n1 n2) +plusSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (plusCard n1 n2) -- Other Poly case by commutativity -opSubDmdInl m sd1 at Poly{} sd2 = opSubDmd m sd2 sd1 --- Otherwise (Call `op` Prod) return Top -opSubDmdInl _ _ _ = topSubDmd - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opSubDmd = opSubDmdInl -{-# INLINE opSubDmdInl #-} -{-# NOINLINE opSubDmd #-} +plusSubDmd sd1 at Poly{} sd2 = plusSubDmd sd2 sd1 +-- Otherwise (Call `plus` Prod) return Top +plusSubDmd _ _ = topSubDmd -- | Used to suppress pretty-printing of an uninformative demand isTopDmd :: Demand -> Bool @@ -1129,11 +1017,6 @@ strictifyDictDmd _ dmd = dmd lazifyDmd :: Demand -> Demand lazifyDmd = multDmd C_01 - --- | Make a 'SubDemand' lazy. -lazifySubDmd :: SubDemand -> SubDemand -lazifySubDmd = multSubDmd C_01 - -- | Wraps the 'SubDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCalledOnceDmd :: SubDemand -> SubDemand mkCalledOnceDmd sd = mkCall C_11 sd @@ -1166,7 +1049,7 @@ subDemandIfEvaluated (_ :* sd) = sd mkWorkerDemand :: Int -> Demand mkWorkerDemand n = C_01 :* go n where go 0 = topSubDmd - go n = Call C_01 $ go (n-1) + go n = mkCall C_01 $ go (n-1) argsOneShots :: DmdSig -> Arity -> [[OneShotInfo]] -- ^ See Note [Computing one-shot info] @@ -1242,22 +1125,24 @@ NB: The Premise only makes a difference for lower bounds/strictness. Upper bounds/usage are unaffected by adding or leaving out evaluations that never happen. -So if `x` was demanded with `LP(1L)`, so perhaps `` was - f1 x = (x `seq` case x of (a,b) -> a, True) -then `x` will be evaluated lazily, but any time `x` is evaluated, `e` is -evaluated with sub-demand `P(1L)`, e.g., the first field of `e` is evaluated -strictly, too. - -How does the additional strictness help? The long version is in #21081. +The Premise comes into play when we have lazy Demands. For example, if `x` was +demanded with `LP(SL,A)`, so perhaps the full expression was + let x = (e1, e2) in (x `seq` fun y `seq` case x of (a,b) -> a, True) +then `x` will be evaluated lazily, but in any trace in which `x` is evaluated, +the pair in its RHS will ultimately be evaluated deeply with sub-demand +`P(SL,A)`. That means that `e1` is ultimately evaluated strictly, even though +evaluation of the field does not directly follow the eval of `x` due to the +intermittent call `fun y`. + +How does the additional strictness help? The long version is the list of +examples at the end of this Note (as procured in #21081 and #18903). The short version is - * We get to take advantage of call-by-value/let-to-case in more situations. - See example "More let-to-case" below. + * We get to take advantage of call-by-value/let-to-case in more situations, + as for e1 above. See example "More let-to-case" below. * Note [Eta reduction based on evaluation context] applies in more situations. See example "More eta reduction" below. * We get to unbox more results, see example "More CPR" below. - * We prevent annoying issues with `Poly` equalities, #21085. In short, we'd get - `L + S = S = CS(S) < CS(L) = C(L+S)(LuS) = L + CS(S)` although `S = CS(S)`. It seems like we don't give up anything in return. Indeed that is the case: @@ -1271,47 +1156,26 @@ It seems like we don't give up anything in return. Indeed that is the case: well as when expanding absent 'Poly's to 'Call' sub-demands in 'viewCall'. Of course, we now have to maintain the Premise when we unpack and rebuild -SubDemands. For strict demands, we know that the Premise indeed always holds for +Demands. For strict demands, we know that the Premise indeed always holds for any program trace abstracted over, whereas we have to be careful for lazy demands. -That makes for a strange definition of `plusDmd`, where we use `plusSubDmd` -throughout for upper bounds (every eval returns the same, memoised heap object), -but what we do on lower bounds depends on the strictness of both arguments: - - D1 `plusSubDmd` on the nested SubDemands if both args are strict. - D2 `plusSubDmd` on the nested SubDemands if one of them is lazy, which we - *lazify* before (that's new), so that e.g. - `LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L)` - Multiplying with `M`/`C_01` is the "lazify" part here. - Example proving that point: - d2 :: - d2 x y = y `seq` (case x of (a,b) -> a, True) - -- What is demand on x in (d2 x x)? NOT SP(SL)!! - D3 `lubPlusSubDmd` on the nested SubDemands if both args are lazy. - This new operation combines `lubSubDmd` on lower bounds with `plusSubDmd` - on upper bounds. - Examples proving that point: - d3 :: - d3 x y = (case x of (a,b) -> a, y `seq` ()) - -- What is demand on x in `snd (d3 x x)`? - -- Not LP(SL)!! d3 might evaluate second argument but not first. - -- Lub lower bounds because we might evaluate one OR the other. - -Similarly, in the handling of Call SubDemands `Cn(sd)` in `plusSubDmd`, we use -`lub` for upper bounds (because every call returns a fresh heap object), but -what we do for lower bounds depends on whether the outer `n`s are strict: - - C1 `lubSubDmd` on the nested SubDemands if both args are lazy. - C2 `plusLubSubDmd` on the nested `sd`s if one of the `n`s is lazy. That one's - nested `sd` we *lazify*, so that e.g. - `CL(SL) + CS(L) = C(L+S)((M*SL)+L) = CS(L+L) = CS(L)` - `plusLubSubDmd` combines `plusSubDmd` on lower bounds with `lubSubDmd` on - upper bounds. - C3 `plusLubSubDmd` on the nested SubDemands if both args are strict. - -There are a couple of other examples in T21081. -Here is a selection of examples demonstrating the -usefulness of The Premise: + +In particular, when doing `plusDmd` we have to *lazify* the nested SubDemand +if the outer cardinality is lazy. E.g., + LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L) +Multiplying with `M`/`C_01` is the "lazify" part here and is implemented in +`lazifyIfStrict`. Example proving that point: + d2 :: + d2 x y = y `seq` (case x of (a,b) -> a, True) + -- What is the demand on x in (d2 x x)? NOT SP(SL)!! + +We used to apply the same reasoning to Call SubDemands `Cn(sd)` in `plusSubDmd`, +but that led to #21717, because different calls return different heap objects. +See Note [Call SubDemand vs. evaluation Demand]. + +There are a couple more examples that improve in T21081. +Here is a selection of those examples demonstrating the usefulness of The +Premise: * "More let-to-case" (from testcase T21081): ```hs @@ -1355,6 +1219,102 @@ usefulness of The Premise: pair. That in turn means that Nested CPR can unbox the result of the division even though it might throw. +Note [Unrealised opportunity in plusDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Recall the lazification of SubDemands happening in `plusDmd` as described in +Note [SubDemand denotes at least one evaluation]. + +We *could* do better when both Demands are lazy already. Example + (fun 1, fun 2) +Both args put Demand SCS(L) on `fun`. The lazy pair arg context lazifies +this to LCS(L), and it would be reasonable to report this Demand on `fun` for +the entire pair expression; after all, `fun` is called whenever it is evaluated. +But our definition of `plusDmd` will compute + LCS(L) + LCS(L) = (L+L)(M*CS(L) + M*CS(L)) = L(CL(L)) = L +Which is clearly less precise. +Doing better here could mean to `lub` when both demands are lazy, e.g., + LCS(L) + LCS(L) = (L+L)(CS(L) ⊔ CS(L)) = L(CS(L)) +Indeed that's what we did at one point between 9.4 and 9.6 after !7599, but it +means that we need a function `lubPlusSubDmd` that lubs on lower bounds but +plus'es upper bounds, implying maintenance challenges and complicated +explanations. + +Plus, NoFib says that this special case doesn't bring all that much +(geom. mean +0.0% counted instructions), so we don't bother anymore. + +Note [Call SubDemand vs. evaluation Demand] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Although both evaluation Demands and Call SubDemands carry a (Card,SubDemand) +pair, their interpretation is quite different. Example: + + f x = fst x * snd x + -- f :: , because 1P(1L,A)+1P(A,1L) = SP(1L,1L) + g x = fst (x 1) * snd (x 2) + -- g :: , because 1C1(P(1L,A))+1C1(P(A,1L)) = SCS(P(ML,ML)) + +The point about this example is that both demands have P(A,1L)/P(1L,A) as +sub-expressions, but when these sub-demands occur + + 1. under an evaluation demand, we combine with `plusSubDmd` + 2. whereas under a Call sub-demand, we combine with `lubSubDmd` + +And thus (1) yields a stricter demand on the pair components than (2). + +In #21717 we saw that we really need lub in (2), because otherwise we make an +unsound prediction in `g (\n -> if n == 1 then (1,1) else (bot,2))`; we'd say +that the `bot` expression is always evaluated, when it clearly is not. +Operationally, every call to `g` gives back a potentially distinct, +heap-allocated pair with potentially different contents, and we must `lubSubDmd` +over all such calls to approximate how any of those pairs might be used. + +That is in stark contrast to f's argument `x`: Operationally, every eval of +`x` must yield the same pair and `f` evaluates both components of that pair. +The theorem "every eval of `x` returns the same heap object" is a very strong +MUST-alias property and we capitalise on that by using `plusSubDmd` in (1). + +And indeed we *must* use `plusSubDmd` in (1) for sound upper bounds in an +analysis that assumes call-by-need (as opposed to the weaker call-by-name) for +let bindings. Consider + + h x = fst x * fst x + -- h :: + +And the expression `let a=1; p=(a,a)} in h p`. Here, *although* the RHS of `p` +is only evaluated once under call-by-need, `a` is still evaluated twice. +If we had used `lubSubDmd`, we'd see SP(1L,A) and the 1L unsoundly says "exactly +once". + +If the analysis had assumed call-by-name, it would be sound to say "a is used +once in p": p is used multiple times and hence so would a, as if p was a +function. So using `plusSubDmd` does not only yield better strictness, it is +also "holding up the other end of the bargain" of the call-by-need assumption +for upper bounds. + +(To SG's knowledge, the distinction between call-by-name and call-by-need does +not matter for strictness analysis/lower bounds, thus it would be sound to use +`lubSubDmd` all the time there.) + +Note [mkCall and plusSubDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We never rewrite a strict, non-absent Call sub-demand like CS(S) to a +polymorphic sub-demand like S, otherwise #21085 strikes. Consider the +following inequality (would also for M and 1 instead of L and S, but we forbid +such Polys): + + L+S = S = CS(S) < CS(L) = CL(L)+CS(S) + +Note that L=CL(L). If we also had S=CS(S), we'd be in trouble: Now +`plusSubDmd` would no longer maintain the equality relation on sub-demands, +much less monotonicity. Bad! + +Clearly, `n <= Cn(n)` is unproblematic, as is `n >= Cn(n)` for any `n` +except 1 and S. But `CS(S) >= S` would mean trouble, because then we'd get +the problematic `CS(S) = S`. We have just established that `S < CS(S)`! +As such, the rewrite CS(S) to S is anti-monotone and we forbid it, first +and foremost in `mkCall` (which is the only place that rewrites Cn(n) to n). + +Crisis and #21085 averted! + Note [Computing one-shot info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a call @@ -2102,7 +2062,7 @@ If this same function is applied to one arg, all we can say is that it uses x with 1L, and its arg with demand 1P(L,L). Note [Understanding DmdType and DmdSig] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Demand types are sound approximations of an expression's semantics relative to the incoming demand we put the expression under. Consider the following expression: ===================================== testsuite/tests/arityanal/should_compile/Arity11.stderr ===================================== @@ -53,7 +53,7 @@ F11.fib1 = GHC.Num.Integer.IS 0# -- RHS size: {terms: 52, types: 26, coercions: 0, joins: 0/5} F11.$wfib [InlPrag=[2]] :: forall {t} {a}. (t -> t -> Bool) -> (Num t, Num a) => t -> a -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] F11.$wfib = \ (@t) (@a) (ww :: t -> t -> Bool) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> let { @@ -91,7 +91,7 @@ F11.$wfib fib [InlPrag=[2]] :: forall {t} {a}. (Eq t, Num t, Num a) => t -> a [GblId, Arity=4, - Str=<1P(SCS(C1(L)),A)>, + Str=<1P(SCS(C1(L)),A)>, 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= \ (@t) (@a) ($dEq [Occ=Once1!] :: Eq t) ($dNum [Occ=Once1] :: Num t) ($dNum1 [Occ=Once1] :: Num a) (eta [Occ=Once1] :: t) -> case $dEq of { GHC.Classes.C:Eq ww [Occ=Once1] _ [Occ=Dead] -> F11.$wfib @t @a ww $dNum $dNum1 eta }}] fib = \ (@t) (@a) ($dEq :: Eq t) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> case $dEq of { GHC.Classes.C:Eq ww ww1 -> F11.$wfib @t @a ww $dNum $dNum1 eta } @@ -142,4 +142,7 @@ f11 :: (Integer, Integer) f11 = (F11.f4, F11.f1) +------ Local rules for imported ids -------- +"SPEC fib @Integer @Integer" forall ($dEq :: Eq Integer) ($dNum :: Num Integer) ($dNum1 :: Num Integer). fib @Integer @Integer $dEq $dNum $dNum1 = F11.f11_fib + ===================================== testsuite/tests/arityanal/should_compile/Arity14.stderr ===================================== @@ -14,7 +14,7 @@ F14.f2 = GHC.Num.Integer.IS 1# -- RHS size: {terms: 35, types: 23, coercions: 0, joins: 0/3} F14.$wf14 [InlPrag=[2]] :: forall {t}. (t -> t -> Bool) -> Num t => t -> t -> t -> t -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] F14.$wf14 = \ (@t) (ww :: t -> t -> Bool) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> let { @@ -41,7 +41,7 @@ F14.$wf14 f14 [InlPrag=[2]] :: forall {t}. (Ord t, Num t) => t -> t -> t -> t [GblId, Arity=4, - Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, + Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, 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= \ (@t) ($dOrd [Occ=Once1!] :: Ord t) ($dNum [Occ=Once1] :: Num t) (eta [Occ=Once1] :: t) (eta1 [Occ=Once1] :: t) -> case $dOrd of { GHC.Classes.C:Ord _ [Occ=Dead] _ [Occ=Dead] ww2 [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> F14.$wf14 @t ww2 $dNum eta eta1 }}] f14 = \ (@t) ($dOrd :: Ord t) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> case $dOrd of { GHC.Classes.C:Ord ww ww1 ww2 ww3 ww4 ww5 ww6 ww7 -> F14.$wf14 @t ww2 $dNum eta eta1 } ===================================== testsuite/tests/arityanal/should_compile/Arity16.stderr ===================================== @@ -5,7 +5,7 @@ Result size of Tidy Core = {terms: 53, types: 71, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 15, types: 15, coercions: 0, joins: 0/0} map2 [Occ=LoopBreaker] :: forall {t} {a}. (t -> a) -> [t] -> [a] -[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] map2 = \ (@t) (@a) (f :: t -> a) (ds :: [t]) -> case ds of { @@ -27,7 +27,7 @@ lvl1 = Control.Exception.Base.patError @GHC.Types.LiftedRep @() lvl Rec { -- RHS size: {terms: 31, types: 32, coercions: 0, joins: 0/0} zipWith2 [Occ=LoopBreaker] :: forall {t1} {t2} {a}. (t1 -> t2 -> a) -> [t1] -> [t2] -> [a] -[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] zipWith2 = \ (@t) (@t1) (@a) (f :: t -> t1 -> a) (ds :: [t]) (ds1 :: [t1]) -> case ds of { ===================================== testsuite/tests/simplCore/should_compile/T21261.hs ===================================== @@ -34,18 +34,26 @@ f5 c = Just (c 1 2 + c 3 4) yes2_lazy :: (Int -> Int -> Int) -> Maybe Int yes2_lazy c = f5 (\x y -> c x y) --- These last two here are disallowed in T21261_pedantic.hs, which activates --- -fpedantic-bottoms. It would be unsound to eta reduce these bindings with --- -fpedantic-bottoms, but without it's fine to eta reduce: +-- These last two here are tricky. It is unsound to eta reduce +-- the args to f6 and f7 because we could call both functions +-- at a c like `\x -> if x == 1 then undefined else id`. +-- Note that if we do so and *do* eta-reduce, we'll see a crash! +-- Whereas we *don't* see a crash if we keep the original, +-- eta-expanded arguments. +-- +-- This is issue is discussed in Note [Eta reduction soundness], condition (S). +-- +-- This is a variant of #21717 (and tested by T21717), where +-- prior to the fix we observed an unsound strictness signature. f6 :: (Int -> Int -> Int) -> Int f6 c = c 1 `seq` c 2 3 {-# NOINLINE f6 #-} -yes_non_pedantic :: (Int -> Int -> Int) -> Int -yes_non_pedantic c = f6 (\x y -> c x y) +no_tricky :: (Int -> Int -> Int) -> Int +no_tricky c = f6 (\x y -> c x y) f7 :: (Int -> Int -> Int) -> Maybe Int f7 c = Just (c 1 `seq` c 3 4) {-# NOINLINE f7 #-} -yes_non_pedantic_lazy :: (Int -> Int -> Int) -> Maybe Int -yes_non_pedantic_lazy c = f7 (\x y -> c x y) +no_tricky_lazy :: (Int -> Int -> Int) -> Maybe Int +no_tricky_lazy c = f7 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 166, types: 176, coercions: 0, joins: 0/0} + = {terms: 182, types: 191, coercions: 0, joins: 0/0} lvl = I# 3# @@ -29,13 +29,14 @@ no3 f6 = \ c -> case c lvl2 of { __DEFAULT -> c lvl3 lvl } -yes_non_pedantic = f6 +no_tricky = \ c -> f6 (\ x y -> c x y) $wf7 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl lvl1 } #) f7 = \ c -> case $wf7 c of { (# ww #) -> Just ww } -yes_non_pedantic_lazy = f7 +no_tricky_lazy + = \ c -> case $wf7 (\ x y -> c x y) of { (# ww #) -> Just ww } $wf5 = \ c -> ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.hs deleted ===================================== @@ -1,18 +0,0 @@ -{-# OPTIONS_GHC -fpedantic-bottoms #-} -- This flag must inhibit eta reduction based on demands - -module T21261_pedantic where - --- README: See T21261. These examples absolutely should not eta reduce with --- -fpedantic-bottoms. - -f1 :: (Int -> Int -> Int) -> Int -f1 c = c 1 `seq` c 2 3 -{-# NOINLINE f1 #-} -no2 :: (Int -> Int -> Int) -> Int -no2 c = f1 (\x y -> c x y) - -f2 :: (Int -> Int -> Int) -> Maybe Int -f2 c = Just (c 1 `seq` c 3 4) -{-# NOINLINE f2 #-} -no2_lazy :: (Int -> Int -> Int) -> Maybe Int -no2_lazy c = f2 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr deleted ===================================== @@ -1,26 +0,0 @@ - -==================== Tidy Core ==================== -Result size of Tidy Core - = {terms: 59, types: 63, coercions: 0, joins: 0/0} - -lvl = I# 2# - -lvl1 = I# 3# - -lvl2 = I# 1# - -f1 = \ c -> case c lvl2 of { __DEFAULT -> c lvl lvl1 } - -no2 = \ c -> f1 (\ x y -> c x y) - -lvl3 = I# 4# - -$wf2 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl1 lvl3 } #) - -f2 = \ c -> case $wf2 c of { (# ww #) -> Just ww } - -no2_lazy - = \ c -> case $wf2 (\ x y -> c x y) of { (# ww #) -> Just ww } - - - ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -407,8 +407,7 @@ test('T21144', normal, compile, ['-O']) test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. -test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) -test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # We expect to see a SPEC rule for $cm test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/stranal/should_compile/T18894.stderr ===================================== @@ -147,7 +147,7 @@ lvl :: (Int, Int) lvl = (lvl, lvl) -- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} -g1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] :: Int -> (Int, Int) +g1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: Int -> (Int, Int) [LclId, Arity=1, Str=<1!P(1L)>, @@ -266,7 +266,7 @@ lvl = GHC.Types.I# 0# -- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} $wg2 [InlPrag=NOINLINE, Dmd=LCS(C1(!P(M!P(L),1!P(L))))] :: Int -> GHC.Prim.Int# -> (# Int, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -328,9 +328,9 @@ h2 } -- RHS size: {terms: 34, types: 14, coercions: 0, joins: 0/1} -$wg1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] +$wg1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -367,7 +367,7 @@ lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} $wh1 [InlPrag=[2], Dmd=LCS(!P(L))] :: GHC.Prim.Int# -> Int -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, ===================================== testsuite/tests/stranal/sigs/T20746.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -Foo.f: +Foo.f: Foo.foogle: ===================================== testsuite/tests/stranal/sigs/T21081.stderr ===================================== @@ -4,7 +4,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: T21081.blurg2: T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: @@ -50,7 +50,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: <1!P(SL)> T21081.blurg2: <1!P(SL)> T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: ===================================== testsuite/tests/stranal/sigs/T21119.stderr ===================================== @@ -4,7 +4,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x @@ -24,7 +24,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x ===================================== testsuite/tests/stranal/sigs/T21717.hs ===================================== @@ -0,0 +1,22 @@ +-- {-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# OPTIONS_GHC -O -fforce-recomp #-} +-- {-# LANGUAGE PatternSynonyms #-} +-- {-# LANGUAGE BangPatterns #-} +-- {-# LANGUAGE MagicHash, UnboxedTuples #-} + +module Main (g, main) where + +f :: Bool -> (Int, Int) +f True = (42,error "m") +f False = (error "m",42) + +g :: (Bool -> (Int, Int)) -> Int +g f = fst (f True) + snd (f False) +{-# NOINLINE g #-} + +makeUp :: IO Int +makeUp = pure 42 +{-# NOINLINE makeUp #-} + +main = do + print $ g f ===================================== testsuite/tests/stranal/sigs/T21717.stderr ===================================== @@ -0,0 +1,21 @@ + +==================== Strictness signatures ==================== +:Main.main: +Main.g: +Main.main: + + + +==================== Cpr signatures ==================== +:Main.main: +Main.g: 1 +Main.main: + + + +==================== Strictness signatures ==================== +:Main.main: +Main.g: +Main.main: + + ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -T5075.f: +T5075.f: T5075.g: <1L> T5075.h: @@ -14,7 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> +T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> T5075.g: <1L> T5075.h: <1!P(L)> ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -33,5 +33,6 @@ test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) +test('T21717', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52178f97ae84a416de9c69a91a4df5ed40613606 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52178f97ae84a416de9c69a91a4df5ed40613606 You're receiving 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 Sep 26 15:40:09 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 11:40:09 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Skip some tests that require the dynamic linker Message-ID: <6331c7d934a45_2c975751450748c6@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 8cf5f41c by Sylvain Henry at 2022-09-26T17:43:17+02:00 Skip some tests that require the dynamic linker - - - - - 2 changed files: - testsuite/driver/testlib.py - testsuite/tests/rts/linker/all.T Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -259,6 +259,8 @@ def req_interp( name, opts ): def req_rts_linker( name, opts ): if not config.have_RTS_linker: opts.expect = 'fail' + # JS backend doesn't provide the RTS linker + js_skip(name, opts) def req_th( name, opts ): """ ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -75,9 +75,13 @@ test('T5435_v_gcc', makefile_test, ['T5435_v_gcc']) test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']), + js_skip, # dynamic linking not supported by the JS backend check_stdout(checkDynAsm)], makefile_test, ['T5435_dyn_asm']) -test('T5435_dyn_gcc', extra_files(['T5435.hs', 'T5435_gcc.c']) , makefile_test, ['T5435_dyn_gcc']) +test('T5435_dyn_gcc', + [extra_files(['T5435.hs', 'T5435_gcc.c']), + js_skip], # dynamic linking not supported by the JS backend + makefile_test, ['T5435_dyn_gcc']) ###################################### test('linker_unload', View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cf5f41cb38d35d67aefa37fdb6af35e20b9fb70 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cf5f41cb38d35d67aefa37fdb6af35e20b9fb70 You're receiving 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 Sep 26 17:28:34 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Mon, 26 Sep 2022 13:28:34 -0400 Subject: [Git][ghc/ghc][wip/js-staging] JavaScript ShrinkSmallMutableArrayOp_Char & GetSizeofSmallMutableArrayOp Message-ID: <6331e1421c9d0_2c9757514781085a2@gitlab.mail> Josh Meredith pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 4c452b24 by Josh Meredith at 2022-09-26T17:28:09+00:00 JavaScript ShrinkSmallMutableArrayOp_Char & GetSizeofSmallMutableArrayOp - - - - - 2 changed files: - compiler/GHC/StgToJS/Prim.hs - rts/js/mem.js Changes: ===================================== compiler/GHC/StgToJS/Prim.hs ===================================== @@ -1214,8 +1214,9 @@ genPrim prof ty op = case op of ------------------------------ Unhandled primops ------------------- - ShrinkSmallMutableArrayOp_Char -> unhandledPrimop op - GetSizeofSmallMutableArrayOp -> unhandledPrimop op + ShrinkSmallMutableArrayOp_Char -> \[] [a,n] -> PrimInline $ appS "h$shrinkMutableCharArray" [a,n] + GetSizeofSmallMutableArrayOp -> \[r] [a] -> PrimInline $ r |= a .^ "length" + AtomicReadAddrOp_Word -> \[r] [a,o] -> PrimInline $ r |= dv_u32 a o ===================================== rts/js/mem.js ===================================== @@ -992,6 +992,10 @@ function h$shrinkMutableByteArray(a, n) { } } +function h$shrinkMutableArray(a, n) { + a.length = n; +} + function h$compareByteArrays(a1,o1,a2,o2,n) { for(var i = 0; i < n; i++) { var x = a1.u8[i + o1]; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c452b24e26217dabc83e690ba1f1b9fdd23fb6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c452b24e26217dabc83e690ba1f1b9fdd23fb6f You're receiving 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 Sep 26 18:05:18 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 26 Sep 2022 14:05:18 -0400 Subject: [Git][ghc/ghc][wip/T21754] 387 commits: Mark AArch64/Darwin as requiring sign-extension Message-ID: <6331e9de2c150_2c9757514001163c6@gitlab.mail> Sebastian Graf pushed to branch wip/T21754 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - f2e39aad by Sebastian Graf at 2022-09-26T20:04:53+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. - - - - - 30 changed files: - − .appveyor.sh - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfdfc3d4031e2be6784ca95115c5238df15c7ad5...f2e39aade432ec323deb7f0d7f40716ce47a7539 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dfdfc3d4031e2be6784ca95115c5238df15c7ad5...f2e39aade432ec323deb7f0d7f40716ce47a7539 You're receiving 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 Sep 26 21:06:58 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 17:06:58 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Disable more linker tests Message-ID: <633214729ee07_2c975753ffac143474@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: a85ed3f1 by Sylvain Henry at 2022-09-26T23:10:06+02:00 Disable more linker tests - - - - - 1 changed file: - testsuite/tests/rts/linker/all.T Changes: ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -98,12 +98,15 @@ test('linker_unload_native', ###################################### test('linker_error1', [extra_files(['linker_error.c']), + js_skip, # dynamic linking not supported by the JS backend ignore_stderr], makefile_test, ['linker_error1']) test('linker_error2', [extra_files(['linker_error.c']), + js_skip, # dynamic linking not supported by the JS backend ignore_stderr], makefile_test, ['linker_error2']) test('linker_error3', [extra_files(['linker_error.c']), + js_skip, # dynamic linking not supported by the JS backend ignore_stderr], makefile_test, ['linker_error3']) ###################################### View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a85ed3f130dc909906ed5a91625c9028c61919c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a85ed3f130dc909906ed5a91625c9028c61919c9 You're receiving 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 Sep 26 21:20:15 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 17:20:15 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Testsuite: better normalisation for ghc and ghc-pkg Message-ID: <6332178fbd8b9_2c97575141414873a@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 3de68f56 by Sylvain Henry at 2022-09-26T23:22:19+02: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 - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -2313,8 +2313,9 @@ def normalise_errmsg(s: str) -> str: # The inplace ghc's are called ghc-stage[123] to avoid filename # collisions, so we need to normalise that to just "ghc" s = re.sub('ghc-stage[123]', 'ghc', s) - # Remove platform prefix (e.g. js-unknown-ghcjs) for cross-compiled ghc - s = re.sub('^\\w+-\\w+-\\w+-ghc', 'ghc', s) + # Remove platform prefix (e.g. js-unknown-ghcjs) for cross-compiled tools + # (ghc, ghc-pkg, unlit, etc.) + s = re.sub('\\w+-\\w+-\\w+-ghc', 'ghc', s) s = re.sub('\\w+-\\w+-\\w+-unlit', 'unlit', s) # On windows error messages can mention versioned executables View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3de68f562f3e7cc05903f7652ff28b37bc6739ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3de68f562f3e7cc05903f7652ff28b37bc6739ce You're receiving 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 Sep 26 21:23:58 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 17:23:58 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Skip T14373 because it requires Cmm Message-ID: <6332186e5d62e_2c975751464149188@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 3923163f by Sylvain Henry at 2022-09-26T23:27:05+02:00 Skip T14373 because it requires Cmm - - - - - 1 changed file: - testsuite/tests/codeGen/should_compile/all.T Changes: ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -72,20 +72,28 @@ test('T14373', [], switch_skeleton_only = 'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' -test('T14373a', [], +test('T14373a', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373a', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -test('T14373b', [], +test('T14373b', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373b', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -test('T14373c', [], +test('T14373c', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373c', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') -test('T14373d', [], +test('T14373d', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373d', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_and_entries_only]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3923163f6fd4be00951efeb503eaa3385f546a8c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3923163f6fd4be00951efeb503eaa3385f546a8c You're receiving 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 Sep 26 21:25:22 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 17:25:22 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Skip T14373 because it requires Cmm Message-ID: <633218c26362f_2c975751414149337@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 72438a3d by Sylvain Henry at 2022-09-26T23:28:34+02:00 Skip T14373 because it requires Cmm - - - - - 1 changed file: - testsuite/tests/codeGen/should_compile/all.T Changes: ===================================== testsuite/tests/codeGen/should_compile/all.T ===================================== @@ -66,26 +66,36 @@ test('T17334', [ unless(have_ncg() and (arch('x86_64') or arch('i386')), skip) , only_ways(['normal']) ], compile, ['-O']) -test('T14373', [], +test('T14373', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373', '-fasm -O2 -c -ddump-cmm-from-stg', 'grep -e "const T14373\.._closure+.;"']) switch_skeleton_only = 'grep -e "switch \[" -e "case " -e "default: " | sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g"' -test('T14373a', [], +test('T14373a', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373a', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -test('T14373b', [], +test('T14373b', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373b', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) -test('T14373c', [], +test('T14373c', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373c', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_only]) switch_skeleton_and_entries_only = ('grep -e "switch \[" -e "case " -e "default: " -e "Default_entry(" -e "R1 = .*_closure+2;"' '| sed -e "s|\] .*|\]|g" -e "s|goto .*|goto |g" -e "s|R1 = .*_closure+2;.*|R1 = XYZ_closure+2;|g" -e "s|//.*|//|g"') -test('T14373d', [], +test('T14373d', + [ js_skip # JS backend doesn't produce Cmm + ], multimod_compile_filter, ['T14373d', '-fasm -O2 -c -ddump-cmm-from-stg', switch_skeleton_and_entries_only]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72438a3da1be4db4d14f655ce2cdbc59ba03b921 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72438a3da1be4db4d14f655ce2cdbc59ba03b921 You're receiving 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 Sep 26 21:27:04 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 17:27:04 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Disable cg010 with JS backend Message-ID: <63321928bd45f_2c9757514781495e1@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 726b3a12 by Sylvain Henry at 2022-09-26T23:30:16+02:00 Disable cg010 with JS backend - - - - - 1 changed file: - testsuite/tests/codeGen/should_compile/cg010/all.T Changes: ===================================== testsuite/tests/codeGen/should_compile/cg010/all.T ===================================== @@ -1 +1,4 @@ -test('cg010', [extra_files(['A.hs','Main.hs'])], makefile_test, ['cg010']) +test('cg010', + [ extra_files(['A.hs','Main.hs']) + , js_skip # skip with JS backend because Cmm is required + ], makefile_test, ['cg010']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/726b3a12f0e739d9de62711c048fe195e4d8f242 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/726b3a12f0e739d9de62711c048fe195e4d8f242 You're receiving 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 Sep 26 21:30:39 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 26 Sep 2022 17:30:39 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Testsuite: better normalisation of .jsexe extension Message-ID: <633219ff669c2_2c9757dfd4014976e@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 23c4c228 by Sylvain Henry at 2022-09-26T23:33:47+02:00 Testsuite: better normalisation of .jsexe extension - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -2425,6 +2425,7 @@ def normalise_slashes_( s: str ) -> str: def normalise_exe_( s: str ) -> str: s = re.sub('\.exe', '', s) + s = re.sub('\.jsexe', '', s) return s def normalise_output( s: str ) -> str: @@ -2433,8 +2434,10 @@ def normalise_output( s: str ) -> str: s = modify_lines(s, lambda l: re.sub(' error:', '', l)) s = modify_lines(s, lambda l: re.sub(' Warning:', ' warning:', l)) # Remove a .exe extension (for Windows) + # and .jsexe extension (for the JS backend) # This can occur in error messages generated by the program. s = re.sub('([^\\s])\\.exe', '\\1', s) + s = re.sub('([^\\s])\\.jsexe', '\\1', s) s = normalise_callstacks(s) s = normalise_type_reps(s) # ghci outputs are pretty unstable with -fexternal-dynamic-refs, which is View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23c4c22834e5952a90294d7aefa074a422cc4ad7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23c4c22834e5952a90294d7aefa074a422cc4ad7 You're receiving 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 Sep 26 21:35:33 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Mon, 26 Sep 2022 17:35:33 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: JS.Linker: Cleanup: remove unused functions/types Message-ID: <63321b258463_2c9757514001523c@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 23b4ec7e by doyougnu at 2022-09-26T17:34:55-04:00 JS.Linker: Cleanup: remove unused functions/types - - - - - 3238b3eb by doyougnu at 2022-09-26T17:34:56-04:00 JS.Rts.Types: remove dead code, docs - - - - - 816fea7f by doyougnu at 2022-09-26T17:34:56-04:00 StgToJS.RTS: cleanup and more docs - - - - - 4 changed files: - compiler/GHC/JS/Make.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/StgToJS/Rts/Rts.hs - compiler/GHC/StgToJS/Rts/Types.hs Changes: ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -103,6 +103,7 @@ module GHC.JS.Make , returnStack, assignAllEqual, assignAll, assignAllReverseOrder , declAssignAll , nullStat, (.^) + , trace -- ** Hash combinators , jhEmpty , jhSingle @@ -527,10 +528,12 @@ assignAll xs ys = mconcat (zipWith (|=) xs ys) assignAllReverseOrder :: [JExpr] -> [JExpr] -> JStat assignAllReverseOrder xs ys = mconcat (reverse (zipWith (|=) xs ys)) - declAssignAll :: [Ident] -> [JExpr] -> JStat declAssignAll xs ys = mconcat (zipWith (||=) xs ys) +trace :: ToJExpr a => a -> JStat +trace ex = appS "h$log" [toJExpr ex] + -------------------------------------------------------------------------------- -- Literals @@ -661,6 +664,7 @@ allocClsA i = toJExpr (TxtI (clsCache ! i)) -------------------------------------------------------------------------------- -- New Identifiers -------------------------------------------------------------------------------- + -- | The 'ToSat' class is heavily used in the Introduction function. It ensures -- that all identifiers in the EDSL are tracked and named with an 'IdentSupply'. class ToSat a where ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -65,7 +65,7 @@ import Data.Int import Data.IntSet (IntSet) import qualified Data.IntSet as IS import Data.IORef -import Data.List ( partition, nub, foldl', intercalate, group, sort +import Data.List ( partition, nub, intercalate, group, sort , groupBy, intersperse ) import Data.Map.Strict (Map) @@ -77,7 +77,7 @@ import Data.Word import GHC.Generics (Generic) -import System.FilePath (splitPath, (<.>), (), dropExtension) +import System.FilePath ((<.>), (), dropExtension) import System.Directory ( createDirectoryIfMissing , doesFileExist , getCurrentDirectory @@ -390,9 +390,6 @@ linkerStats meta s = module_stats = "code size per module (in bytes):\n\n" <> unlines (map (concatMap showMod) pkgMods) -splitPath' :: FilePath -> [FilePath] -splitPath' = map (filter (`notElem` ("/\\"::String))) . splitPath - getPackageArchives :: StgToJSConfig -> [([FilePath],[String])] -> IO [FilePath] getPackageArchives cfg pkgs = filterM doesFileExist [ p "lib" ++ l ++ profSuff <.> "a" @@ -402,15 +399,6 @@ getPackageArchives cfg pkgs = profSuff | csProf cfg = "_p" | otherwise = "" --- fixme the wired-in package id's we get from GHC we have no version -getShims :: [FilePath] -> [UnitId] -> IO ([FilePath], [FilePath]) -getShims = panic "Panic from getShims: Shims not implemented! no to shims!" --- getShims dflags extraFiles pkgDeps = do --- (w,a) <- collectShims (getLibDir dflags "shims") --- (map (convertPkg dflags) pkgDeps) --- extraFiles' <- mapM canonicalizePath extraFiles --- return (w, a++extraFiles') - {- | convenience: combine rts.js, lib.js, out.js to all.js that can be run directly with node.js or SpiderMonkey jsshell -} @@ -478,16 +466,6 @@ writeRunner _settings out = do perms <- getPermissions runner setPermissions runner (perms {executable = True}) --- | write the manifest.webapp file that for firefox os -writeWebAppManifest :: FilePath -- ^ top directory - -> FilePath -- ^ output directory - -> IO () -writeWebAppManifest top out = do - e <- doesFileExist manifestFile - unless e $ B.readFile (top "manifest.webapp") >>= B.writeFile manifestFile - where - manifestFile = out "manifest.webapp" - rtsExterns :: FastString rtsExterns = "// GHCJS RTS externs for closure compiler ADVANCED_OPTIMIZATIONS\n\n" <> @@ -498,10 +476,6 @@ writeExterns :: FilePath -> IO () writeExterns out = writeFile (out "all.js.externs") $ unpackFS rtsExterns --- | get all functions in a module -modFuns :: Deps -> [ExportedFun] -modFuns (Deps _m _r e _b) = M.keys e - -- | get all dependencies for a given set of roots getDeps :: Map Module Deps -- ^ loaded deps -> Set LinkableUnit -- ^ don't link these blocks @@ -638,18 +612,6 @@ readArObject ar_state mod ar_file = do go_entries entries -{- | Static dependencies are symbols that need to be linked regardless - of whether the linked program refers to them. For example - dependencies that the RTS uses or symbols that the user program - refers to directly - -} -newtype StaticDeps = - StaticDeps { unStaticDeps :: [(FastString, FastString)] -- module/symbol - } - -noStaticDeps :: StaticDeps -noStaticDeps = StaticDeps [] - -- | A helper function to read system dependencies that are hardcoded via a file -- path. @@ -736,13 +698,16 @@ thDeps pkgs = diffDeps pkgs $ , S.fromList $ mkBaseFuns "GHC.JS.Prim.TH.Eval" ["runTHServer"] ) - +-- | Export the functions in base mkBaseFuns :: FastString -> [FastString] -> [ExportedFun] mkBaseFuns = mkExportedFuns baseUnitId +-- | Export the Prim functions mkPrimFuns :: FastString -> [FastString] -> [ExportedFun] mkPrimFuns = mkExportedFuns primUnitId +-- | Given a @UnitId@, a module name, and a set of symbols in the module, +-- package these into an @ExportedFun at . mkExportedFuns :: UnitId -> FastString -> [FastString] -> [ExportedFun] mkExportedFuns uid mod_name symbols = map mk_fun symbols where @@ -765,67 +730,12 @@ mkJsSymbol mod s = mkFastString $ mconcat will all come from the same version, but it's undefined which one. -} -type SDep = (FastString, FastString) -- ^ module/symbol - -staticDeps :: UnitEnv - -> [(FastString, Module)] -- ^ wired-in package names / keys - -> StaticDeps -- ^ deps from yaml file - -> (StaticDeps, Set UnitId, Set ExportedFun) - -- ^ the StaticDeps contains the symbols - -- for which no package could be found -staticDeps unit_env wiredin sdeps = mkDeps sdeps - where - u_st = ue_units unit_env - mkDeps (StaticDeps ds) = - let (u, p, r) = foldl' resolveDep ([], S.empty, S.empty) ds - in (StaticDeps u, closePackageDeps u_st p, r) - resolveDep :: ([SDep], Set UnitId, Set ExportedFun) - -> SDep - -> ([SDep], Set UnitId, Set ExportedFun) - resolveDep (unresolved, pkgs, resolved) dep@(mod_name, s) = - -- lookup our module in wiredin names - case lookup mod_name wiredin of - -- we didn't find the module in wiredin so add to unresolved - Nothing -> ( dep : unresolved, pkgs, resolved) - -- this is a wired in module - Just mod -> - let mod_uid = moduleUnitId mod - in case lookupUnitId u_st mod_uid of - -- couldn't find the uid for this wired in package so explode - Nothing -> pprPanic ("Package key for wired-in dependency could not be found.`" - ++ "I looked for: " - ++ unpackFS mod_name - ++ " received " ++ moduleNameString (moduleName mod) - ++ " but could not find: " ++ unitString mod_uid - ++ " in the UnitState." - ++ " Here is too much info for you: ") - $ pprWithUnitState u_st (ppr mod) - -- we are all good, add the uid to the package set, construct - -- its symbols on the fly and add the module to exported symbol - -- set - Just _ -> ( unresolved - , S.insert mod_uid pkgs - , S.insert (ExportedFun mod - . LexicalFastString $ mkJsSymbol mod s) resolved - ) - -closePackageDeps :: UnitState -> Set UnitId -> Set UnitId -closePackageDeps u_st pkgs - | S.size pkgs == S.size pkgs' = pkgs - | otherwise = closePackageDeps u_st pkgs' - where - pkgs' = pkgs `S.union` S.fromList (concatMap deps $ S.toList pkgs) - notFound = error "closePackageDeps: package not found" - deps :: UnitId -> [UnitId] - deps = unitDepends - . fromMaybe notFound - . lookupUnitId u_st - --- read all dependency data from the to-be-linked files +-- | read all dependency data from the to-be-linked files loadObjDeps :: [LinkedObj] -- ^ object files to link -> IO (Map Module (Deps, DepsLocation), [LinkableUnit]) loadObjDeps objs = prepareLoadedDeps <$> mapM readDepsFile' objs +-- | Load dependencies for the Linker from Ar loadArchiveDeps :: GhcjsEnv -> [FilePath] -> IO ( Map Module (Deps, DepsLocation) @@ -859,9 +769,11 @@ loadArchiveDeps' archives = do let !deps = objDeps obj pure $ Just (deps, ArchiveFile ar_file) +-- | Predicate to check that an entry in Ar is a JS payload isJsFile :: Ar.ArchiveEntry -> Bool isJsFile = checkEntryHeader "//JavaScript" +-- | Ensure that the entry header to the Archive object is sound. checkEntryHeader :: B.ByteString -> Ar.ArchiveEntry -> Bool checkEntryHeader header entry = B.take (B.length header) (Ar.filedata entry) == header @@ -879,7 +791,7 @@ prepareLoadedDeps deps = requiredUnits :: Deps -> [LinkableUnit] requiredUnits d = map (depsModule d,) (IS.toList $ depsRequired d) --- read dependencies from an object that might have already been into memory +-- | read dependencies from an object that might have already been into memory -- pulls in all Deps from an archive readDepsFile' :: LinkedObj -> IO (Deps, DepsLocation) readDepsFile' = \case @@ -889,8 +801,3 @@ readDepsFile' = \case ObjFile file -> do deps <- readObjectDeps file pure (deps,ObjectFile file) - --- generateBase :: FilePath -> Base -> IO () --- generateBase outDir b = --- BL.writeFile (outDir "out.base.symbs") (renderBase b) - ===================================== compiler/GHC/StgToJS/Rts/Rts.hs ===================================== @@ -17,7 +17,9 @@ -- Top level driver of the JavaScript Backend RTS. This file is an -- implementation of the JS RTS for the JS backend written as an EDSL in -- Haskell. It assumes the existence of pre-generated JS functions, included as --- js-sources... +-- js-sources in base. These functions are similarly assumed for non-inline +-- Primops, See 'GHC.StgToJS.Prim'. Most of the elements in this module are +-- constants in Haskell Land which define pieces of the JS RTS. -- ----------------------------------------------------------------------------- @@ -46,23 +48,37 @@ import Data.Monoid import Data.Char (toLower, toUpper) import qualified Data.Bits as Bits +-- | The garbageCollector resets registers and result variables. garbageCollector :: JStat garbageCollector = mconcat [ TxtI "h$resetRegisters" ||= jLam (mconcat $ map resetRegister [minBound..maxBound]) , TxtI "h$resetResultVars" ||= jLam (mconcat $ map resetResultVar [minBound..maxBound]) ] - +-- | Reset the register 'r' in JS Land. Note that this "resets" by setting the +-- register to a dummy variable called "null", /not/ by setting to JS's nil +-- value. resetRegister :: StgReg -> JStat resetRegister r = toJExpr r |= null_ +-- | Reset the return variable 'r' in JS Land. Note that this "resets" by +-- setting the register to a dummy variable called "null", /not/ by setting to +-- JS's nil value. resetResultVar :: StgRet -> JStat resetResultVar r = toJExpr r |= null_ -{- - use h$c1, h$c2, h$c3, ... h$c24 instead of making objects manually so layouts - and fields can be changed more easily - -} +-- | Define closures based on size, these functions are syntactic sugar, e.g., a +-- Haskell function which generates some useful JS. Each Closure constructor +-- follows the naming convention h$cN, where N is a natural number. For example, +-- h$c (with the nat omitted) is a JS Land Constructor for a closure in JS land +-- which has a single entry function 'f', and no fields; identical to h$c0. h$c1 +-- is a JS Land Constructor for a closure with an entry function 'f', and a +-- /single/ field 'x1', 'Just foo' is an example of this kind of closure. h$c2 +-- is a JS Land Constructor for a closure with an entry function and two data +-- fields: 'x1' and 'x2'. And so on. Note that this has JIT performance +-- implications; you should use h$c1, h$c2, h$c3, ... h$c24 instead of making +-- objects manually so layouts and fields can be changed more easily and so the +-- JIT can optimize better. closureConstructors :: StgToJSConfig -> JStat closureConstructors s = BlockStat [ declClsConstr "h$c" ["f"] $ Closure @@ -192,6 +208,7 @@ closureConstructors s = BlockStat extra_args = ValExpr . JHash . listToUniqMap . zip ds $ map (toJExpr . TxtI) ds fun = JFunc (map TxtI ds) (checkD <> returnS extra_args) +-- | JS Payload to perform stack manipulation in the RTS stackManip :: JStat stackManip = mconcat (map mkPush [1..32]) <> mconcat (map mkPpush [1..255]) @@ -242,6 +259,7 @@ bhLneStats _s p frameSize = ] +-- | JS payload to declare the registers declRegs :: JStat declRegs = mconcat [ TxtI "h$regs" ||= toJExpr (JList []) @@ -253,6 +271,7 @@ declRegs = declReg r = (decl . TxtI . mkFastString . ("h$"++) . map toLower . show) r <> BlockStat [AssignStat (toJExpr r) (ValExpr (JInt 0))] -- [j| `r` = 0; |] +-- | JS payload to define getters and setters on the registers. regGettersSetters :: JStat regGettersSetters = mconcat [ TxtI "h$getReg" ||= jLam (\n -> SwitchStat n getRegCases mempty) @@ -264,6 +283,7 @@ regGettersSetters = setRegCases v = map (\r -> (toJExpr (jsRegToInt r), (toJExpr r |= toJExpr v) <> returnS undefined_)) regsFromR1 +-- | JS payload that defines the functions to load each register loadRegs :: JStat loadRegs = mconcat $ map mkLoad [1..32] where @@ -275,9 +295,9 @@ loadRegs = mconcat $ map mkLoad [1..32] fun = JFunc args (mconcat assign) in fname ||= toJExpr fun --- assign registers R1 ... Rn --- assigns Rn first -assignRegs :: StgToJSConfig -> [JExpr] -> JStat +-- | Assign registers R1 ... Rn in descending order, that is assign Rn first. +-- This function uses the 'assignRegs'' array to construct functions which set +-- the registers. assignRegs :: StgToJSConfig -> [JExpr] -> JStat assignRegs _ [] = mempty assignRegs s xs | l <= 32 && not (csInlineLoadRegs s) @@ -287,15 +307,24 @@ assignRegs s xs where l = length xs +-- | JS payload which defines an array of function symbols that set N registers +-- from M parameters. For example, h$l2 compiles to: +-- @ +-- function h$l4(x1, x2, x3, x4) { +-- h$r4 = x1; +-- h$r3 = x2; +-- h$r2 = x3; +-- h$r1 = x4; +-- }; +-- @ assignRegs' :: Array Int Ident assignRegs' = listArray (1,32) (map (TxtI . mkFastString . ("h$l"++) . show) [(1::Int)..32]) +-- | JS payload to declare return variables. declRets :: JStat declRets = mconcat $ map (decl . TxtI . mkFastString . ("h$"++) . map toLower . show) (enumFrom Ret1) -trace :: ToJExpr a => a -> JStat -trace ex = appS "h$log" [toJExpr ex] - +-- | JS payload defining the types closures. closureTypes :: JStat closureTypes = mconcat (map mkClosureType (enumFromTo minBound maxBound)) <> closureTypeName where @@ -311,6 +340,7 @@ closureTypes = mconcat (map mkClosureType (enumFromTo minBound maxBound)) <> clo ifCT :: JExpr -> ClosureType -> JStat ifCT arg ct = jwhenS (arg .===. toJExpr ct) (returnS (toJExpr (show ct))) +-- | JS payload declaring the RTS functions. rtsDecls :: JStat rtsDecls = jsSaturate (Just "h$RTSD") $ mconcat [ TxtI "h$currentThread" ||= null_ -- thread state object for current thread @@ -325,15 +355,19 @@ rtsDecls = jsSaturate (Just "h$RTSD") $ , declRegs , declRets] +-- | print the embedded RTS to a String rtsText :: StgToJSConfig -> String rtsText = show . pretty . rts +-- | print the RTS declarations to a String. rtsDeclsText :: String rtsDeclsText = show . pretty $ rtsDecls +-- | Wrapper over the RTS to guarentee saturation, see 'GHC.JS.Transform' rts :: StgToJSConfig -> JStat rts = jsSaturate (Just "h$RTS") . rts' +-- | JS Payload which defines the embedded RTS. rts' :: StgToJSConfig -> JStat rts' s = mconcat [ closureConstructors s ===================================== compiler/GHC/StgToJS/Rts/Types.hs ===================================== @@ -26,35 +26,32 @@ import GHC.JS.Syntax import GHC.StgToJS.Regs import GHC.StgToJS.Types -import GHC.Utils.Monad.State.Strict - -import GHC.Data.FastString - +-------------------------------------------------------------------------------- +-- Syntactic Sugar for some Utilities we want in JS land +-------------------------------------------------------------------------------- +-- | Syntactic sugar, i.e., a Haskell function which generates useful JS code. +-- Given a @JExpr@, 'ex', inject a trace statement on 'ex' in the compiled JS +-- program traceRts :: StgToJSConfig -> JExpr -> JStat -traceRts s ex = jStatIf (csTraceRts s) (appS "h$log" [ex]) +traceRts s ex | (csTraceRts s) = appS "h$log" [ex] + | otherwise = mempty +-- | Syntactic sugar. Given a @JExpr@, 'ex' which is assumed to be a predicate, +-- and a message 'm', assert that 'not ex' is True, if not throw an exception in +-- JS land with message 'm'. assertRts :: ToJExpr a => StgToJSConfig -> JExpr -> a -> JStat -assertRts s ex m = jStatIf (csAssertRts s) - (jwhenS (UOpExpr NotOp ex) (appS "throw" [toJExpr m])) - -jStatIf :: Bool -> JStat -> JStat -jStatIf True s = s -jStatIf _ _ = mempty +assertRts s ex m | csAssertRts s = jwhenS (UOpExpr NotOp ex) (appS "throw" [toJExpr m]) + | otherwise = mempty +-- | name of the closure 'c' clName :: JExpr -> JExpr clName c = c .^ "n" +-- | Type name of the closure 'c' clTypeName :: JExpr -> JExpr clTypeName c = app "h$closureTypeName" [c .^ "t"] -type C = State GenState JStat - -assertRtsStat :: C -> C -assertRtsStat stat = do - s <- gets gsSettings - if csAssertRts s then stat else return mempty - -- number of arguments (arity & 0xff = arguments, arity >> 8 = number of registers) stackFrameSize :: JExpr -- ^ assign frame size to this -> JExpr -- ^ stack frame header function @@ -71,33 +68,11 @@ stackFrameSize tgt f = ] )) --- some utilities do do something with a range of regs --- start or end possibly supplied as javascript expr -withRegs :: StgReg -> StgReg -> (StgReg -> JStat) -> JStat -withRegs start end f = mconcat $ map f [start..end] - -withRegs' :: StgReg -> StgReg -> (StgReg -> JStat) -> JStat -withRegs' start end = withRegs start end - --- start from js expr, start is guaranteed to be at least min --- from low to high (fallthrough!) -withRegsS :: JExpr -> StgReg -> StgReg -> Bool -> (StgReg -> JStat) -> JStat -withRegsS start min end fallthrough f = - SwitchStat start (map mkCase [min..end]) mempty - where - brk | fallthrough = mempty - | otherwise = BreakStat Nothing - mkCase r = let stat = f r - in (toJExpr r, mconcat [stat , stat , brk]) +-------------------------------------------------------------------------------- +-- Register utilities +-------------------------------------------------------------------------------- --- end from js expr, from high to low -withRegsRE :: StgReg -> JExpr -> StgReg -> Bool -> (StgReg -> JStat) -> JStat -withRegsRE start end max fallthrough f = - SwitchStat end (reverse $ map mkCase [start..max]) mempty - where - brk | fallthrough = mempty - | otherwise = BreakStat Nothing - mkCase r = (toJExpr (fromEnum r), mconcat [f r , brk]) - -jsVar :: String -> JExpr -jsVar = ValExpr . JVar . TxtI . mkFastString +-- | Perform the computation 'f', on the range of registers bounded by 'start' +-- and 'end'. +withRegs :: StgReg -> StgReg -> (StgReg -> JStat) -> JStat +withRegs start end f = mconcat $ fmap f [start..end] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23c4c22834e5952a90294d7aefa074a422cc4ad7...816fea7ff6ef3af4d4a9e49c8874b746efbc01ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23c4c22834e5952a90294d7aefa074a422cc4ad7...816fea7ff6ef3af4d4a9e49c8874b746efbc01ec You're receiving 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 Sep 26 21:36:13 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Mon, 26 Sep 2022 17:36:13 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.RTS: cleanup and more docs Message-ID: <63321b4d17072_2c97575143c152510@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: f497fe1a by doyougnu at 2022-09-26T17:36:01-04:00 StgToJS.RTS: cleanup and more docs - - - - - 2 changed files: - compiler/GHC/JS/Make.hs - compiler/GHC/StgToJS/Rts/Rts.hs Changes: ===================================== compiler/GHC/JS/Make.hs ===================================== @@ -103,6 +103,7 @@ module GHC.JS.Make , returnStack, assignAllEqual, assignAll, assignAllReverseOrder , declAssignAll , nullStat, (.^) + , trace -- ** Hash combinators , jhEmpty , jhSingle @@ -527,10 +528,12 @@ assignAll xs ys = mconcat (zipWith (|=) xs ys) assignAllReverseOrder :: [JExpr] -> [JExpr] -> JStat assignAllReverseOrder xs ys = mconcat (reverse (zipWith (|=) xs ys)) - declAssignAll :: [Ident] -> [JExpr] -> JStat declAssignAll xs ys = mconcat (zipWith (||=) xs ys) +trace :: ToJExpr a => a -> JStat +trace ex = appS "h$log" [toJExpr ex] + -------------------------------------------------------------------------------- -- Literals @@ -661,6 +664,7 @@ allocClsA i = toJExpr (TxtI (clsCache ! i)) -------------------------------------------------------------------------------- -- New Identifiers -------------------------------------------------------------------------------- + -- | The 'ToSat' class is heavily used in the Introduction function. It ensures -- that all identifiers in the EDSL are tracked and named with an 'IdentSupply'. class ToSat a where ===================================== compiler/GHC/StgToJS/Rts/Rts.hs ===================================== @@ -17,7 +17,9 @@ -- Top level driver of the JavaScript Backend RTS. This file is an -- implementation of the JS RTS for the JS backend written as an EDSL in -- Haskell. It assumes the existence of pre-generated JS functions, included as --- js-sources... +-- js-sources in base. These functions are similarly assumed for non-inline +-- Primops, See 'GHC.StgToJS.Prim'. Most of the elements in this module are +-- constants in Haskell Land which define pieces of the JS RTS. -- ----------------------------------------------------------------------------- @@ -46,23 +48,37 @@ import Data.Monoid import Data.Char (toLower, toUpper) import qualified Data.Bits as Bits +-- | The garbageCollector resets registers and result variables. garbageCollector :: JStat garbageCollector = mconcat [ TxtI "h$resetRegisters" ||= jLam (mconcat $ map resetRegister [minBound..maxBound]) , TxtI "h$resetResultVars" ||= jLam (mconcat $ map resetResultVar [minBound..maxBound]) ] - +-- | Reset the register 'r' in JS Land. Note that this "resets" by setting the +-- register to a dummy variable called "null", /not/ by setting to JS's nil +-- value. resetRegister :: StgReg -> JStat resetRegister r = toJExpr r |= null_ +-- | Reset the return variable 'r' in JS Land. Note that this "resets" by +-- setting the register to a dummy variable called "null", /not/ by setting to +-- JS's nil value. resetResultVar :: StgRet -> JStat resetResultVar r = toJExpr r |= null_ -{- - use h$c1, h$c2, h$c3, ... h$c24 instead of making objects manually so layouts - and fields can be changed more easily - -} +-- | Define closures based on size, these functions are syntactic sugar, e.g., a +-- Haskell function which generates some useful JS. Each Closure constructor +-- follows the naming convention h$cN, where N is a natural number. For example, +-- h$c (with the nat omitted) is a JS Land Constructor for a closure in JS land +-- which has a single entry function 'f', and no fields; identical to h$c0. h$c1 +-- is a JS Land Constructor for a closure with an entry function 'f', and a +-- /single/ field 'x1', 'Just foo' is an example of this kind of closure. h$c2 +-- is a JS Land Constructor for a closure with an entry function and two data +-- fields: 'x1' and 'x2'. And so on. Note that this has JIT performance +-- implications; you should use h$c1, h$c2, h$c3, ... h$c24 instead of making +-- objects manually so layouts and fields can be changed more easily and so the +-- JIT can optimize better. closureConstructors :: StgToJSConfig -> JStat closureConstructors s = BlockStat [ declClsConstr "h$c" ["f"] $ Closure @@ -192,6 +208,7 @@ closureConstructors s = BlockStat extra_args = ValExpr . JHash . listToUniqMap . zip ds $ map (toJExpr . TxtI) ds fun = JFunc (map TxtI ds) (checkD <> returnS extra_args) +-- | JS Payload to perform stack manipulation in the RTS stackManip :: JStat stackManip = mconcat (map mkPush [1..32]) <> mconcat (map mkPpush [1..255]) @@ -242,6 +259,7 @@ bhLneStats _s p frameSize = ] +-- | JS payload to declare the registers declRegs :: JStat declRegs = mconcat [ TxtI "h$regs" ||= toJExpr (JList []) @@ -253,6 +271,7 @@ declRegs = declReg r = (decl . TxtI . mkFastString . ("h$"++) . map toLower . show) r <> BlockStat [AssignStat (toJExpr r) (ValExpr (JInt 0))] -- [j| `r` = 0; |] +-- | JS payload to define getters and setters on the registers. regGettersSetters :: JStat regGettersSetters = mconcat [ TxtI "h$getReg" ||= jLam (\n -> SwitchStat n getRegCases mempty) @@ -264,6 +283,7 @@ regGettersSetters = setRegCases v = map (\r -> (toJExpr (jsRegToInt r), (toJExpr r |= toJExpr v) <> returnS undefined_)) regsFromR1 +-- | JS payload that defines the functions to load each register loadRegs :: JStat loadRegs = mconcat $ map mkLoad [1..32] where @@ -275,8 +295,9 @@ loadRegs = mconcat $ map mkLoad [1..32] fun = JFunc args (mconcat assign) in fname ||= toJExpr fun --- assign registers R1 ... Rn --- assigns Rn first +-- | Assign registers R1 ... Rn in descending order, that is assign Rn first. +-- This function uses the 'assignRegs'' array to construct functions which set +-- the registers. assignRegs :: StgToJSConfig -> [JExpr] -> JStat assignRegs _ [] = mempty assignRegs s xs @@ -287,15 +308,24 @@ assignRegs s xs where l = length xs +-- | JS payload which defines an array of function symbols that set N registers +-- from M parameters. For example, h$l2 compiles to: +-- @ +-- function h$l4(x1, x2, x3, x4) { +-- h$r4 = x1; +-- h$r3 = x2; +-- h$r2 = x3; +-- h$r1 = x4; +-- }; +-- @ assignRegs' :: Array Int Ident assignRegs' = listArray (1,32) (map (TxtI . mkFastString . ("h$l"++) . show) [(1::Int)..32]) +-- | JS payload to declare return variables. declRets :: JStat declRets = mconcat $ map (decl . TxtI . mkFastString . ("h$"++) . map toLower . show) (enumFrom Ret1) -trace :: ToJExpr a => a -> JStat -trace ex = appS "h$log" [toJExpr ex] - +-- | JS payload defining the types closures. closureTypes :: JStat closureTypes = mconcat (map mkClosureType (enumFromTo minBound maxBound)) <> closureTypeName where @@ -311,6 +341,7 @@ closureTypes = mconcat (map mkClosureType (enumFromTo minBound maxBound)) <> clo ifCT :: JExpr -> ClosureType -> JStat ifCT arg ct = jwhenS (arg .===. toJExpr ct) (returnS (toJExpr (show ct))) +-- | JS payload declaring the RTS functions. rtsDecls :: JStat rtsDecls = jsSaturate (Just "h$RTSD") $ mconcat [ TxtI "h$currentThread" ||= null_ -- thread state object for current thread @@ -325,15 +356,19 @@ rtsDecls = jsSaturate (Just "h$RTSD") $ , declRegs , declRets] +-- | print the embedded RTS to a String rtsText :: StgToJSConfig -> String rtsText = show . pretty . rts +-- | print the RTS declarations to a String. rtsDeclsText :: String rtsDeclsText = show . pretty $ rtsDecls +-- | Wrapper over the RTS to guarentee saturation, see 'GHC.JS.Transform' rts :: StgToJSConfig -> JStat rts = jsSaturate (Just "h$RTS") . rts' +-- | JS Payload which defines the embedded RTS. rts' :: StgToJSConfig -> JStat rts' s = mconcat [ closureConstructors s View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f497fe1ab56f7ba9025c1ec98c3f464088749641 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f497fe1ab56f7ba9025c1ec98c3f464088749641 You're receiving 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 Sep 26 22:08:32 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 26 Sep 2022 18:08:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-ubx-cast Message-ID: <633222e05191f_2c97575143c1592b9@gitlab.mail> Andreas Klebinger pushed new branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-ubx-cast You're receiving 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 Sep 26 22:21:12 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 26 Sep 2022 18:21:12 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <633225d81ca8f_2c9757514281705b6@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 861bb0ac by Andreas Klebinger at 2022-09-27T00:20:04+02:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations. * 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 ------------------------- Metric Decrease: T1969 ------------------------- - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,8 @@ -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +97,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +267,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1865,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1914,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1933,56 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2724,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> LResult a) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- type WarnsAndErrs = (# Bag SDoc, Bag SDoc #) + +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2883,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2936,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2967,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2983,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3023,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3039,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3059,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -2521,12 +2522,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,10 +295,10 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S --- import GHC.Utils.Trace -- $type_classification -- #type_classification# @@ -556,7 +557,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2788,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [Type comparisons using object pointer comparisons] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by a single object +in the heap. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2811,15 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + -- See Note [Type comparisons using object pointer comparisons] + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,50 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.CmdLine ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.Backpack.Syntax View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/861bb0ac584fea4116c97d6c6ef13caa8822ca64 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/861bb0ac584fea4116c97d6c6ef13caa8822ca64 You're receiving 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 Sep 26 22:23:40 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 26 Sep 2022 18:23:40 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] 2 commits: Avoid some pointless output in the testsuite Message-ID: <6332266cf08b5_2c97575148c17268f@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 632db7af by Andreas Klebinger at 2022-09-27T00:10:47+02:00 Avoid some pointless output in the testsuite - - - - - a796d89e by Andreas Klebinger at 2022-09-27T00:22:45+02:00 Fix some lint issues - - - - - 2 changed files: - compiler/GHC/Stg/Unarise.hs - testsuite/driver/testlib.py Changes: ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -283,7 +283,6 @@ import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM import GHC.Utils.Trace import GHC.Builtin.PrimOps -import GHC.Platform import GHC.Builtin.PrimOps.Casts import Data.List import GHC.Types.Name ===================================== 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): View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dccda9ccfbb8ee4bb0f8aefa254d1ec1331efa7e...a796d89eb52d4b0e9fbb5875340f8855d4232ca4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dccda9ccfbb8ee4bb0f8aefa254d1ec1331efa7e...a796d89eb52d4b0e9fbb5875340f8855d4232ca4 You're receiving 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 Sep 26 22:43:50 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 26 Sep 2022 18:43:50 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] More lint fallout Message-ID: <63322b26ae609_2c975753ffac183064@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: ec4c170d by Andreas Klebinger at 2022-09-27T00:42:56+02:00 More lint fallout - - - - - 1 changed file: - compiler/GHC/Stg/Pipeline.hs Changes: ===================================== compiler/GHC/Stg/Pipeline.hs ===================================== @@ -126,7 +126,7 @@ stg2stg logger extra_vars opts this_mod binds StgUnarise -> do us <- getUniqueSupplyM liftIO (stg_linter False "Pre-unarise" binds) - let binds' = {-# SCC "StgUnarise" #-} unarise (stgPlatform opts) us binds + let binds' = {-# SCC "StgUnarise" #-} unarise us binds liftIO (dump_when Opt_D_dump_stg_unarised "Unarised STG:" binds') liftIO (stg_linter True "Unarise" binds') return binds' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec4c170d4cc99d7b76ff49ec49244bb8c2284c2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec4c170d4cc99d7b76ff49ec49244bb8c2284c2e You're receiving 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 Sep 26 22:52:05 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 26 Sep 2022 18:52:05 -0400 Subject: [Git][ghc/ghc][wip/T22206] fixit Message-ID: <63322d15889eb_2c97575143c187041@gitlab.mail> Ben Gamari pushed to branch wip/T22206 at Glasgow Haskell Compiler / GHC Commits: 96c758af by Ben Gamari at 2022-09-26T22:52:04+00:00 fixit - - - - - 1 changed file: - rts/posix/OSThreads.c Changes: ===================================== rts/posix/OSThreads.c ===================================== @@ -218,7 +218,7 @@ int createOSThread (OSThreadId* pId, char *name STG_UNUSED, OSThreadProc *startProc, void *param) { - struct ThreadDesc *desc = stgMallocBytes("createOSThread", sizeof(struct ThreadDesc)); + struct ThreadDesc *desc = stgMallocBytes(sizeof(struct ThreadDesc), "createOSThread"); desc->startProc = startProc; desc->param = param; desc->name = name; @@ -227,6 +227,8 @@ createOSThread (OSThreadId* pId, char *name STG_UNUSED, if (!result) { pthread_detach(*pId); + } else { + stgFree(desc); } return result; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96c758af60299b38bc7cf2db2746c72598b12e92 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96c758af60299b38bc7cf2db2746c72598b12e92 You're receiving 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 Sep 26 22:57:16 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 26 Sep 2022 18:57:16 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-bindersof] Avoid allocating intermediate lists for non recursive bindings. Message-ID: <63322e4c53570_2c9757514001941c0@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-bindersof at Glasgow Haskell Compiler / GHC Commits: 36438646 by Andreas Klebinger at 2022-09-27T00:55:20+02:00 Avoid allocating intermediate lists for non recursive bindings. We give `Bind` a fold instance that performs better than converting to a list and folding over that instead. Fixes #22196 - - - - - 8 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Types/Var/Env.hs Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -42,6 +42,7 @@ module GHC.Core ( -- ** Simple 'Expr' access functions and predicates bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts, + foldBindersOfBindsStrict, collectBinders, collectTyBinders, collectTyAndValBinders, collectNBinders, collectNValBinders_maybe, collectArgs, stripNArgs, collectArgsTicks, flattenBinds, @@ -120,6 +121,7 @@ import GHC.Utils.Panic.Plain import Data.Data hiding (TyCon) import Data.Int import Data.Word +import Data.Foldable (Foldable(..)) infixl 4 `mkApps`, `mkTyApps`, `mkVarApps`, `App`, `mkCoApps` -- Left associative, so that we can say (f `mkTyApps` xs `mkVarApps` ys) @@ -315,6 +317,26 @@ data Bind b = NonRec b (Expr b) | Rec [(b, (Expr b))] deriving Data +instance Foldable Bind where + -- We want these to inline if the function is given as argument, so that the function + -- arguments will be a known function call. + {-# INLINE foldr #-} + foldr f = \r bind -> case bind of + NonRec b _ -> f b r + Rec pairs -> foldr f r . map fst $ pairs + {-# INLINE foldl' #-} + foldl' f = \r bind -> case bind of + NonRec b _ -> f r b + Rec pairs -> foldl' f r . map fst $ pairs + {-# INLINE foldMap #-} + foldMap f = \bind -> case bind of + NonRec b _ -> f b + Rec pairs -> foldMap f . map fst $ pairs + {-# INLINE foldMap' #-} + foldMap' f = \bind -> case bind of + NonRec b _ -> f b + Rec pairs -> foldMap' f . map fst $ pairs + {- Note [Shadowing] ~~~~~~~~~~~~~~~~ @@ -1943,6 +1965,7 @@ exprToType _bad = pprPanic "exprToType" empty -} -- | Extract every variable by this group +-- {-# INLINEABLE bindersOf #-} bindersOf :: Bind b -> [b] -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] in GHC.Core.Lint @@ -1953,6 +1976,11 @@ bindersOf (Rec pairs) = [binder | (binder, _) <- pairs] bindersOfBinds :: [Bind b] -> [b] bindersOfBinds binds = foldr ((++) . bindersOf) [] binds +-- We inline this to avoid unknown function calls. +{-# INLINE foldBindersOfBindsStrict #-} +foldBindersOfBindsStrict :: (a -> b -> a) -> a -> [Bind b] -> a +foldBindersOfBindsStrict f = \z binds -> foldl' (foldl' f) z binds + rhssOfBind :: Bind b -> [Expr b] rhssOfBind (NonRec _ rhs) = [rhs] rhssOfBind (Rec pairs) = [rhs | (_,rhs) <- pairs] ===================================== compiler/GHC/Core/Opt/Exitify.hs ===================================== @@ -62,7 +62,7 @@ exitifyProgram binds = map goTopLvl binds goTopLvl (Rec pairs) = Rec (map (second (go in_scope_toplvl)) pairs) -- Top-level bindings are never join points - in_scope_toplvl = emptyInScopeSet `extendInScopeSetList` bindersOfBinds binds + in_scope_toplvl = emptyInScopeSet `extendInScopeSetBndrs` binds go :: InScopeSet -> CoreExpr -> CoreExpr go _ e@(Var{}) = e @@ -94,7 +94,7 @@ exitifyProgram binds = map goTopLvl binds | otherwise = Let (Rec pairs') body' where is_join_rec = any (isJoinId . fst) pairs - in_scope' = in_scope `extendInScopeSetList` bindersOf (Rec pairs) + in_scope' = in_scope `extendInScopeSetBind` (Rec pairs) pairs' = mapSnd (go in_scope') pairs body' = go in_scope' body ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -82,7 +82,7 @@ import GHC.Core.Utils ( exprType, exprIsHNF , exprOkForSpeculation , exprIsTopLevelBindable , collectMakeStaticArgs - , mkLamTypes + , mkLamTypes, extendInScopeSetBndrs ) import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, isOneShotBndr ) import GHC.Core.FVs -- all of it @@ -1566,7 +1566,7 @@ initialEnv float_lams binds , le_subst = mkEmptySubst in_scope_toplvl , le_env = emptyVarEnv } where - in_scope_toplvl = emptyInScopeSet `extendInScopeSetList` bindersOfBinds binds + in_scope_toplvl = emptyInScopeSet `extendInScopeSetBndrs` binds -- 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 ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -812,10 +812,6 @@ addJoinFloats floats join_floats , sfInScope = foldlOL extendInScopeSetBind (sfInScope floats) join_floats } -extendInScopeSetBind :: InScopeSet -> CoreBind -> InScopeSet -extendInScopeSetBind in_scope bind - = extendInScopeSetList in_scope (bindersOf bind) - addFloats :: SimplFloats -> SimplFloats -> SimplFloats -- Add both let-floats and join-floats for env2 to env1; -- *plus* the in-scope set for env2, which is bigger ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -949,8 +949,7 @@ initScEnv guts sc_vals = emptyVarEnv, sc_annotations = anns }) } where - init_subst = mkEmptySubst $ mkInScopeSet $ mkVarSet $ - bindersOfBinds (mg_binds guts) + init_subst = mkEmptySubst $ mkInScopeSetBndrs (mg_binds guts) -- Acccount for top-level bindings that are not in dependency order; -- see Note [Glomming] in GHC.Core.Opt.OccurAnal -- Easiest thing is to bring all the top level binders into scope at once, ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -28,7 +28,7 @@ import GHC.Core import GHC.Core.Rules import GHC.Core.Utils ( exprIsTrivial , mkCast, exprType - , stripTicksTop ) + , stripTicksTop, mkInScopeSetBndrs ) import GHC.Core.FVs import GHC.Core.TyCo.Rep (TyCoBinder (..)) import GHC.Core.Opt.Arity( collectBindersPushingCo ) @@ -601,8 +601,10 @@ specProgram guts@(ModGuts { mg_module = this_mod -- accidentally re-use a unique that's already in use -- Easiest thing is to do it all at once, as if all the top-level -- decls were mutually recursive - ; let top_env = SE { se_subst = Core.mkEmptySubst $ mkInScopeSetList $ - bindersOfBinds binds + ; let top_env = SE { se_subst = Core.mkEmptySubst $ + mkInScopeSetBndrs binds + -- mkInScopeSetList $ + -- bindersOfBinds binds , se_module = this_mod , se_dflags = dflags } ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -47,6 +47,9 @@ module GHC.Core.Utils ( stripTicksTop, stripTicksTopE, stripTicksTopT, stripTicksE, stripTicksT, + -- InScopeSet things that can't live elsewhere because of import loops. + mkInScopeSetBndrs, extendInScopeSetBind, extendInScopeSetBndrs, + -- * StaticPtr collectMakeStaticArgs, @@ -2336,6 +2339,26 @@ normSplitTyConApp_maybe fam_envs ty = Just (tc, tc_args, co) normSplitTyConApp_maybe _ _ = Nothing +{- +***************************************************** +* +* InScopeSet things +* +***************************************************** +-} + + +extendInScopeSetBind :: InScopeSet -> CoreBind -> InScopeSet +extendInScopeSetBind (InScope in_scope) binds + = InScope $ foldl' extendVarSet in_scope binds + +extendInScopeSetBndrs :: InScopeSet -> [CoreBind] -> InScopeSet +extendInScopeSetBndrs (InScope in_scope) binds + = InScope $ foldBindersOfBindsStrict extendVarSet in_scope binds + +mkInScopeSetBndrs :: [CoreBind] -> InScopeSet +mkInScopeSetBndrs binds = foldBindersOfBindsStrict extendInScopeSet emptyInScopeSet binds + {- ***************************************************** * ===================================== compiler/GHC/Types/Var/Env.hs ===================================== @@ -47,7 +47,7 @@ module GHC.Types.Var.Env ( anyDVarEnv, -- * The InScopeSet type - InScopeSet, + InScopeSet(..), -- ** Operations on InScopeSets emptyInScopeSet, mkInScopeSet, mkInScopeSetList, delInScopeSet, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/364386467ae12847e001d5ad6ea6c473fb38e6d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/364386467ae12847e001d5ad6ea6c473fb38e6d6 You're receiving 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 Sep 26 23:07:51 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Mon, 26 Sep 2022 19:07:51 -0400 Subject: [Git][ghc/ghc][wip/clc-85] Export symbolSing, SSymbol, and friends (CLC#85) Message-ID: <633230c7af674_2c97575143c19524a@gitlab.mail> Ryan Scott pushed to branch wip/clc-85 at Glasgow Haskell Compiler / GHC Commits: 5ecb4ece by Ryan Scott at 2022-09-26T19:07:38-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. - - - - - 14 changed files: - compiler/GHC/Tc/Instance/Class.hs - libraries/base/GHC/TypeLits.hs - libraries/base/GHC/TypeNats.hs - libraries/base/changelog.md - + libraries/base/tests/T15183.hs - + libraries/base/tests/T15183.stdout - libraries/base/tests/all.T - testsuite/tests/dependent/should_compile/RaeJobTalk.hs - testsuite/tests/ghci/scripts/T19667Ghci.hs - testsuite/tests/ghci/scripts/T4175.stdout - testsuite/tests/ghci/scripts/T9181.stdout - testsuite/tests/ghci/scripts/ghci064.stdout - testsuite/tests/typecheck/should_run/T16646.hs - testsuite/tests/typecheck/should_run/T19667.hs Changes: ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -571,15 +571,15 @@ Some further observations about `withDict`: (WD3) As an alternative to `withDict`, one could define functions like `withT` above in terms of `unsafeCoerce`. This is more error-prone, however. -(WD4) In order to define things like `reifySymbol` below: +(WD4) In order to define things like `withKnownNat` below: - reifySymbol :: forall r. String -> (forall (n :: Symbol). KnownSymbol n => r) -> r + withKnownNat :: SNat n -> (KnownNat n => r) -> r `withDict` needs to be instantiated with `Any`, like so: - reifySymbol n k = withDict @(KnownSymbol Any) @String @r n (k @Any) + withKnownNat = withDict @(KnownNat Any) @(SNat Any) @r - The use of `Any` is explained in Note [NOINLINE someNatVal] in + The use of `Any` is explained in Note [NOINLINE withSomeSNat] in base:GHC.TypeNats. (WD5) In earlier implementations, `withDict` was implemented as an identifier ===================================== libraries/base/GHC/TypeLits.hs ===================================== @@ -11,6 +11,10 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ViewPatterns #-} {-| GHC's @DataKinds@ language extension lifts data constructors, natural @@ -34,15 +38,20 @@ module GHC.TypeLits N.Natural, N.Nat, Symbol -- Symbol is declared in GHC.Types in package ghc-prim -- * Linking type and value level - , N.KnownNat, natVal, natVal' - , KnownSymbol, symbolVal, symbolVal' - , KnownChar, charVal, charVal' + , N.KnownNat(natSing), natVal, natVal' + , KnownSymbol(symbolSing), symbolVal, symbolVal' + , KnownChar(charSing), charVal, charVal' , N.SomeNat(..), SomeSymbol(..), SomeChar(..) , someNatVal, someSymbolVal, someCharVal , N.sameNat, sameSymbol, sameChar , OrderingI(..) , N.cmpNat, cmpSymbol, cmpChar - + -- ** Singleton values + , N.SNat, SSymbol, SChar + , pattern N.SNat, pattern SSymbol, pattern SChar + , fromSNat, fromSSymbol, fromSChar + , withSomeSNat, withSomeSSymbol, withSomeSChar + , N.withKnownNat, withKnownSymbol, withKnownChar -- * Functions on type literals , type (N.<=), type (N.<=?), type (N.+), type (N.*), type (N.^), type (N.-) @@ -58,17 +67,19 @@ module GHC.TypeLits ) where -import GHC.Base(Eq(..), Ord(..), Ordering(..), String, otherwise, withDict) -import GHC.Types(Symbol, Char) +import GHC.Base ( Eq(..), Functor(..), Ord(..), Ordering(..), String + , (.), otherwise, withDict ) +import GHC.Types(Symbol, Char, TYPE) import GHC.TypeError(ErrorMessage(..), TypeError) import GHC.Num(Integer, fromInteger) -import GHC.Show(Show(..)) +import GHC.Show(Show(..), appPrec, appPrec1, showParen, showString) import GHC.Read(Read(..)) import GHC.Real(toInteger) import GHC.Prim(Proxy#) import Data.Maybe(Maybe(..)) import Data.Proxy (Proxy(..)) -import Data.Type.Equality((:~:)(Refl)) +import Data.Type.Coercion (Coercion(..), TestCoercion(..)) +import Data.Type.Equality((:~:)(Refl), TestEquality(..)) import Data.Type.Ord(OrderingI(..)) import Unsafe.Coerce(unsafeCoerce) @@ -91,7 +102,7 @@ natVal p = toInteger (N.natVal p) -- | @since 4.7.0.0 symbolVal :: forall n proxy. KnownSymbol n => proxy n -> String symbolVal _ = case symbolSing :: SSymbol n of - SSymbol x -> x + UnsafeSSymbol x -> x -- | @since 4.8.0.0 natVal' :: forall n. N.KnownNat n => Proxy# n -> Integer @@ -100,7 +111,7 @@ natVal' p = toInteger (N.natVal' p) -- | @since 4.8.0.0 symbolVal' :: forall n. KnownSymbol n => Proxy# n -> String symbolVal' _ = case symbolSing :: SSymbol n of - SSymbol x -> x + UnsafeSSymbol x -> x -- | This type represents unknown type-level symbols. @@ -113,11 +124,11 @@ class KnownChar (n :: Char) where charVal :: forall n proxy. KnownChar n => proxy n -> Char charVal _ = case charSing :: SChar n of - SChar x -> x + UnsafeSChar x -> x charVal' :: forall n. KnownChar n => Proxy# n -> Char charVal' _ = case charSing :: SChar n of - SChar x -> x + UnsafeSChar x -> x data SomeChar = forall n. KnownChar n => SomeChar (Proxy n) @@ -133,10 +144,8 @@ someNatVal n -- -- @since 4.7.0.0 someSymbolVal :: String -> SomeSymbol -someSymbolVal n = withSSymbol SomeSymbol (SSymbol n) Proxy -{-# NOINLINE someSymbolVal #-} --- For details see Note [NOINLINE someNatVal] in "GHC.TypeNats" --- The issue described there applies to `someSymbolVal` as well. +someSymbolVal s = withSomeSSymbol s (\(ss :: SSymbol s) -> + withKnownSymbol ss (SomeSymbol @s Proxy)) -- | @since 4.7.0.0 instance Eq SomeSymbol where @@ -159,8 +168,8 @@ instance Read SomeSymbol where -- -- @since 4.16.0.0 someCharVal :: Char -> SomeChar -someCharVal n = withSChar SomeChar (SChar n) Proxy -{-# NOINLINE someCharVal #-} +someCharVal c = withSomeSChar c (\(sc :: SChar c) -> + withKnownChar sc (SomeChar @c Proxy)) instance Eq SomeChar where SomeChar x == SomeChar y = charVal x == charVal y @@ -210,22 +219,20 @@ type family NatToChar (n :: N.Nat) :: Char -- same type-level symbols, or 'Nothing'. -- -- @since 4.7.0.0 -sameSymbol :: (KnownSymbol a, KnownSymbol b) => +sameSymbol :: forall a b proxy1 proxy2. + (KnownSymbol a, KnownSymbol b) => proxy1 a -> proxy2 b -> Maybe (a :~: b) -sameSymbol x y - | symbolVal x == symbolVal y = Just (unsafeCoerce Refl) - | otherwise = Nothing +sameSymbol _ _ = testEquality (symbolSing @a) (symbolSing @b) -- | We either get evidence that this function was instantiated with the -- same type-level characters, or 'Nothing'. -- -- @since 4.16.0.0 -sameChar :: (KnownChar a, KnownChar b) => - proxy1 a -> proxy2 b -> Maybe (a :~: b) -sameChar x y - | charVal x == charVal y = Just (unsafeCoerce Refl) - | otherwise = Nothing +sameChar :: forall a b proxy1 proxy2. + (KnownChar a, KnownChar b) => + proxy1 a -> proxy2 b -> Maybe (a :~: b) +sameChar _ _ = testEquality (charSing @a) (charSing @b) -- | Like 'sameSymbol', but if the symbols aren't equal, this additionally -- provides proof of LT or GT. @@ -257,20 +264,217 @@ cmpChar x y = case compare (charVal x) (charVal y) of -------------------------------------------------------------------------------- --- PRIVATE: +-- Singleton values + +-- | Return the 'Integer' corresponding to @n@ in an @'SNat' n@ value. +-- The returned 'Integer' is always non-negative. +-- +-- For a version of this function that returns a 'Natural' instead of an +-- 'Integer', see 'N.fromSNat' in "GHC.TypeNats". +-- +-- @since 4.18.0.0 +fromSNat :: N.SNat n -> Integer +fromSNat sn = toInteger (N.fromSNat sn) + +-- | Attempt to convert an 'Integer' into an @'SNat' n@ value, where @n@ is a +-- fresh type-level natural number. If the 'Integer' argument is non-negative, +-- invoke the continuation with @Just sn@, where @sn@ is the @'SNat' n@ value. +-- If the 'Integer' argument is negative, invoke the continuation with +-- 'Nothing'. +-- +-- For a version of this function where the continuation uses @'SNat@ n@ +-- instead of @'Maybe' ('SNat' n)@, see 'N.withSomeSNat' in "GHC.TypeNats". +-- +-- @since 4.18.0.0 +withSomeSNat :: forall rep (r :: TYPE rep). + Integer -> (forall n. Maybe (N.SNat n) -> r) -> r +withSomeSNat n k + | n >= 0 = N.withSomeSNat (fromInteger n) (\sn -> k (Just sn)) + | otherwise = k Nothing + +-- | A value-level witness for a type-level symbol. This is commonly referred +-- to as a /singleton/ type, as for each @s@, there is a single value that +-- inhabits the type @'SSymbol' s@ (aside from bottom). +-- +-- The definition of 'SSymbol' is intentionally left abstract. To obtain an +-- 'SSymbol' value, use one of the following: +-- +-- 1. The 'symbolSing' method of 'KnownSymbol'. +-- +-- 2. The @SSymbol@ pattern synonym. +-- +-- 3. The 'withSomeSSymbol' function, which creates an 'SSymbol' from a +-- 'String'. +-- +-- @since 4.18.0.0 +newtype SSymbol (s :: Symbol) = UnsafeSSymbol String -newtype SSymbol (s :: Symbol) = SSymbol String +-- | A explicitly bidirectional pattern synonym relating an 'SSymbol' to a +-- 'KnownSymbol' constraint. +-- +-- As an __expression__: Constructs an explicit @'SSymbol' s@ value from an +-- implicit @'KnownSymbol' s@ constraint: +-- +-- @ +-- SSymbol @s :: 'KnownSymbol' s => 'SSymbol' s +-- @ +-- +-- As a __pattern__: Matches on an explicit @'SSymbol' s@ value bringing +-- an implicit @'KnownSymbol' s@ constraint into scope: +-- +-- @ +-- f :: 'SSymbol' s -> .. +-- f SSymbol = {- SSymbol s in scope -} +-- @ +-- +-- @since 4.18.0.0 +pattern SSymbol :: forall s. () => KnownSymbol s => SSymbol s +pattern SSymbol <- (knownSymbolInstance -> KnownSymbolInstance) + where SSymbol = symbolSing + +-- An internal data type that is only used for defining the SSymbol pattern +-- synonym. +data KnownSymbolInstance (s :: Symbol) where + KnownSymbolInstance :: KnownSymbol s => KnownSymbolInstance s + +-- An internal function that is only used for defining the SSymbol pattern +-- synonym. +knownSymbolInstance :: SSymbol s -> KnownSymbolInstance s +knownSymbolInstance ss = withKnownSymbol ss KnownSymbolInstance + +-- | @since 4.18.0.0 +instance Show (SSymbol s) where + showsPrec p (UnsafeSSymbol s) + = showParen (p > appPrec) + ( showString "SSymbol @" + . showsPrec appPrec1 s + ) + +-- | @since 4.18.0.0 +instance TestEquality SSymbol where + testEquality (UnsafeSSymbol x) (UnsafeSSymbol y) + | x == y = Just (unsafeCoerce Refl) + | otherwise = Nothing + +-- | @since 4.18.0.0 +instance TestCoercion SSymbol where + testCoercion x y = fmap (\Refl -> Coercion) (testEquality x y) + +-- | Return the String corresponding to @s@ in an @'SSymbol' s@ value. +-- +-- @since 4.18.0.0 +fromSSymbol :: SSymbol s -> String +fromSSymbol (UnsafeSSymbol s) = s +-- | Convert an explicit @'SSymbol' s@ value into an implicit @'KnownSymbol' s@ +-- constraint. +-- +-- @since 4.18.0.0 +withKnownSymbol :: forall s rep (r :: TYPE rep). + SSymbol s -> (KnownSymbol s => r) -> r +withKnownSymbol = withDict @(KnownSymbol s) -- See Note [withDict] in "GHC.Tc.Instance.Class" in GHC -withSSymbol :: forall a b. - (KnownSymbol a => Proxy a -> b) - -> SSymbol a -> Proxy a -> b -withSSymbol f x y = withDict @(KnownSymbol a) x f y -newtype SChar (s :: Char) = SChar Char +-- | Convert a 'String' into an @'SSymbol' s@ value, where @s@ is a fresh +-- type-level symbol. +-- +-- @since 4.18.0.0 +withSomeSSymbol :: forall rep (r :: TYPE rep). + String -> (forall s. SSymbol s -> r) -> r +withSomeSSymbol s k = k (UnsafeSSymbol s) +{-# NOINLINE withSomeSSymbol #-} +-- For details see Note [NOINLINE withSomeSNat] in "GHC.TypeNats" +-- The issue described there applies to `withSomeSSymbol` as well. + +-- | A value-level witness for a type-level character. This is commonly referred +-- to as a /singleton/ type, as for each @c@, there is a single value that +-- inhabits the type @'SChar' c@ (aside from bottom). +-- +-- The definition of 'SChar' is intentionally left abstract. To obtain an +-- 'SChar' value, use one of the following: +-- +-- 1. The 'charSing' method of 'KnownChar'. +-- +-- 2. The @SChar@ pattern synonym. +-- +-- 3. The 'withSomeSChar' function, which creates an 'SChar' from a 'Char'. +-- +-- @since 4.18.0.0 +newtype SChar (s :: Char) = UnsafeSChar Char +-- | A explicitly bidirectional pattern synonym relating an 'SChar' to a +-- 'KnownChar' constraint. +-- +-- As an __expression__: Constructs an explicit @'SChar' c@ value from an +-- implicit @'KnownChar' c@ constraint: +-- +-- @ +-- SChar @c :: 'KnownChar' c => 'SChar' c +-- @ +-- +-- As a __pattern__: Matches on an explicit @'SChar' c@ value bringing +-- an implicit @'KnownChar' c@ constraint into scope: +-- +-- @ +-- f :: 'SChar' c -> .. +-- f SChar = {- SChar c in scope -} +-- @ +-- +-- @since 4.18.0.0 +pattern SChar :: forall c. () => KnownChar c => SChar c +pattern SChar <- (knownCharInstance -> KnownCharInstance) + where SChar = charSing + +-- An internal data type that is only used for defining the SChar pattern +-- synonym. +data KnownCharInstance (n :: Char) where + KnownCharInstance :: KnownChar c => KnownCharInstance c + +-- An internal function that is only used for defining the SChar pattern +-- synonym. +knownCharInstance :: SChar c -> KnownCharInstance c +knownCharInstance sc = withKnownChar sc KnownCharInstance + +-- | @since 4.18.0.0 +instance Show (SChar c) where + showsPrec p (UnsafeSChar c) + = showParen (p > appPrec) + ( showString "SChar @" + . showsPrec appPrec1 c + ) + +-- | @since 4.18.0.0 +instance TestEquality SChar where + testEquality (UnsafeSChar x) (UnsafeSChar y) + | x == y = Just (unsafeCoerce Refl) + | otherwise = Nothing + +-- | @since 4.18.0.0 +instance TestCoercion SChar where + testCoercion x y = fmap (\Refl -> Coercion) (testEquality x y) + +-- | Return the 'Char' corresponding to @c@ in an @'SChar' c@ value. +-- +-- @since 4.18.0.0 +fromSChar :: SChar c -> Char +fromSChar (UnsafeSChar c) = c + +-- | Convert an explicit @'SChar' c@ value into an implicit @'KnownChar' c@ +-- constraint. +-- +-- @since 4.18.0.0 +withKnownChar :: forall c rep (r :: TYPE rep). + SChar c -> (KnownChar c => r) -> r +withKnownChar = withDict @(KnownChar c) -- See Note [withDict] in "GHC.Tc.Instance.Class" in GHC -withSChar :: forall a b. - (KnownChar a => Proxy a -> b) - -> SChar a -> Proxy a -> b -withSChar f x y = withDict @(KnownChar a) x f y + +-- | Convert a 'Char' into an @'SChar' c@ value, where @c@ is a fresh type-level +-- character. +-- +-- @since 4.18.0.0 +withSomeSChar :: forall rep (r :: TYPE rep). + Char -> (forall c. SChar c -> r) -> r +withSomeSChar c k = k (UnsafeSChar c) +{-# NOINLINE withSomeSChar #-} +-- For details see Note [NOINLINE withSomeSNat] in "GHC.TypeNats" +-- The issue described there applies to `withSomeSChar` as well. ===================================== libraries/base/GHC/TypeNats.hs ===================================== @@ -13,6 +13,9 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE ViewPatterns #-} {-| This module is an internal GHC module. It declares the constants used in the implementation of type-level natural numbers. The programmer interface @@ -26,10 +29,16 @@ module GHC.TypeNats Natural -- declared in GHC.Num.Natural in package ghc-bignum , Nat -- * Linking type and value level - , KnownNat, natVal, natVal' + , KnownNat(natSing), natVal, natVal' , SomeNat(..) , someNatVal , sameNat + -- ** Singleton values + , SNat + , pattern SNat + , fromSNat + , withSomeSNat + , withKnownNat -- * Functions on type literals , type (<=), type (<=?), type (+), type (*), type (^), type (-) @@ -39,15 +48,16 @@ module GHC.TypeNats ) where -import GHC.Base(Eq(..), Ord(..), otherwise, WithDict(..)) +import GHC.Base(Eq(..), Functor(..), Ord(..), WithDict(..), (.), otherwise) import GHC.Types import GHC.Num.Natural(Natural) -import GHC.Show(Show(..)) +import GHC.Show(Show(..), appPrec, appPrec1, showParen, showString) import GHC.Read(Read(..)) import GHC.Prim(Proxy#) import Data.Maybe(Maybe(..)) import Data.Proxy (Proxy(..)) -import Data.Type.Equality((:~:)(Refl)) +import Data.Type.Coercion (Coercion(..), TestCoercion(..)) +import Data.Type.Equality((:~:)(Refl), TestEquality(..)) import Data.Type.Ord(OrderingI(..), type (<=), type (<=?)) import Unsafe.Coerce(unsafeCoerce) @@ -73,12 +83,12 @@ class KnownNat (n :: Nat) where -- | @since 4.10.0.0 natVal :: forall n proxy. KnownNat n => proxy n -> Natural natVal _ = case natSing :: SNat n of - SNat x -> x + UnsafeSNat x -> x -- | @since 4.10.0.0 natVal' :: forall n. KnownNat n => Proxy# n -> Natural natVal' _ = case natSing :: SNat n of - SNat x -> x + UnsafeSNat x -> x -- | This type represents unknown type-level natural numbers. -- @@ -89,64 +99,67 @@ data SomeNat = forall n. KnownNat n => SomeNat (Proxy n) -- -- @since 4.10.0.0 someNatVal :: Natural -> SomeNat -someNatVal n = withSNat SomeNat (SNat n) Proxy -{-# NOINLINE someNatVal #-} -- See Note [NOINLINE someNatVal] +someNatVal n = withSomeSNat n (\(sn :: SNat n) -> + withKnownNat sn (SomeNat @n Proxy)) {- -Note [NOINLINE someNatVal] -~~~~~~~~~~~~~~~~~~~~~~~~~~ -`someNatVal` converts a natural number to an existentially quantified -dictionary for `KnownNat` (aka `SomeNat`). The existential quantification +Note [NOINLINE withSomeSNat] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +`withSomeSNat` converts a `Natural` number to a singleton natural `SNat k`, +where the `k` is locally quantified in a continuation. The local quantification is very important, as it captures the fact that we don't know the type -statically, although we do know that it exists. Because this type is -fully opaque, we should never be able to prove that it matches anything else. -This is why coherence should still hold: we can manufacture a `KnownNat k` -dictionary, but it can never be confused with a `KnownNat 33` dictionary, -because we should never be able to prove that `k ~ 33`. - -But how to implement `someNatVal`? We can't quite implement it "honestly" -because `SomeNat` needs to "hide" the type of the newly created dictionary, -but we don't know what the actual type is! If `someNatVal` was built into -the language, then we could manufacture a new skolem constant, -which should behave correctly. - -Since extra language constructors have additional maintenance costs, -we use a trick to implement `someNatVal` in the library. The idea is that -instead of generating a "fresh" type for each use of `someNatVal`, we simply -use GHC's placeholder type `Any` (of kind `Nat`). So, the elaborated -version of the code is: - - someNatVal n = withSNat @T (SomeNat @T) (SNat @T n) (Proxy @T) +statically, although we do know that it exists. Because this type is fully +opaque, we should never be able to prove that it matches anything else. This +is why coherence should still hold: we can manufacture an `SNat k` value, but +it can never be confused with an `SNat 33` value, because we should never be +able to prove that `k ~ 33`. + +But how to implement `withSomeSNat`? We can't quite implement it "honestly" +because we need to "hide" the `k` type of the newly created `SNat k` value, but +we don't know what the actual type is! If `withSomeSNat` was built into the +language, then we could manufacture a new skolem constant, which should behave +correctly. (See #19675 for one idea of how this might be done.) + +Since extra language constructors have additional maintenance costs, we use a +trick to implement `withSomeSNat` in the library. The idea is that instead of +generating a "fresh" type for each use of `withSomeSNat`, we simply use GHC's +placeholder type `Any` (of kind `Nat`). So, the elaborated version of the code +is: + + withSomeSNat n f = f @T (UnsafeSNat @T n) + where type T = Any @Nat + +Surprisingly, however, things can go wrong if `withSomeSNat` is inlined. +Consider this definition, for example, which computes the value 3: + + ex :: Natural + ex = withSomeSNat 1 (\(s1 :: SNat one) -> withKnownNat one s1 (\(kn1 :: KnownNat one) -> + withSomeSNat 2 (\(s2 :: SNat two) -> withKnownNat two s2 (\(kn2 :: KnownNat two) -> + natVal one kn1 (Proxy one) + natVal two kn2 (Proxy two))))) + +Here, we are using Core to make the KnownNat dictionaries explicit. After +inlining both uses of `withSomeSNat`, this ends up looking something like: + + ex :: Natural + ex = withKnownNat T (UnsafeSNat T 1) (\(kn1 :: KnownNat T) -> + withKnownNat T (UnsafeSNat T 2) (\(kn2 :: KnownNat T) -> + natVal T kn1 (Proxy T) + natVal T kn2 (Proxy T))) where type T = Any Nat -After inlining and simplification, this ends up looking something like this: +We are now treading on thin ice. We have two dictionaries kn1 and kn2, both of +type `KnownNat T`, but with different implementations. This is not good, as GHC +assumes coherence, and it is free to interchange dictionaries of the same type. +Suppose GHC decided to swap out kn2 with kn1 in the expression +`natVal T kn2 (Proxy T)`, for instance. This would change ex from computing the +value 3 to computing the value 2! See #16586 for more examples of where this +has actually happened. - someNatVal n = SomeNat @T (KnownNat @T (SNat @T n)) (Proxy @T) - where type T = Any Nat - -`KnownNat` is the constructor for dictionaries for the class `KnownNat`. -See Note [withDict] in "GHC.Tc.Instance.Class" for details on how -we actually construct the dictionary. - -Note that using `Any Nat` is not really correct, as multiple calls to -`someNatVal` would violate coherence: - - type T = Any Nat - - x = SomeNat @T (KnownNat @T (SNat @T 1)) (Proxy @T) - y = SomeNat @T (KnownNat @T (SNat @T 2)) (Proxy @T) - -Note that now the code has two dictionaries with the same type, `KnownNat Any`, -but they have different implementations, namely `SNat 1` and `SNat 2`. This -is not good, as GHC assumes coherence, and it is free to interchange -dictionaries of the same type, but in this case this would produce an incorrect -result. See #16586 for examples of this happening. - -We can avoid this problem by making the definition of `someNatVal` opaque +We can avoid this problem by making the definition of `withSomeSNat` opaque and we do this by using a `NOINLINE` pragma. This restores coherence, because -GHC can only inspect the result of `someNatVal` by pattern matching on the -existential, which would generate a new type. This restores correctness, -at the cost of having a little more allocation for the `SomeNat` constructors. +the higher-rank quantification in `withSomeSNat`'s type forces the SNat in the +continuation's argument to have a type that is distinct from every other SNat. +This restores correctness, at the cost of introducing a little more indirection +when invoking `withSomeSNat`. -} @@ -218,11 +231,10 @@ type family Log2 (m :: Nat) :: Nat -- same type-level numbers, or 'Nothing'. -- -- @since 4.7.0.0 -sameNat :: (KnownNat a, KnownNat b) => +sameNat :: forall a b proxy1 proxy2. + (KnownNat a, KnownNat b) => proxy1 a -> proxy2 b -> Maybe (a :~: b) -sameNat x y - | natVal x == natVal y = Just (unsafeCoerce Refl) - | otherwise = Nothing +sameNat _ _ = testEquality (natSing @a) (natSing @b) -- | Like 'sameNat', but if the numbers aren't equal, this additionally -- provides proof of LT or GT. @@ -241,12 +253,96 @@ cmpNat x y = case compare (natVal x) (natVal y) of -------------------------------------------------------------------------------- --- PRIVATE: +-- Singleton values + +-- | A value-level witness for a type-level natural number. This is commonly +-- referred to as a /singleton/ type, as for each @n@, there is a single value +-- that inhabits the type @'SNat' n@ (aside from bottom). +-- +-- The definition of 'SNat' is intentionally left abstract. To obtain an 'SNat' +-- value, use one of the following: +-- +-- 1. The 'natSing' method of 'KnownNat'. +-- +-- 2. The @SNat@ pattern synonym. +-- +-- 3. The 'withSomeSNat' function, which creates an 'SNat' from a 'Natural' +-- number. +-- +-- @since 4.18.0.0 +newtype SNat (n :: Nat) = UnsafeSNat Natural -newtype SNat (n :: Nat) = SNat Natural +-- | A explicitly bidirectional pattern synonym relating an 'SNat' to a +-- 'KnownNat' constraint. +-- +-- As an __expression__: Constructs an explicit @'SNat' n@ value from an +-- implicit @'KnownNat' n@ constraint: +-- +-- @ +-- SNat @n :: 'KnownNat' n => 'SNat' n +-- @ +-- +-- As a __pattern__: Matches on an explicit @'SNat' n@ value bringing +-- an implicit @'KnownNat' n@ constraint into scope: +-- +-- @ +-- f :: 'SNat' n -> .. +-- f SNat = {- SNat n in scope -} +-- @ +-- +-- @since 4.18.0.0 +pattern SNat :: forall n. () => KnownNat n => SNat n +pattern SNat <- (knownNatInstance -> KnownNatInstance) + where SNat = natSing + +-- An internal data type that is only used for defining the SNat pattern +-- synonym. +data KnownNatInstance (n :: Nat) where + KnownNatInstance :: KnownNat n => KnownNatInstance n +-- An internal function that is only used for defining the SNat pattern +-- synonym. +knownNatInstance :: SNat n -> KnownNatInstance n +knownNatInstance sn = withKnownNat sn KnownNatInstance + +-- | @since 4.18.0.0 +instance Show (SNat n) where + showsPrec p (UnsafeSNat n) + = showParen (p > appPrec) + ( showString "SNat @" + . showsPrec appPrec1 n + ) + +-- | @since 4.18.0.0 +instance TestEquality SNat where + testEquality (UnsafeSNat x) (UnsafeSNat y) + | x == y = Just (unsafeCoerce Refl) + | otherwise = Nothing + +-- | @since 4.18.0.0 +instance TestCoercion SNat where + testCoercion x y = fmap (\Refl -> Coercion) (testEquality x y) + +-- | Return the 'Natural' number corresponding to @n@ in an @'SNat' n@ value. +-- +-- @since 4.18.0.0 +fromSNat :: SNat n -> Natural +fromSNat (UnsafeSNat n) = n + +-- | Convert an explicit @'SNat' n@ value into an implicit @'KnownNat' n@ +-- constraint. +-- +-- @since 4.18.0.0 +withKnownNat :: forall n rep (r :: TYPE rep). + SNat n -> (KnownNat n => r) -> r +withKnownNat = withDict @(KnownNat n) -- See Note [withDict] in "GHC.Tc.Instance.Class" in GHC -withSNat :: forall a b. - (KnownNat a => Proxy a -> b) - -> SNat a -> Proxy a -> b -withSNat f x y = withDict @(KnownNat a) x f y + +-- | Convert a 'Natural' number into an @'SNat' n@ value, where @n@ is a fresh +-- type-level natural number. +-- +-- @since 4.18.0.0 +withSomeSNat :: forall rep (r :: TYPE rep). + Natural -> (forall n. SNat n -> r) -> r +withSomeSNat n k = k (UnsafeSNat n) +{-# NOINLINE withSomeSNat #-} -- See Note [NOINLINE withSomeSNat] ===================================== libraries/base/changelog.md ===================================== @@ -37,6 +37,12 @@ related discussion, as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md). * Add `gcdetails_block_fragmentation_bytes` to `GHC.Stats.GCDetails` to track heap fragmentation. + * `GHC.TypeLits` and `GHC.TypeNats` now export the `natSing`, `symbolSing`, + and `charSing` methods of `KnownNat`, `KnownSymbol`, and `KnownChar`, + respectively. They also export the `SNat`, `SSymbol`, and `SChar` types + that are used in these methods and provide an API to interact with these + types, per + [CLC proposal #85](https://github.com/haskell/core-libraries-committee/issues/85). ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/T15183.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +module Main (main) where + +import Control.Exception (ArithException(..), throw) +import Data.Proxy (Proxy(..)) +import GHC.TypeLits ( KnownChar, KnownNat, KnownSymbol + , SChar, Nat, SNat, Symbol, SSymbol + , charVal, natVal, symbolVal + , withKnownChar, withKnownNat, withKnownSymbol + , withSomeSChar, withSomeSNat, withSomeSSymbol ) + +-- As found in the `reflection` library +reifyNat :: Integer -> (forall (n :: Nat). KnownNat n => Proxy n -> r) -> r +reifyNat n k = withSomeSNat n $ \(mbSn :: Maybe (SNat n)) -> + case mbSn of + Just sn -> withKnownNat sn $ k @n Proxy + Nothing -> throw Underflow + +reifySymbol :: String -> (forall (s :: Symbol). KnownSymbol s => Proxy s -> r) -> r +reifySymbol s k = withSomeSSymbol s $ \(ss :: SSymbol s) -> + withKnownSymbol ss $ k @s Proxy + +reifyChar :: Char -> (forall (c :: Char). KnownChar c => Proxy c -> r) -> r +reifyChar c k = withSomeSChar c $ \(sc :: SChar c) -> + withKnownChar sc (k @c Proxy) + +main :: IO () +main = do + reifyNat 42 $ \(_ :: Proxy n) -> print $ natVal $ Proxy @n + reifySymbol "hi" $ \(_ :: Proxy s) -> print $ symbolVal $ Proxy @s + reifyChar 'a' $ \(_ :: Proxy c) -> print $ charVal $ Proxy @c ===================================== libraries/base/tests/T15183.stdout ===================================== @@ -0,0 +1,3 @@ +42 +"hi" +'a' ===================================== libraries/base/tests/all.T ===================================== @@ -257,6 +257,7 @@ test('T13167', [when(opsys('mingw32'), only_ways(['winio', 'winio_threaded'])), fragile_for(16536, concurrent_ways)], compile_and_run, ['']) +test('T15183', normal, compile_and_run, ['']) test('T15349', [exit_code(1), expect_broken_for(15349, ['ghci'])], compile_and_run, ['']) test('T16111', exit_code(1), compile_and_run, ['']) test('T16943a', normal, compile_and_run, ['']) ===================================== testsuite/tests/dependent/should_compile/RaeJobTalk.hs ===================================== @@ -13,7 +13,7 @@ module RaeJobTalk where import Data.Type.Bool import Data.Type.Equality hiding ((:~~:)(..)) -import GHC.TypeLits +import GHC.TypeLits hiding (SSymbol) import Data.Proxy import GHC.Exts hiding (Lifted, BoxedRep) import Data.Kind ===================================== testsuite/tests/ghci/scripts/T19667Ghci.hs ===================================== @@ -18,7 +18,7 @@ class KnownSymbol (n :: Symbol) where symbolVal :: forall n proxy . KnownSymbol n => proxy n -> String symbolVal _ = case symbolSing :: SSymbol n of SSymbol x -> x --- See Note [NOINLINE someNatVal] in GHC.TypeNats +-- See Note [NOINLINE withSomeSNat] in GHC.TypeNats {-# NOINLINE reifySymbol #-} reifySymbol :: forall r. String -> (forall (n :: Symbol). KnownSymbol n => Proxy n -> r) -> r reifySymbol n k = withDict @(KnownSymbol Any) @(SSymbol Any) (SSymbol n) (k @Any) (Proxy @(Any @Symbol)) ===================================== testsuite/tests/ghci/scripts/T4175.stdout ===================================== @@ -30,10 +30,10 @@ instance Monoid () -- Defined in ‘GHC.Base’ instance Semigroup () -- Defined in ‘GHC.Base’ instance Bounded () -- Defined in ‘GHC.Enum’ instance Enum () -- Defined in ‘GHC.Enum’ -instance Eq () -- Defined in ‘GHC.Classes’ instance Ord () -- Defined in ‘GHC.Classes’ instance Read () -- Defined in ‘GHC.Read’ instance Show () -- Defined in ‘GHC.Show’ +instance Eq () -- Defined in ‘GHC.Classes’ data instance B () = MkB -- Defined at T4175.hs:14:15 type instance D Int () = String -- Defined at T4175.hs:20:10 type instance D () () = Bool -- Defined at T4175.hs:23:10 @@ -49,24 +49,24 @@ instance Monad Maybe -- Defined in ‘GHC.Base’ instance Semigroup a => Monoid (Maybe a) -- Defined in ‘GHC.Base’ instance Semigroup a => Semigroup (Maybe a) -- Defined in ‘GHC.Base’ -instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Maybe’ instance Ord a => Ord (Maybe a) -- Defined in ‘GHC.Maybe’ instance Read a => Read (Maybe a) -- Defined in ‘GHC.Read’ instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ +instance Eq a => Eq (Maybe a) -- Defined in ‘GHC.Maybe’ type instance A (Maybe a) a = a -- Defined at T4175.hs:10:15 type Int :: * data Int = GHC.Types.I# GHC.Prim.Int# -- Defined in ‘GHC.Types’ instance [safe] C Int -- Defined at T4175.hs:19:10 -instance Integral Int -- Defined in ‘GHC.Real’ -instance Num Int -- Defined in ‘GHC.Num’ -instance Real Int -- Defined in ‘GHC.Real’ instance Bounded Int -- Defined in ‘GHC.Enum’ instance Enum Int -- Defined in ‘GHC.Enum’ -instance Eq Int -- Defined in ‘GHC.Classes’ +instance Integral Int -- Defined in ‘GHC.Real’ +instance Num Int -- Defined in ‘GHC.Num’ instance Ord Int -- Defined in ‘GHC.Classes’ instance Read Int -- Defined in ‘GHC.Read’ +instance Real Int -- Defined in ‘GHC.Real’ instance Show Int -- Defined in ‘GHC.Show’ +instance Eq Int -- Defined in ‘GHC.Classes’ type instance A Int Int = () -- Defined at T4175.hs:9:15 type instance D Int () = String -- Defined at T4175.hs:20:10 type Z :: * -> Constraint ===================================== testsuite/tests/ghci/scripts/T9181.stdout ===================================== @@ -16,6 +16,16 @@ class GHC.TypeLits.KnownSymbol n where {-# MINIMAL symbolSing #-} type GHC.TypeLits.NatToChar :: GHC.Num.Natural.Natural -> Char type family GHC.TypeLits.NatToChar a +pattern GHC.TypeLits.SChar + :: () => GHC.TypeLits.KnownChar c => GHC.TypeLits.SChar c +type role GHC.TypeLits.SChar phantom +type GHC.TypeLits.SChar :: Char -> * +newtype GHC.TypeLits.SChar s = GHC.TypeLits.UnsafeSChar Char +pattern GHC.TypeLits.SSymbol + :: () => GHC.TypeLits.KnownSymbol s => GHC.TypeLits.SSymbol s +type role GHC.TypeLits.SSymbol phantom +type GHC.TypeLits.SSymbol :: GHC.Types.Symbol -> * +newtype GHC.TypeLits.SSymbol s = GHC.TypeLits.UnsafeSSymbol String type GHC.TypeLits.SomeChar :: * data GHC.TypeLits.SomeChar = forall (n :: Char). @@ -38,6 +48,9 @@ GHC.TypeLits.cmpChar :: GHC.TypeLits.cmpSymbol :: (GHC.TypeLits.KnownSymbol a, GHC.TypeLits.KnownSymbol b) => proxy1 a -> proxy2 b -> Data.Type.Ord.OrderingI a b +GHC.TypeLits.fromSChar :: GHC.TypeLits.SChar c -> Char +GHC.TypeLits.fromSNat :: GHC.TypeNats.SNat n -> Integer +GHC.TypeLits.fromSSymbol :: GHC.TypeLits.SSymbol s -> String GHC.TypeLits.natVal :: GHC.TypeNats.KnownNat n => proxy n -> Integer GHC.TypeLits.natVal' :: @@ -55,6 +68,21 @@ GHC.TypeLits.symbolVal :: GHC.TypeLits.KnownSymbol n => proxy n -> String GHC.TypeLits.symbolVal' :: GHC.TypeLits.KnownSymbol n => GHC.Prim.Proxy# n -> String +GHC.TypeLits.withKnownChar :: + GHC.TypeLits.SChar c -> (GHC.TypeLits.KnownChar c => r) -> r +GHC.TypeLits.withKnownSymbol :: + GHC.TypeLits.SSymbol s -> (GHC.TypeLits.KnownSymbol s => r) -> r +GHC.TypeLits.withSomeSChar :: + Char -> (forall (c :: Char). GHC.TypeLits.SChar c -> r) -> r +GHC.TypeLits.withSomeSNat :: + Integer + -> (forall (n :: GHC.TypeNats.Nat). + Maybe (GHC.TypeNats.SNat n) -> r) + -> r +GHC.TypeLits.withSomeSSymbol :: + String + -> (forall (s :: GHC.Types.Symbol). GHC.TypeLits.SSymbol s -> r) + -> r type (GHC.TypeNats.*) :: GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family (GHC.TypeNats.*) a b @@ -123,6 +151,12 @@ data Data.Type.Ord.OrderingI a b where Data.Type.Ord.GTI :: forall {k} (a :: k) (b :: k). (Data.Type.Ord.Compare a b ~ 'GT) => Data.Type.Ord.OrderingI a b +pattern GHC.TypeNats.SNat + :: () => GHC.TypeNats.KnownNat n => GHC.TypeNats.SNat n +type role GHC.TypeNats.SNat phantom +type GHC.TypeNats.SNat :: GHC.TypeNats.Nat -> * +newtype GHC.TypeNats.SNat n + = GHC.TypeNats.UnsafeSNat GHC.Num.Natural.Natural type GHC.TypeNats.SomeNat :: * data GHC.TypeNats.SomeNat = forall (n :: GHC.TypeNats.Nat). @@ -142,3 +176,5 @@ GHC.TypeNats.cmpNat :: GHC.TypeNats.sameNat :: (GHC.TypeNats.KnownNat a, GHC.TypeNats.KnownNat b) => proxy1 a -> proxy2 b -> Maybe (a Data.Type.Equality.:~: b) +GHC.TypeNats.withKnownNat :: + GHC.TypeNats.SNat n -> (GHC.TypeNats.KnownNat n => r) -> r ===================================== testsuite/tests/ghci/scripts/ghci064.stdout ===================================== @@ -36,14 +36,14 @@ instance Foreign.Storable.Storable Bool -- Defined in ‘Foreign.Storable’ instance GHC.Generics.Generic Bool -- Defined in ‘GHC.Generics’ instance GHC.Bits.Bits Bool -- Defined in ‘GHC.Bits’ -instance GHC.Bits.FiniteBits Bool -- Defined in ‘GHC.Bits’ -instance GHC.Ix.Ix Bool -- Defined in ‘GHC.Ix’ instance Bounded Bool -- Defined in ‘GHC.Enum’ instance Enum Bool -- Defined in ‘GHC.Enum’ -instance Eq Bool -- Defined in ‘GHC.Classes’ +instance GHC.Bits.FiniteBits Bool -- Defined in ‘GHC.Bits’ +instance GHC.Ix.Ix Bool -- Defined in ‘GHC.Ix’ instance Ord Bool -- Defined in ‘GHC.Classes’ instance Read Bool -- Defined in ‘GHC.Read’ instance Show Bool -- Defined in ‘GHC.Show’ +instance Eq Bool -- Defined in ‘GHC.Classes’ instance Traversable ((,) Int) -- Defined in ‘Data.Traversable’ instance Foldable ((,) Int) -- Defined in ‘Data.Foldable’ instance Functor ((,) Int) -- Defined in ‘GHC.Base’ ===================================== testsuite/tests/typecheck/should_run/T16646.hs ===================================== @@ -21,7 +21,7 @@ instance KnownNat n => Reifies n Integer where reflect = natVal reify :: forall a r. a -> (forall (s :: Type). Reifies s a => Proxy s -> r) -> r -{-# NOINLINE reify #-} -- See Note [NOINLINE someNatVal] in GHC.TypeNats +{-# NOINLINE reify #-} -- See Note [NOINLINE withSomeSNat] in GHC.TypeNats reify a k = withDict @(Reifies (Any @Type) a) @(forall (proxy :: Type -> Type). proxy Any -> a) (const a) (k @Any) Proxy ===================================== testsuite/tests/typecheck/should_run/T19667.hs ===================================== @@ -18,7 +18,7 @@ class KnownSymbol (n :: Symbol) where symbolVal :: forall n proxy . KnownSymbol n => proxy n -> String symbolVal _ = case symbolSing :: SSymbol n of SSymbol x -> x --- See Note [NOINLINE someNatVal] in GHC.TypeNats +-- See Note [NOINLINE withSomeSNat] in GHC.TypeNats {-# NOINLINE reifySymbol #-} reifySymbol :: forall r. String -> (forall (n :: Symbol). KnownSymbol n => Proxy n -> r) -> r reifySymbol n k = withDict @(KnownSymbol Any) @(SSymbol Any) (SSymbol n) (k @Any) (Proxy @(Any @Symbol)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ecb4ecebb3b439850c2719f0341109e2d1ffebf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ecb4ecebb3b439850c2719f0341109e2d1ffebf You're receiving 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 Sep 26 23:22:59 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 26 Sep 2022 19:22:59 -0400 Subject: [Git][ghc/ghc][wip/andreask/opt-core-lint] Apply some tricks to speed up core lint. Message-ID: <63323453ea743_2c9757dfd401991c2@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/opt-core-lint at Glasgow Haskell Compiler / GHC Commits: 829609bd by Andreas Klebinger at 2022-09-27T01:12:15+02: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 ------------------------- - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,8 @@ -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +97,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +267,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1865,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1914,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1933,62 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +-- +-- Being strict in the kind here avoids quite a few pointless thunks +-- reducing allocations by ~5% +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + -- Forcing the in scope set eagerly here reduces allocations by up to 4%. + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + -- We use explicit recursion instead of a fold here to avoid go_app becoming + -- an allocated function closure. This reduced allocations by up to 7% for some + -- modules. + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2730,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> LResult a) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- Using a unboxed tuple here reduced allocations for a lint heavy +-- file by ~6%. Using MaybeUB reduced them further by another ~12%. +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2889,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2942,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2973,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2989,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3029,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3045,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3065,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -2521,12 +2522,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,10 +295,10 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S --- import GHC.Utils.Trace -- $type_classification -- #type_classification# @@ -556,7 +557,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2788,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [Type comparisons using object pointer comparisons] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by a single object +in the heap. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2811,15 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + -- See Note [Type comparisons using object pointer comparisons] + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,50 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.CmdLine ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.Backpack.Syntax View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/829609bde5eb0725c5bb80fbf6543811d5531123 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/829609bde5eb0725c5bb80fbf6543811d5531123 You're receiving 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 Sep 27 07:33:08 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 03:33:08 -0400 Subject: [Git][ghc/ghc][wip/T21286] 15 commits: Add `Eq` and `Ord` instances for `Generically1` Message-ID: <6332a7349420d_2c97575146424815a@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 2a74ad4b by Simon Peyton Jones at 2022-09-27T08:35:10+01: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 modules * 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: Metrics: compile_time/bytes allocated -------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 -50.1% GOOD ManyConstructors(normal) ghc/alloc 3,928,349,810 +1.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,523,518,560 +1.2% T12545(normal) ghc/alloc 1,633,149,272 +3.1% T13056(optasm) ghc/alloc 349,532,453 -8.7% GOOD T13253(normal) ghc/alloc 343,592,469 -3.3% GOOD T15164(normal) ghc/alloc 1,304,125,024 -3.4% GOOD T16190(normal) ghc/alloc 278,584,392 -1.5% T16577(normal) ghc/alloc 8,050,423,421 -2.8% GOOD T17836(normal) ghc/alloc 829,913,981 +2.3% T18223(normal) ghc/alloc 734,732,288 -33.3% GOOD T18282(normal) ghc/alloc 150,159,957 -2.9% GOOD T18478(normal) ghc/alloc 498,300,837 +1.2% T19695(normal) ghc/alloc 1,444,571,802 -2.5% GOOD T9630(normal) ghc/alloc 1,523,682,706 -32.8% GOOD WWRec(normal) ghc/alloc 624,174,317 -9.6% GOOD hie002(normal) ghc/alloc 9,020,356,301 +1.8% ------------------------------------------------------------------------- geo. mean -1.7% minimum -50.1% maximum +3.1% I diligently investigated all these big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlesslly specialising wrappers LargeRecord, T9630 I also got one runtime improvement: T9203(normal) run/alloc 105,672,160 -10.7% GOOD but I did not investigate. Nofib is a wash: +===============================++===============+===========+ | real/anna || -0.13% | 0.0% | | real/fem || +0.13% | 0.0% | | real/fulsom || -0.16% | 0.0% | | real/gamteb || +0.02% | 0.0% | | real/gg || +0.01% | 0.0% | | real/lift || -1.55% | 0.0% | | real/reptile || -0.11% | 0.0% | | real/scs || -0.08% | 0.0% | | real/smallpt || +0.51% | 0.0% | | real/symalg || -0.01% | 0.0% | | real/veritas || +0.05% | 0.0% | | shootout/binary-trees || +0.00% | 0.0% | | shootout/fannkuch-redux || -0.05% | 0.0% | | shootout/k-nucleotide || -0.01% | 0.0% | | shootout/n-body || -0.06% | 0.0% | | shootout/spectral-norm || +0.01% | 0.0% | | spectral/constraints || +0.20% | 0.0% | | spectral/dom-lt || +1.80% | 0.0% | | spectral/expert || +0.33% | 0.0% | Metric Decrease: LargeRecord T13056 T15164 T16577 T18223 T9630 WWRec T9203 - - - - - 0ba307a4 by Simon Peyton Jones at 2022-09-27T08:35:10+01: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. - - - - - 2a660d02 by Simon Peyton Jones at 2022-09-27T08:35:10+01: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. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.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/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3dfc17739c62a4f553e7a5912e67ee330d386a6a...2a660d024b1efea4b6fc3460b424bfe993e06e45 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3dfc17739c62a4f553e7a5912e67ee330d386a6a...2a660d024b1efea4b6fc3460b424bfe993e06e45 You're receiving 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 Sep 27 08:10:06 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 27 Sep 2022 04:10:06 -0400 Subject: [Git][ghc/ghc][wip/T21717] Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <6332afde2c386_2c9757514782642f3@gitlab.mail> Sebastian Graf pushed to branch wip/T21717 at Glasgow Haskell Compiler / GHC Commits: b4ba099e by Sebastian Graf at 2022-09-27T10:09:39+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. - - - - - 22 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/simplCore/should_compile/T21261.hs - testsuite/tests/simplCore/should_compile/T21261.stderr - − testsuite/tests/simplCore/should_compile/T21261_pedantic.hs - − testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/stranal/should_compile/T18894.stderr - + testsuite/tests/stranal/should_run/T21717b.hs - + testsuite/tests/stranal/should_run/T21717b.stdout - testsuite/tests/stranal/should_run/all.T - testsuite/tests/stranal/sigs/T20746.stderr - testsuite/tests/stranal/sigs/T21081.stderr - testsuite/tests/stranal/sigs/T21119.stderr - + testsuite/tests/stranal/sigs/T21717.hs - + testsuite/tests/stranal/sigs/T21717.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -509,9 +509,6 @@ this transformation. So we try to limit it as much as possible: Of course both (1) and (2) are readily defeated by disguising the bottoms. -Another place where -fpedantic-bottoms comes up is during eta-reduction. -See Note [Eta reduction soundness], the bit about -fpedantic-bottoms. - 4. Note [Newtype arity] ~~~~~~~~~~~~~~~~~~~~~~~~ Non-recursive newtypes are transparent, and should not get in the way. @@ -2382,20 +2379,13 @@ case where `e` is trivial): `e = \x y. bot`. Could we relax to "*At least one call in the same trace* is with n args"? - (NB: Strictness analysis can only answer this relaxed question, not the - original formulation.) - Consider what happens for + No. Consider what happens for ``g2 c = c True `seq` c False 42`` Here, `g2` will call `c` with 2 arguments (if there is a call at all). But it is unsound to eta-reduce the arg in `g2 (\x y. e x y)` to `g2 e` when `e = \x. if x then bot else id`, because the latter will diverge when - the former would not. - - On the other hand, with `-fno-pedantic-bottoms` , we will have eta-expanded - the definition of `e` and then eta-reduction is sound - (see Note [Dealing with bottom]). - Consequence: We have to check that `-fpedantic-bottoms` is off; otherwise - eta-reduction based on demands is in fact unsound. + the former would not. Fortunately, the strictness analyser will report + "Not always called with two arguments" for `g2` and we won't eta-expand. See Note [Eta reduction based on evaluation context] for the implementation details. This criterion is tested extensively in T21261. @@ -2541,7 +2531,7 @@ Then this is how the pieces are put together: Because it's irrelevant! When we simplify an expression, we do so under the assumption that it is currently under evaluation.) This sub-demand literally says "Whenever this expression is evaluated, it - is also called with two arguments, potentially multiple times". + is called with at least two arguments, potentially multiple times". * Then the simplifier takes apart the lambda and simplifies the lambda group and then calls 'tryEtaReduce' when rebuilding the lambda, passing the ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1643,11 +1643,7 @@ rebuildLam env bndrs body cont mb_rhs = contIsRhs cont -- See Note [Eta reduction based on evaluation context] - eval_sd - | sePedanticBottoms env = topSubDmd - -- See Note [Eta reduction soundness], criterion (S) - -- the bit about -fpedantic-bottoms - | otherwise = contEvalContext cont + eval_sd = contEvalContext cont -- NB: cont is never ApplyToVal, because beta-reduction would -- have happened. So contEvalContext can panic on ApplyToVal. ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -598,26 +598,6 @@ multCard (Card a) (Card b) bit1 = (a .&. b) .&. 0b010 bitN = (a .|. b) .&. shiftL bit1 1 .&. 0b100 --- | Denotes '∪' on lower and '+' on upper bounds of 'Card'. -lubPlusCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -lubPlusCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .|. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = ((a .|. b) .|. shiftL (a .&. b) 1) .&. 0b100 - --- | Denotes '+' on lower and '∪' on upper bounds of 'Card'. -plusLubCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -plusLubCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .&. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = (a .|. b) .&. 0b100 - {- ************************************************************************ * * @@ -626,11 +606,11 @@ plusLubCard (Card a) (Card b) ************************************************************************ -} --- | A demand describes a /scaled evaluation context/, e.g. how many times --- and how deep the denoted thing is evaluated. +-- | A demand describes +-- +-- * How many times a variable is evaluated, via a 'Card'inality, and +-- * How deep its value was evaluated in turn, via a 'SubDemand'. -- --- The "how many" component is represented by a 'Card'inality. --- The "how deep" component is represented by a 'SubDemand'. -- Examples (using Note [Demand notation]): -- -- * 'seq' puts demand @1A@ on its first argument: It evaluates the argument @@ -674,8 +654,8 @@ viewDmdPair BotDmd = (C_10, botSubDmd) viewDmdPair AbsDmd = (C_00, botSubDmd) viewDmdPair (D n sd) = (n, sd) --- | @c :* sd@ is a demand that says \"evaluated @c@ times, and each time it --- was evaluated, it was at least as deep as @sd@\". +-- | @c :* sd@ is a demand that says \"evaluated @c@ times, and any trace in +-- which it is evaluated will evaluate at least as deep as @sd@\". -- -- Matching on this pattern synonym is a complete match. -- If the matched demand was 'AbsDmd', it will match as @C_00 :* seqSubDmd at . @@ -695,8 +675,9 @@ pattern n :* sd <- (viewDmdPair -> (n, sd)) where n :* sd = D n sd & assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) {-# COMPLETE (:*) #-} --- | A sub-demand describes an /evaluation context/, e.g. how deep the --- denoted thing is evaluated. See 'Demand' for examples. +-- | A sub-demand describes an /evaluation context/ (in the sense of an +-- operational semantics), e.g. how deep the denoted thing is going to be +-- evaluated. See 'Demand' for examples. -- -- See Note [SubDemand denotes at least one evaluation] for a more detailed -- description of what a sub-demand means. @@ -714,14 +695,17 @@ data SubDemand -- @Poly b n@ is semantically equivalent to @Prod b [n :* Poly b n, ...] -- or @Call n (Poly Boxed n)@. 'viewCall' and 'viewProd' do these rewrites. -- - -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === CL(L)@, - -- @B === P(B,B,...)@ and @B === CB(B)@, - -- @!A === !P(A,A,...)@ and @!A === !CA(B)@, + -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === C(L)@, + -- @B === P(B,B,...)@ and @B === C(B)@, + -- @!A === !P(A,A,...)@ and @!A === C(A)@, -- and so on. -- -- We'll only see 'Poly' with 'C_10' (B), 'C_00' (A), 'C_0N' (L) and sometimes -- 'C_1N' (S) through 'plusSubDmd', never 'C_01' (M) or 'C_11' (1) (grep the -- source code). Hence 'CardNonOnce', which is closed under 'lub' and 'plus'. + -- + -- Why doesn't this constructor simply carry a 'Demand' instead of its fields? + -- See Note [Call SubDemand vs. evaluation Demand]. | Call !CardNonAbs !SubDemand -- ^ @Call n sd@ describes the evaluation context of @n@ function -- applications (with one argument), where the result of each call is @@ -803,7 +787,7 @@ viewProd _ _ -- equality @Call C_0N (Poly C_0N) === Poly C_0N@, simplifying to 'Poly' 'SubDemand's -- when possible. mkCall :: CardNonAbs -> SubDemand -> SubDemand -mkCall C_1N sd@(Poly Boxed C_1N) = sd +--mkCall C_1N sd@(Poly Boxed C_1N) = sd -- NO! #21085 strikes. See Note [mkCall and plusSubDmd] mkCall C_0N sd@(Poly Boxed C_0N) = sd mkCall n sd = assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) $ Call n sd @@ -838,17 +822,6 @@ unboxDeeplyDmd BotDmd = BotDmd unboxDeeplyDmd dmd@(D n sd) | isStrict n = D n (unboxDeeplySubDmd sd) | otherwise = dmd -multSubDmd :: Card -> SubDemand -> SubDemand -multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod --- The following three equations don't have an impact on Demands, only on --- Boxity. They are needed so that we don't trigger the assertions in `:*` --- when called from `multDmd`. -multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` -multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` -multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality -multSubDmd n (Poly b m) = Poly b (multCard n m) -multSubDmd n (Call n' sd) = mkCall (multCard n n') sd -multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) multDmd :: Card -> Demand -> Demand multDmd C_11 dmd = dmd -- An optimisation @@ -866,170 +839,85 @@ multDmd n BotDmd = if isStrict n then BotDmd else AbsDmd -- See Note [SubDemand denotes at least one evaluation] for the strictifyCard multDmd n (D m sd) = multCard n m :* multSubDmd (strictifyCard n) sd -{- Note [Manual specialisation of lub*Dmd/plus*Dmd] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As Note [SubDemand denotes at least one evaluation] points out, we need all 4 -different combinations of lub/plus demand operations on upper and lower bounds - lubDmd, plusDmd, lubPlusDmd, plusLubDmd -and the same for lubSubDmd, etc. In order to share as much code as possible -and for the programmer to see immediately how the operations differ, we have -one implementation of opDmd (and opSubDmd) that dispatches on a 'OpMode'. - -For good perf, we specialise this one implementation to the four different -modes. So ideally we'd write -``` -lubSubDmd = opSubDmd (Lub, Lub) -opSubDmd (l, u) = ... opSubDmd ... -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -But unfortunately, 'opSubDmd' will be picked as a loop-breaker and thus never -inline into 'lubSubDmd', so its body will never actually be specialised for -the op mode `(Lub, Lub)`. So instead we write -``` -lubSubDmd = opSubDmdInl (Lub, Lub) -opSubDmdInl (l, u) = ... opSubDmd ... -{-# INLINE opSubDmdInl #-} -opSubDmd = opSubDmdInl -{-# RULES "lubSubDmd" forall l r. opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -Here, 'opSubDmdInl' will not be picked as the loop-breaker and thus inline into -'lubSubDmd' and 'opSubDmd'. Since the latter will never inline, we'll specialise -all call sites of 'opSubDmd' for the proper op mode. A nice trick! --} - -data LubOrPlus = Lub | Plus deriving Show -instance Outputable LubOrPlus where ppr = text . show - --- | Determines whether to use 'LubOrPlus' for lower bounds and upper bounds, --- respectively. See Note [Manual specialisation of lub*Dmd/plus*Dmd]. -type OpMode = (LubOrPlus, LubOrPlus) +multSubDmd :: Card -> SubDemand -> SubDemand +multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod +-- The following three equations don't have an impact on Demands, only on +-- Boxity. They are needed so that we don't trigger the assertions in `:*` +-- when called from `multDmd`. +multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` +multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` +multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality +multSubDmd n (Poly b m) = Poly b (multCard n m) +multSubDmd n (Call n' sd) = mkCall (multCard n n') sd +multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) --- | Denotes '∪' on 'SubDemand'. -lubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubSubDmd l r = opSubDmdInl (Lub, Lub) l r +lazifyIfStrict :: Card -> SubDemand -> SubDemand +lazifyIfStrict n sd = multSubDmd (glbCard C_01 n) sd -- | Denotes '∪' on 'Demand'. lubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubDmd l r = opDmdInl (Lub, Lub) l r +lubDmd BotDmd dmd2 = dmd2 +lubDmd dmd1 BotDmd = dmd1 +lubDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "lubDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + lubCard n1 n2 :* lubSubDmd sd1 sd2 --- | Denotes '+' on 'SubDemand'. -plusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusSubDmd l r = opSubDmdInl (Plus, Plus) l r +lubSubDmd :: SubDemand -> SubDemand -> SubDemand +-- Shortcuts for neutral and absorbing elements. +-- Below we assume that Boxed always wins. +lubSubDmd (Poly Unboxed C_10) sd = sd +lubSubDmd sd (Poly Unboxed C_10) = sd +lubSubDmd sd@(Poly Boxed C_0N) _ = sd +lubSubDmd _ sd@(Poly Boxed C_0N) = sd +-- Handle Prod +lubSubDmd (Prod b1 ds1) (Poly b2 n2) + | let !d = polyFieldDmd b2 n2 + = mkProd (lubBoxity b1 b2) (strictMap (lubDmd d) ds1) +lubSubDmd (Prod b1 ds1) (Prod b2 ds2) + | equalLength ds1 ds2 + = mkProd (lubBoxity b1 b2) (strictZipWith lubDmd ds1 ds2) +-- Handle Call +lubSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (lubCard n1 n2) (lubSubDmd sd1 sd2) +-- Handle Poly +lubSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (lubCard n1 n2) +-- Other Poly case by commutativity +lubSubDmd sd1 at Poly{} sd2 = lubSubDmd sd2 sd1 +-- Otherwise (Call `lub` Prod) return Top +lubSubDmd _ _ = topSubDmd -- | Denotes '+' on 'Demand'. plusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusDmd l r = opDmdInl (Plus, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -lubPlusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusSubDmd l r = opSubDmdInl (Lub, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'Demand'. -lubPlusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusDmd l r = opDmdInl (Lub, Plus) l r - --- | Denotes '+' on lower bounds and '∪' on upper bounds on 'SubDemand'. -plusLubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubSubDmd l r = opSubDmdInl (Plus, Lub) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -plusLubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubDmd l r = opDmdInl (Plus, Lub) l r - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -{-# RULES "lubDmd" opDmd (Lub, Lub) = lubDmd #-} -{-# RULES "plusSubDmd" opSubDmd (Plus, Plus) = plusSubDmd #-} -{-# RULES "plusDmd" opDmd (Plus, Plus) = plusDmd #-} -{-# RULES "lubPlusSubDmd" opSubDmd (Lub, Plus) = lubPlusSubDmd #-} -{-# RULES "lubPlusDmd" opDmd (Lub, Plus) = lubPlusDmd #-} -{-# RULES "plusLubSubDmd" opSubDmd (Plus, Lub) = plusLubSubDmd #-} -{-# RULES "plusLubDmd" opDmd (Plus, Lub) = plusLubDmd #-} - --- --- And now the actual implementation that is to be specialised: --- +plusDmd AbsDmd dmd2 = dmd2 +plusDmd dmd1 AbsDmd = dmd1 +plusDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "plusDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + -- Why lazify? See Note [SubDemand denotes at least one evaluation] + -- and also Note [Unrealised opportunity in plusDmd] which applies when both + -- n1 and n2 are lazy already + plusCard n1 n2 :* plusSubDmd (lazifyIfStrict n1 sd1) (lazifyIfStrict n2 sd2) -neutralCard :: OpMode -> Card -neutralCard (Lub, _) = C_10 -neutralCard (Plus, _) = C_00 -{-# INLINE neutralCard #-} - -absorbingCard :: OpMode -> Card -absorbingCard (Lub, _) = C_0N -absorbingCard (Plus, _) = C_1N -{-# INLINE absorbingCard #-} - -opCard :: OpMode -> Card -> Card -> Card -opCard (Lub, Lub) = lubCard -opCard (Lub, Plus) = lubPlusCard -opCard (Plus, Lub) = plusLubCard -opCard (Plus, Plus) = plusCard -{-# INLINE opCard #-} - -opDmdInl, opDmd :: OpMode -> Demand -> Demand -> Demand -opDmdInl m (n1 :* _) dmd2 | n1 == neutralCard m = dmd2 -opDmdInl m dmd1 (n2 :* _) | n2 == neutralCard m = dmd1 -opDmdInl m@(l,u) (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "opDmd" (\it -> ppr l <+> ppr u $$ ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ - opCard m n1 n2 :* case l of - Lub -> opSubDmd m sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, u) sd1 sd2 -- (D1) - (True, False) -> opSubDmd (Plus, u) sd1 (lazifySubDmd sd2) -- (D2) - (False, True) -> opSubDmd (Plus, u) (lazifySubDmd sd1) sd2 -- (D2) - (False, False) -> opSubDmd (Lub, u) sd1 sd2 -- (D3) - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opDmd = opDmdInl -{-# INLINE opDmdInl #-} -{-# NOINLINE opDmd #-} - -opSubDmdInl, opSubDmd :: OpMode -> SubDemand -> SubDemand -> SubDemand +plusSubDmd :: SubDemand -> SubDemand -> SubDemand -- Shortcuts for neutral and absorbing elements. -- Below we assume that Boxed always wins. -opSubDmdInl m (Poly Unboxed n) sd | n == neutralCard m = sd -opSubDmdInl m sd (Poly Unboxed n) | n == neutralCard m = sd -opSubDmdInl m sd@(Poly Boxed n) _ | n == absorbingCard m = sd -opSubDmdInl m _ sd@(Poly Boxed n) | n == absorbingCard m = sd +plusSubDmd (Poly Unboxed C_00) sd = sd +plusSubDmd sd (Poly Unboxed C_00) = sd +plusSubDmd sd@(Poly Boxed C_1N) _ = sd +plusSubDmd _ sd@(Poly Boxed C_1N) = sd -- Handle Prod -opSubDmdInl m (Prod b1 ds1) (Poly b2 n2) +plusSubDmd (Prod b1 ds1) (Poly b2 n2) | let !d = polyFieldDmd b2 n2 - = mkProd (lubBoxity b1 b2) (strictMap (opDmd m d) ds1) -opSubDmdInl m (Prod b1 ds1) (Prod b2 ds2) + = mkProd (lubBoxity b1 b2) (strictMap (plusDmd d) ds1) +plusSubDmd (Prod b1 ds1) (Prod b2 ds2) | equalLength ds1 ds2 - = mkProd (lubBoxity b1 b2) (strictZipWith (opDmd m) ds1 ds2) + = mkProd (lubBoxity b1 b2) (strictZipWith plusDmd ds1 ds2) -- Handle Call -opSubDmdInl m@(l, _) (Call n1 sd1) (viewCall -> Just (n2, sd2)) = - mkCall (opCard m n1 n2) $! case l of - Lub -> opSubDmd (Lub, Lub) sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]. Usage is always lubbed: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, Lub) sd1 sd2 -- (C3) - (False, True) -> opSubDmd (Plus, Lub) (lazifySubDmd sd1) sd2 -- (C2) - (True, False) -> opSubDmd (Plus, Lub) sd1 (lazifySubDmd sd2) -- (C2) - (False, False) -> opSubDmd (Lub, Lub) sd1 sd2 -- (C1) +plusSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (plusCard n1 n2) (lubSubDmd sd1 sd2) -- Handle Poly -opSubDmdInl m (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (opCard m n1 n2) +plusSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (plusCard n1 n2) -- Other Poly case by commutativity -opSubDmdInl m sd1 at Poly{} sd2 = opSubDmd m sd2 sd1 --- Otherwise (Call `op` Prod) return Top -opSubDmdInl _ _ _ = topSubDmd - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opSubDmd = opSubDmdInl -{-# INLINE opSubDmdInl #-} -{-# NOINLINE opSubDmd #-} +plusSubDmd sd1 at Poly{} sd2 = plusSubDmd sd2 sd1 +-- Otherwise (Call `plus` Prod) return Top +plusSubDmd _ _ = topSubDmd -- | Used to suppress pretty-printing of an uninformative demand isTopDmd :: Demand -> Bool @@ -1129,11 +1017,6 @@ strictifyDictDmd _ dmd = dmd lazifyDmd :: Demand -> Demand lazifyDmd = multDmd C_01 - --- | Make a 'SubDemand' lazy. -lazifySubDmd :: SubDemand -> SubDemand -lazifySubDmd = multSubDmd C_01 - -- | Wraps the 'SubDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCalledOnceDmd :: SubDemand -> SubDemand mkCalledOnceDmd sd = mkCall C_11 sd @@ -1166,7 +1049,7 @@ subDemandIfEvaluated (_ :* sd) = sd mkWorkerDemand :: Int -> Demand mkWorkerDemand n = C_01 :* go n where go 0 = topSubDmd - go n = Call C_01 $ go (n-1) + go n = mkCall C_01 $ go (n-1) argsOneShots :: DmdSig -> Arity -> [[OneShotInfo]] -- ^ See Note [Computing one-shot info] @@ -1242,22 +1125,24 @@ NB: The Premise only makes a difference for lower bounds/strictness. Upper bounds/usage are unaffected by adding or leaving out evaluations that never happen. -So if `x` was demanded with `LP(1L)`, so perhaps `` was - f1 x = (x `seq` case x of (a,b) -> a, True) -then `x` will be evaluated lazily, but any time `x` is evaluated, `e` is -evaluated with sub-demand `P(1L)`, e.g., the first field of `e` is evaluated -strictly, too. - -How does the additional strictness help? The long version is in #21081. +The Premise comes into play when we have lazy Demands. For example, if `x` was +demanded with `LP(SL,A)`, so perhaps the full expression was + let x = (e1, e2) in (x `seq` fun y `seq` case x of (a,b) -> a, True) +then `x` will be evaluated lazily, but in any trace in which `x` is evaluated, +the pair in its RHS will ultimately be evaluated deeply with sub-demand +`P(SL,A)`. That means that `e1` is ultimately evaluated strictly, even though +evaluation of the field does not directly follow the eval of `x` due to the +intermittent call `fun y`. + +How does the additional strictness help? The long version is the list of +examples at the end of this Note (as procured in #21081 and #18903). The short version is - * We get to take advantage of call-by-value/let-to-case in more situations. - See example "More let-to-case" below. + * We get to take advantage of call-by-value/let-to-case in more situations, + as for e1 above. See example "More let-to-case" below. * Note [Eta reduction based on evaluation context] applies in more situations. See example "More eta reduction" below. * We get to unbox more results, see example "More CPR" below. - * We prevent annoying issues with `Poly` equalities, #21085. In short, we'd get - `L + S = S = CS(S) < CS(L) = C(L+S)(LuS) = L + CS(S)` although `S = CS(S)`. It seems like we don't give up anything in return. Indeed that is the case: @@ -1271,47 +1156,26 @@ It seems like we don't give up anything in return. Indeed that is the case: well as when expanding absent 'Poly's to 'Call' sub-demands in 'viewCall'. Of course, we now have to maintain the Premise when we unpack and rebuild -SubDemands. For strict demands, we know that the Premise indeed always holds for +Demands. For strict demands, we know that the Premise indeed always holds for any program trace abstracted over, whereas we have to be careful for lazy demands. -That makes for a strange definition of `plusDmd`, where we use `plusSubDmd` -throughout for upper bounds (every eval returns the same, memoised heap object), -but what we do on lower bounds depends on the strictness of both arguments: - - D1 `plusSubDmd` on the nested SubDemands if both args are strict. - D2 `plusSubDmd` on the nested SubDemands if one of them is lazy, which we - *lazify* before (that's new), so that e.g. - `LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L)` - Multiplying with `M`/`C_01` is the "lazify" part here. - Example proving that point: - d2 :: - d2 x y = y `seq` (case x of (a,b) -> a, True) - -- What is demand on x in (d2 x x)? NOT SP(SL)!! - D3 `lubPlusSubDmd` on the nested SubDemands if both args are lazy. - This new operation combines `lubSubDmd` on lower bounds with `plusSubDmd` - on upper bounds. - Examples proving that point: - d3 :: - d3 x y = (case x of (a,b) -> a, y `seq` ()) - -- What is demand on x in `snd (d3 x x)`? - -- Not LP(SL)!! d3 might evaluate second argument but not first. - -- Lub lower bounds because we might evaluate one OR the other. - -Similarly, in the handling of Call SubDemands `Cn(sd)` in `plusSubDmd`, we use -`lub` for upper bounds (because every call returns a fresh heap object), but -what we do for lower bounds depends on whether the outer `n`s are strict: - - C1 `lubSubDmd` on the nested SubDemands if both args are lazy. - C2 `plusLubSubDmd` on the nested `sd`s if one of the `n`s is lazy. That one's - nested `sd` we *lazify*, so that e.g. - `CL(SL) + CS(L) = C(L+S)((M*SL)+L) = CS(L+L) = CS(L)` - `plusLubSubDmd` combines `plusSubDmd` on lower bounds with `lubSubDmd` on - upper bounds. - C3 `plusLubSubDmd` on the nested SubDemands if both args are strict. - -There are a couple of other examples in T21081. -Here is a selection of examples demonstrating the -usefulness of The Premise: + +In particular, when doing `plusDmd` we have to *lazify* the nested SubDemand +if the outer cardinality is lazy. E.g., + LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L) +Multiplying with `M`/`C_01` is the "lazify" part here and is implemented in +`lazifyIfStrict`. Example proving that point: + d2 :: + d2 x y = y `seq` (case x of (a,b) -> a, True) + -- What is the demand on x in (d2 x x)? NOT SP(SL)!! + +We used to apply the same reasoning to Call SubDemands `Cn(sd)` in `plusSubDmd`, +but that led to #21717, because different calls return different heap objects. +See Note [Call SubDemand vs. evaluation Demand]. + +There are a couple more examples that improve in T21081. +Here is a selection of those examples demonstrating the usefulness of The +Premise: * "More let-to-case" (from testcase T21081): ```hs @@ -1355,6 +1219,102 @@ usefulness of The Premise: pair. That in turn means that Nested CPR can unbox the result of the division even though it might throw. +Note [Unrealised opportunity in plusDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Recall the lazification of SubDemands happening in `plusDmd` as described in +Note [SubDemand denotes at least one evaluation]. + +We *could* do better when both Demands are lazy already. Example + (fun 1, fun 2) +Both args put Demand SCS(L) on `fun`. The lazy pair arg context lazifies +this to LCS(L), and it would be reasonable to report this Demand on `fun` for +the entire pair expression; after all, `fun` is called whenever it is evaluated. +But our definition of `plusDmd` will compute + LCS(L) + LCS(L) = (L+L)(M*CS(L) + M*CS(L)) = L(CL(L)) = L +Which is clearly less precise. +Doing better here could mean to `lub` when both demands are lazy, e.g., + LCS(L) + LCS(L) = (L+L)(CS(L) ⊔ CS(L)) = L(CS(L)) +Indeed that's what we did at one point between 9.4 and 9.6 after !7599, but it +means that we need a function `lubPlusSubDmd` that lubs on lower bounds but +plus'es upper bounds, implying maintenance challenges and complicated +explanations. + +Plus, NoFib says that this special case doesn't bring all that much +(geom. mean +0.0% counted instructions), so we don't bother anymore. + +Note [Call SubDemand vs. evaluation Demand] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Although both evaluation Demands and Call SubDemands carry a (Card,SubDemand) +pair, their interpretation is quite different. Example: + + f x = fst x * snd x + -- f :: , because 1P(1L,A)+1P(A,1L) = SP(1L,1L) + g x = fst (x 1) * snd (x 2) + -- g :: , because 1C1(P(1L,A))+1C1(P(A,1L)) = SCS(P(ML,ML)) + +The point about this example is that both demands have P(A,1L)/P(1L,A) as +sub-expressions, but when these sub-demands occur + + 1. under an evaluation demand, we combine with `plusSubDmd` + 2. whereas under a Call sub-demand, we combine with `lubSubDmd` + +And thus (1) yields a stricter demand on the pair components than (2). + +In #21717 we saw that we really need lub in (2), because otherwise we make an +unsound prediction in `g (\n -> if n == 1 then (1,1) else (bot,2))`; we'd say +that the `bot` expression is always evaluated, when it clearly is not. +Operationally, every call to `g` gives back a potentially distinct, +heap-allocated pair with potentially different contents, and we must `lubSubDmd` +over all such calls to approximate how any of those pairs might be used. + +That is in stark contrast to f's argument `x`: Operationally, every eval of +`x` must yield the same pair and `f` evaluates both components of that pair. +The theorem "every eval of `x` returns the same heap object" is a very strong +MUST-alias property and we capitalise on that by using `plusSubDmd` in (1). + +And indeed we *must* use `plusSubDmd` in (1) for sound upper bounds in an +analysis that assumes call-by-need (as opposed to the weaker call-by-name) for +let bindings. Consider + + h x = fst x * fst x + -- h :: + +And the expression `let a=1; p=(a,a)} in h p`. Here, *although* the RHS of `p` +is only evaluated once under call-by-need, `a` is still evaluated twice. +If we had used `lubSubDmd`, we'd see SP(1L,A) and the 1L unsoundly says "exactly +once". + +If the analysis had assumed call-by-name, it would be sound to say "a is used +once in p": p is used multiple times and hence so would a, as if p was a +function. So using `plusSubDmd` does not only yield better strictness, it is +also "holding up the other end of the bargain" of the call-by-need assumption +for upper bounds. + +(To SG's knowledge, the distinction between call-by-name and call-by-need does +not matter for strictness analysis/lower bounds, thus it would be sound to use +`lubSubDmd` all the time there.) + +Note [mkCall and plusSubDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We never rewrite a strict, non-absent Call sub-demand like CS(S) to a +polymorphic sub-demand like S, otherwise #21085 strikes. Consider the +following inequality (would also for M and 1 instead of L and S, but we forbid +such Polys): + + L+S = S = CS(S) < CS(L) = CL(L)+CS(S) + +Note that L=CL(L). If we also had S=CS(S), we'd be in trouble: Now +`plusSubDmd` would no longer maintain the equality relation on sub-demands, +much less monotonicity. Bad! + +Clearly, `n <= Cn(n)` is unproblematic, as is `n >= Cn(n)` for any `n` +except 1 and S. But `CS(S) >= S` would mean trouble, because then we'd get +the problematic `CS(S) = S`. We have just established that `S < CS(S)`! +As such, the rewrite CS(S) to S is anti-monotone and we forbid it, first +and foremost in `mkCall` (which is the only place that rewrites Cn(n) to n). + +Crisis and #21085 averted! + Note [Computing one-shot info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a call @@ -2102,7 +2062,7 @@ If this same function is applied to one arg, all we can say is that it uses x with 1L, and its arg with demand 1P(L,L). Note [Understanding DmdType and DmdSig] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Demand types are sound approximations of an expression's semantics relative to the incoming demand we put the expression under. Consider the following expression: ===================================== testsuite/tests/arityanal/should_compile/Arity11.stderr ===================================== @@ -53,7 +53,7 @@ F11.fib1 = GHC.Num.Integer.IS 0# -- RHS size: {terms: 52, types: 26, coercions: 0, joins: 0/5} F11.$wfib [InlPrag=[2]] :: forall {t} {a}. (t -> t -> Bool) -> (Num t, Num a) => t -> a -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] F11.$wfib = \ (@t) (@a) (ww :: t -> t -> Bool) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> let { @@ -91,7 +91,7 @@ F11.$wfib fib [InlPrag=[2]] :: forall {t} {a}. (Eq t, Num t, Num a) => t -> a [GblId, Arity=4, - Str=<1P(SCS(C1(L)),A)>, + Str=<1P(SCS(C1(L)),A)>, 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= \ (@t) (@a) ($dEq [Occ=Once1!] :: Eq t) ($dNum [Occ=Once1] :: Num t) ($dNum1 [Occ=Once1] :: Num a) (eta [Occ=Once1] :: t) -> case $dEq of { GHC.Classes.C:Eq ww [Occ=Once1] _ [Occ=Dead] -> F11.$wfib @t @a ww $dNum $dNum1 eta }}] fib = \ (@t) (@a) ($dEq :: Eq t) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> case $dEq of { GHC.Classes.C:Eq ww ww1 -> F11.$wfib @t @a ww $dNum $dNum1 eta } @@ -142,4 +142,7 @@ f11 :: (Integer, Integer) f11 = (F11.f4, F11.f1) +------ Local rules for imported ids -------- +"SPEC fib @Integer @Integer" forall ($dEq :: Eq Integer) ($dNum :: Num Integer) ($dNum1 :: Num Integer). fib @Integer @Integer $dEq $dNum $dNum1 = F11.f11_fib + ===================================== testsuite/tests/arityanal/should_compile/Arity14.stderr ===================================== @@ -14,7 +14,7 @@ F14.f2 = GHC.Num.Integer.IS 1# -- RHS size: {terms: 35, types: 23, coercions: 0, joins: 0/3} F14.$wf14 [InlPrag=[2]] :: forall {t}. (t -> t -> Bool) -> Num t => t -> t -> t -> t -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] F14.$wf14 = \ (@t) (ww :: t -> t -> Bool) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> let { @@ -41,7 +41,7 @@ F14.$wf14 f14 [InlPrag=[2]] :: forall {t}. (Ord t, Num t) => t -> t -> t -> t [GblId, Arity=4, - Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, + Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, 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= \ (@t) ($dOrd [Occ=Once1!] :: Ord t) ($dNum [Occ=Once1] :: Num t) (eta [Occ=Once1] :: t) (eta1 [Occ=Once1] :: t) -> case $dOrd of { GHC.Classes.C:Ord _ [Occ=Dead] _ [Occ=Dead] ww2 [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> F14.$wf14 @t ww2 $dNum eta eta1 }}] f14 = \ (@t) ($dOrd :: Ord t) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> case $dOrd of { GHC.Classes.C:Ord ww ww1 ww2 ww3 ww4 ww5 ww6 ww7 -> F14.$wf14 @t ww2 $dNum eta eta1 } ===================================== testsuite/tests/arityanal/should_compile/Arity16.stderr ===================================== @@ -5,7 +5,7 @@ Result size of Tidy Core = {terms: 53, types: 71, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 15, types: 15, coercions: 0, joins: 0/0} map2 [Occ=LoopBreaker] :: forall {t} {a}. (t -> a) -> [t] -> [a] -[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] map2 = \ (@t) (@a) (f :: t -> a) (ds :: [t]) -> case ds of { @@ -27,7 +27,7 @@ lvl1 = Control.Exception.Base.patError @GHC.Types.LiftedRep @() lvl Rec { -- RHS size: {terms: 31, types: 32, coercions: 0, joins: 0/0} zipWith2 [Occ=LoopBreaker] :: forall {t1} {t2} {a}. (t1 -> t2 -> a) -> [t1] -> [t2] -> [a] -[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] zipWith2 = \ (@t) (@t1) (@a) (f :: t -> t1 -> a) (ds :: [t]) (ds1 :: [t1]) -> case ds of { ===================================== testsuite/tests/simplCore/should_compile/T21261.hs ===================================== @@ -34,18 +34,26 @@ f5 c = Just (c 1 2 + c 3 4) yes2_lazy :: (Int -> Int -> Int) -> Maybe Int yes2_lazy c = f5 (\x y -> c x y) --- These last two here are disallowed in T21261_pedantic.hs, which activates --- -fpedantic-bottoms. It would be unsound to eta reduce these bindings with --- -fpedantic-bottoms, but without it's fine to eta reduce: +-- These last two here are tricky. It is unsound to eta reduce +-- the args to f6 and f7 because we could call both functions +-- at a c like `\x -> if x == 1 then undefined else id`. +-- Note that if we do so and *do* eta-reduce, we'll see a crash! +-- Whereas we *don't* see a crash if we keep the original, +-- eta-expanded arguments. +-- +-- This is issue is discussed in Note [Eta reduction soundness], condition (S). +-- +-- This is a variant of #21717 (and tested by T21717), where +-- prior to the fix we observed an unsound strictness signature. f6 :: (Int -> Int -> Int) -> Int f6 c = c 1 `seq` c 2 3 {-# NOINLINE f6 #-} -yes_non_pedantic :: (Int -> Int -> Int) -> Int -yes_non_pedantic c = f6 (\x y -> c x y) +no_tricky :: (Int -> Int -> Int) -> Int +no_tricky c = f6 (\x y -> c x y) f7 :: (Int -> Int -> Int) -> Maybe Int f7 c = Just (c 1 `seq` c 3 4) {-# NOINLINE f7 #-} -yes_non_pedantic_lazy :: (Int -> Int -> Int) -> Maybe Int -yes_non_pedantic_lazy c = f7 (\x y -> c x y) +no_tricky_lazy :: (Int -> Int -> Int) -> Maybe Int +no_tricky_lazy c = f7 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 166, types: 176, coercions: 0, joins: 0/0} + = {terms: 182, types: 191, coercions: 0, joins: 0/0} lvl = I# 3# @@ -29,13 +29,14 @@ no3 f6 = \ c -> case c lvl2 of { __DEFAULT -> c lvl3 lvl } -yes_non_pedantic = f6 +no_tricky = \ c -> f6 (\ x y -> c x y) $wf7 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl lvl1 } #) f7 = \ c -> case $wf7 c of { (# ww #) -> Just ww } -yes_non_pedantic_lazy = f7 +no_tricky_lazy + = \ c -> case $wf7 (\ x y -> c x y) of { (# ww #) -> Just ww } $wf5 = \ c -> ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.hs deleted ===================================== @@ -1,18 +0,0 @@ -{-# OPTIONS_GHC -fpedantic-bottoms #-} -- This flag must inhibit eta reduction based on demands - -module T21261_pedantic where - --- README: See T21261. These examples absolutely should not eta reduce with --- -fpedantic-bottoms. - -f1 :: (Int -> Int -> Int) -> Int -f1 c = c 1 `seq` c 2 3 -{-# NOINLINE f1 #-} -no2 :: (Int -> Int -> Int) -> Int -no2 c = f1 (\x y -> c x y) - -f2 :: (Int -> Int -> Int) -> Maybe Int -f2 c = Just (c 1 `seq` c 3 4) -{-# NOINLINE f2 #-} -no2_lazy :: (Int -> Int -> Int) -> Maybe Int -no2_lazy c = f2 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr deleted ===================================== @@ -1,26 +0,0 @@ - -==================== Tidy Core ==================== -Result size of Tidy Core - = {terms: 59, types: 63, coercions: 0, joins: 0/0} - -lvl = I# 2# - -lvl1 = I# 3# - -lvl2 = I# 1# - -f1 = \ c -> case c lvl2 of { __DEFAULT -> c lvl lvl1 } - -no2 = \ c -> f1 (\ x y -> c x y) - -lvl3 = I# 4# - -$wf2 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl1 lvl3 } #) - -f2 = \ c -> case $wf2 c of { (# ww #) -> Just ww } - -no2_lazy - = \ c -> case $wf2 (\ x y -> c x y) of { (# ww #) -> Just ww } - - - ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -407,8 +407,7 @@ test('T21144', normal, compile, ['-O']) test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. -test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) -test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # We expect to see a SPEC rule for $cm test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/stranal/should_compile/T18894.stderr ===================================== @@ -147,7 +147,7 @@ lvl :: (Int, Int) lvl = (lvl, lvl) -- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} -g1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] :: Int -> (Int, Int) +g1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: Int -> (Int, Int) [LclId, Arity=1, Str=<1!P(1L)>, @@ -266,7 +266,7 @@ lvl = GHC.Types.I# 0# -- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} $wg2 [InlPrag=NOINLINE, Dmd=LCS(C1(!P(M!P(L),1!P(L))))] :: Int -> GHC.Prim.Int# -> (# Int, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -328,9 +328,9 @@ h2 } -- RHS size: {terms: 34, types: 14, coercions: 0, joins: 0/1} -$wg1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] +$wg1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -367,7 +367,7 @@ lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} $wh1 [InlPrag=[2], Dmd=LCS(!P(L))] :: GHC.Prim.Int# -> Int -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, ===================================== testsuite/tests/stranal/should_run/T21717b.hs ===================================== @@ -0,0 +1,18 @@ +import System.Environment +import GHC.Exts + +g :: (Int -> (Int, Int)) -> Int +-- Should *not* infer strictness SCS(P(SL,SL)) for h +-- Otherwise `main` could use CbV on the DivByZero exprs +g h = fst (h 0) + snd (h 1) +{-# NOINLINE g #-} + +main = do + m <- length <$> getArgs + -- The point here is that we may *not* use CbV/let-to-case on err! + -- GHC.Exts.lazy so that we don't lambda lift and float out the + -- obviously bottoming RHS (where it is no longer used strictly). + let err = GHC.Exts.lazy $ error (show m) + let f n | even n = (n+m, err) + | otherwise = (err, n+m) + print $! g f ===================================== testsuite/tests/stranal/should_run/T21717b.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/stranal/should_run/all.T ===================================== @@ -27,3 +27,4 @@ test('T14290', normal, compile_and_run, ['']) test('T14285', normal, multimod_compile_and_run, ['T14285', '']) test('T17676', normal, compile_and_run, ['']) test('T19053', normal, compile_and_run, ['']) +test('T21717b', normal, compile_and_run, ['']) ===================================== testsuite/tests/stranal/sigs/T20746.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -Foo.f: +Foo.f: Foo.foogle: ===================================== testsuite/tests/stranal/sigs/T21081.stderr ===================================== @@ -4,7 +4,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: T21081.blurg2: T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: @@ -50,7 +50,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: <1!P(SL)> T21081.blurg2: <1!P(SL)> T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: ===================================== testsuite/tests/stranal/sigs/T21119.stderr ===================================== @@ -4,7 +4,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x @@ -24,7 +24,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x ===================================== testsuite/tests/stranal/sigs/T21717.hs ===================================== @@ -0,0 +1,12 @@ +module T21717 (g) where + +-- This is the original reproducer from #21717. +-- See T21717b for a reproducer that exhibited a crash. + +f :: Bool -> (Int, Int) +f True = (42,error "m") +f False = (error "m",42) + +g :: (Bool -> (Int, Int)) -> Int +g h = fst (h True) + snd (h False) +{-# NOINLINE g #-} ===================================== testsuite/tests/stranal/sigs/T21717.stderr ===================================== @@ -0,0 +1,15 @@ + +==================== Strictness signatures ==================== +T21717.g: + + + +==================== Cpr signatures ==================== +T21717.g: 1 + + + +==================== Strictness signatures ==================== +T21717.g: + + ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -T5075.f: +T5075.f: T5075.g: <1L> T5075.h: @@ -14,7 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> +T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> T5075.g: <1L> T5075.h: <1!P(L)> ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -33,5 +33,6 @@ test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) +test('T21717', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b4ba099e92077016607657e97a7772c089421e15 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b4ba099e92077016607657e97a7772c089421e15 You're receiving 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 Sep 27 09:55:55 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 05:55:55 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <6332c8ab8ed4f_2c975751414303171@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 68f1c783 by Andreas Klebinger at 2022-09-27T11:48:06+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,187 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. +-} + +module GHC.Builtin.PrimOps.Casts 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) + +-- from - to +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | 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 = wordOrIntToAddrRep from_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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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 ===================================== @@ -258,8 +258,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 +281,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +311,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 +327,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 +375,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 +388,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 +399,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 unariseUbxSumTupleArgs 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 +417,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 unariseUbxSumTupleArgs 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 +454,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +495,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 +598,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) -------------------------------------------------------------------------------- @@ -618,29 +640,115 @@ mapTupleIdBinders ids args0 rho0 in map_ids rho0 ids_unarised args0 +{- 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. +This works *if* we put a Float/Store in the register representing sum_field +at the call side and the implicitly + +To fix this we now convert properly between the types of the slots and the actual +types we want to put into, and get out of the field. + +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. + + -} mapSumIdBinders :: [InId] -- Binder of a sum alternative (remember that sum patterns -- 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +763,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 +778,52 @@ 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 + -- mapAccumLM (acc -> x -> m (acc, y)) acc ([x]) + ((_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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +934,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 +956,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68f1c783e9ec03ccd2a963f85e0e1519aa8904f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68f1c783e9ec03ccd2a963f85e0e1519aa8904f8 You're receiving 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 Sep 27 09:58:55 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 05:58:55 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <6332c95f7b133_2c97575147830361d@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 5a58b721 by Andreas Klebinger at 2022-09-27T11:57:50+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,187 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. +-} + +module GHC.Builtin.PrimOps.Casts 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) + +-- from - to +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | 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 = wordOrIntToAddrRep from_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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,75 @@ 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +761,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 +776,52 @@ 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 + -- mapAccumLM (acc -> x -> m (acc, y)) acc ([x]) + ((_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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +932,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 +954,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a58b72176ddd3f777c5fd454545d9e2d11ab9ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a58b72176ddd3f777c5fd454545d9e2d11ab9ea You're receiving 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 Sep 27 10:25:14 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Tue, 27 Sep 2022 06:25:14 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] 31 commits: Clean up some. In particular: Message-ID: <6332cf8ad3542_2c975751450312821@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 5eeda514 by Luite Stegeman at 2022-09-27T11:54:11+02:00 Add PrimCallConv suppport to GHCi - - - - - 3bbb21a6 by Luite Stegeman at 2022-09-27T11:54:11+02:00 fixups - - - - - 40520888 by Luite Stegeman at 2022-09-27T11:54:11+02:00 add new note ref - - - - - 85441428 by Luite Stegeman at 2022-09-27T11:54:11+02:00 twiddle test options - - - - - 9ffbdbc2 by Luite Stegeman at 2022-09-27T11:54:11+02:00 untwiddle a test option - - - - - 92acc601 by Luite Stegeman at 2022-09-27T11:54:11+02:00 generalise GHCi tuple things to nativeCall and extend test case - - - - - fe3c8a70 by Luite Stegeman at 2022-09-27T12:23:52+02:00 add ghci primcall testcase expected output - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6cca1ebbdf31950c7c0a58a2ec032c6407a247e9...fe3c8a70995e92589517466f639e2ec867f053a7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6cca1ebbdf31950c7c0a58a2ec032c6407a247e9...fe3c8a70995e92589517466f639e2ec867f053a7 You're receiving 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 Sep 27 10:55:09 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 06:55:09 -0400 Subject: [Git][ghc/ghc][wip/T21286] 3 commits: Improve aggressive specialisation Message-ID: <6332d68d6fa07_2c9757514003316d4@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 33105eec by Simon Peyton Jones at 2022-09-27T11:49:00+01: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 - - - - - f6d3af11 by Simon Peyton Jones at 2022-09-27T11:56:59+01: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. - - - - - 71823511 by Simon Peyton Jones at 2022-09-27T11:56:59+01: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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Make.hs - libraries/base/Foreign/Marshal/Array.hs - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/deSugar/should_compile/T19969.stderr - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/indexed-types/should_compile/T7837.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2a660d024b1efea4b6fc3460b424bfe993e06e45...7182351129c66a5933b3eba4d80cb9930b1dbe0d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2a660d024b1efea4b6fc3460b424bfe993e06e45...7182351129c66a5933b3eba4d80cb9930b1dbe0d You're receiving 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 Sep 27 12:18:12 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 27 Sep 2022 08:18:12 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Disable recomp015 Message-ID: <6332ea04b4b3f_2c9757514643710bd@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 68018d77 by Sylvain Henry at 2022-09-27T14:21:18+02:00 Disable recomp015 - - - - - 1 changed file: - testsuite/tests/driver/recomp015/all.T Changes: ===================================== testsuite/tests/driver/recomp015/all.T ===================================== @@ -5,6 +5,7 @@ test('recomp015', # See ticket:11022#comment:7 unless(opsys('linux') or opsys('solaris2') or opsys('openbsd'), skip), when(arch('arm'), skip), + js_skip, # JS backend doesn't support .s assembly files when(arch('powerpc64'), expect_broken(11323))], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68018d77700833b7865d9ee33e817fc7d5d15478 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68018d77700833b7865d9ee33e817fc7d5d15478 You're receiving 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 Sep 27 12:23:54 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 08:23:54 -0400 Subject: [Git][ghc/ghc][wip/ghc-fat-interface] 163 commits: typo Message-ID: <6332eb5ae206d_2c9757dfd403821fd@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-fat-interface at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 16502500 by Matthew Pickering at 2022-09-26T19:46:24+01: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. - - - - - 97a19f4d by Matthew Pickering at 2022-09-27T13:14:22+01: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 - - - - - 40330411 by Matthew Pickering at 2022-09-27T13:14:22+01: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 - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8733981155a47e18f3d25f1c40fd525168641928...40330411c948f35979b62e7025da8ddf1d39ac74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8733981155a47e18f3d25f1c40fd525168641928...40330411c948f35979b62e7025da8ddf1d39ac74 You're receiving 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 Sep 27 12:34:38 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 08:34:38 -0400 Subject: [Git][ghc/ghc][wip/T21286] 3 commits: Improve aggressive specialisation Message-ID: <6332eddef3fe6_2c9757514003875fc@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 40419260 by Simon Peyton Jones at 2022-09-27T13:36:10+01: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 - - - - - 54d1954a by Simon Peyton Jones at 2022-09-27T13:36:43+01: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. - - - - - 8dca5184 by Simon Peyton Jones at 2022-09-27T13:36:43+01: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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Make.hs - libraries/base/Foreign/Marshal/Array.hs - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/deSugar/should_compile/T19969.stderr - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/indexed-types/should_compile/T7837.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7182351129c66a5933b3eba4d80cb9930b1dbe0d...8dca5184c925159119aae1d7860a91c3f22656b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7182351129c66a5933b3eba4d80cb9930b1dbe0d...8dca5184c925159119aae1d7860a91c3f22656b5 You're receiving 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 Sep 27 12:35:28 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 08:35:28 -0400 Subject: [Git][ghc/ghc][wip/ghc-fat-interface] 2 commits: Interface Files with Core Definitions Message-ID: <6332ee101823b_2c975751400388510@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-fat-interface at Glasgow Haskell Compiler / GHC Commits: 15c1685c by Matthew Pickering at 2022-09-27T13:35:22+01: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 - - - - - 7c322be4 by Matthew Pickering at 2022-09-27T13:35:22+01: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 - - - - - 30 changed files: - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.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/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Unit/Home/ModInfo.hs - compiler/GHC/Unit/Module/Graph.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Unit/Module/Status.hs - + compiler/GHC/Unit/Module/WholeCoreBindings.hs - compiler/ghc.cabal.in - docs/users_guide/phases.rst - ghc/GHCi/Leak.hs - ghc/Main.hs - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - testsuite/tests/driver/T20300/T20300.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40330411c948f35979b62e7025da8ddf1d39ac74...7c322be403375851d5a5fd1e0607ca90a0480b62 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/40330411c948f35979b62e7025da8ddf1d39ac74...7c322be403375851d5a5fd1e0607ca90a0480b62 You're receiving 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 Sep 27 13:15:33 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 27 Sep 2022 09:15:33 -0400 Subject: [Git][ghc/ghc][wip/T21717] Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <6332f77511a3b_2c97575147840414c@gitlab.mail> Sebastian Graf pushed to branch wip/T21717 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 22 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/simplCore/should_compile/T21261.hs - testsuite/tests/simplCore/should_compile/T21261.stderr - − testsuite/tests/simplCore/should_compile/T21261_pedantic.hs - − testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/stranal/should_compile/T18894.stderr - + testsuite/tests/stranal/should_run/T21717b.hs - + testsuite/tests/stranal/should_run/T21717b.stdout - testsuite/tests/stranal/should_run/all.T - testsuite/tests/stranal/sigs/T20746.stderr - testsuite/tests/stranal/sigs/T21081.stderr - testsuite/tests/stranal/sigs/T21119.stderr - + testsuite/tests/stranal/sigs/T21717.hs - + testsuite/tests/stranal/sigs/T21717.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -509,9 +509,6 @@ this transformation. So we try to limit it as much as possible: Of course both (1) and (2) are readily defeated by disguising the bottoms. -Another place where -fpedantic-bottoms comes up is during eta-reduction. -See Note [Eta reduction soundness], the bit about -fpedantic-bottoms. - 4. Note [Newtype arity] ~~~~~~~~~~~~~~~~~~~~~~~~ Non-recursive newtypes are transparent, and should not get in the way. @@ -2382,20 +2379,13 @@ case where `e` is trivial): `e = \x y. bot`. Could we relax to "*At least one call in the same trace* is with n args"? - (NB: Strictness analysis can only answer this relaxed question, not the - original formulation.) - Consider what happens for + No. Consider what happens for ``g2 c = c True `seq` c False 42`` Here, `g2` will call `c` with 2 arguments (if there is a call at all). But it is unsound to eta-reduce the arg in `g2 (\x y. e x y)` to `g2 e` when `e = \x. if x then bot else id`, because the latter will diverge when - the former would not. - - On the other hand, with `-fno-pedantic-bottoms` , we will have eta-expanded - the definition of `e` and then eta-reduction is sound - (see Note [Dealing with bottom]). - Consequence: We have to check that `-fpedantic-bottoms` is off; otherwise - eta-reduction based on demands is in fact unsound. + the former would not. Fortunately, the strictness analyser will report + "Not always called with two arguments" for `g2` and we won't eta-expand. See Note [Eta reduction based on evaluation context] for the implementation details. This criterion is tested extensively in T21261. @@ -2541,7 +2531,7 @@ Then this is how the pieces are put together: Because it's irrelevant! When we simplify an expression, we do so under the assumption that it is currently under evaluation.) This sub-demand literally says "Whenever this expression is evaluated, it - is also called with two arguments, potentially multiple times". + is called with at least two arguments, potentially multiple times". * Then the simplifier takes apart the lambda and simplifies the lambda group and then calls 'tryEtaReduce' when rebuilding the lambda, passing the ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1643,11 +1643,7 @@ rebuildLam env bndrs body cont mb_rhs = contIsRhs cont -- See Note [Eta reduction based on evaluation context] - eval_sd - | sePedanticBottoms env = topSubDmd - -- See Note [Eta reduction soundness], criterion (S) - -- the bit about -fpedantic-bottoms - | otherwise = contEvalContext cont + eval_sd = contEvalContext cont -- NB: cont is never ApplyToVal, because beta-reduction would -- have happened. So contEvalContext can panic on ApplyToVal. ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -598,26 +598,6 @@ multCard (Card a) (Card b) bit1 = (a .&. b) .&. 0b010 bitN = (a .|. b) .&. shiftL bit1 1 .&. 0b100 --- | Denotes '∪' on lower and '+' on upper bounds of 'Card'. -lubPlusCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -lubPlusCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .|. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = ((a .|. b) .|. shiftL (a .&. b) 1) .&. 0b100 - --- | Denotes '+' on lower and '∪' on upper bounds of 'Card'. -plusLubCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -plusLubCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .&. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = (a .|. b) .&. 0b100 - {- ************************************************************************ * * @@ -626,11 +606,11 @@ plusLubCard (Card a) (Card b) ************************************************************************ -} --- | A demand describes a /scaled evaluation context/, e.g. how many times --- and how deep the denoted thing is evaluated. +-- | A demand describes +-- +-- * How many times a variable is evaluated, via a 'Card'inality, and +-- * How deep its value was evaluated in turn, via a 'SubDemand'. -- --- The "how many" component is represented by a 'Card'inality. --- The "how deep" component is represented by a 'SubDemand'. -- Examples (using Note [Demand notation]): -- -- * 'seq' puts demand @1A@ on its first argument: It evaluates the argument @@ -674,8 +654,8 @@ viewDmdPair BotDmd = (C_10, botSubDmd) viewDmdPair AbsDmd = (C_00, botSubDmd) viewDmdPair (D n sd) = (n, sd) --- | @c :* sd@ is a demand that says \"evaluated @c@ times, and each time it --- was evaluated, it was at least as deep as @sd@\". +-- | @c :* sd@ is a demand that says \"evaluated @c@ times, and any trace in +-- which it is evaluated will evaluate at least as deep as @sd@\". -- -- Matching on this pattern synonym is a complete match. -- If the matched demand was 'AbsDmd', it will match as @C_00 :* seqSubDmd at . @@ -695,8 +675,9 @@ pattern n :* sd <- (viewDmdPair -> (n, sd)) where n :* sd = D n sd & assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) {-# COMPLETE (:*) #-} --- | A sub-demand describes an /evaluation context/, e.g. how deep the --- denoted thing is evaluated. See 'Demand' for examples. +-- | A sub-demand describes an /evaluation context/ (in the sense of an +-- operational semantics), e.g. how deep the denoted thing is going to be +-- evaluated. See 'Demand' for examples. -- -- See Note [SubDemand denotes at least one evaluation] for a more detailed -- description of what a sub-demand means. @@ -714,14 +695,17 @@ data SubDemand -- @Poly b n@ is semantically equivalent to @Prod b [n :* Poly b n, ...] -- or @Call n (Poly Boxed n)@. 'viewCall' and 'viewProd' do these rewrites. -- - -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === CL(L)@, - -- @B === P(B,B,...)@ and @B === CB(B)@, - -- @!A === !P(A,A,...)@ and @!A === !CA(B)@, + -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === C(L)@, + -- @B === P(B,B,...)@ and @B === C(B)@, + -- @!A === !P(A,A,...)@ and @!A === C(A)@, -- and so on. -- -- We'll only see 'Poly' with 'C_10' (B), 'C_00' (A), 'C_0N' (L) and sometimes -- 'C_1N' (S) through 'plusSubDmd', never 'C_01' (M) or 'C_11' (1) (grep the -- source code). Hence 'CardNonOnce', which is closed under 'lub' and 'plus'. + -- + -- Why doesn't this constructor simply carry a 'Demand' instead of its fields? + -- See Note [Call SubDemand vs. evaluation Demand]. | Call !CardNonAbs !SubDemand -- ^ @Call n sd@ describes the evaluation context of @n@ function -- applications (with one argument), where the result of each call is @@ -803,7 +787,7 @@ viewProd _ _ -- equality @Call C_0N (Poly C_0N) === Poly C_0N@, simplifying to 'Poly' 'SubDemand's -- when possible. mkCall :: CardNonAbs -> SubDemand -> SubDemand -mkCall C_1N sd@(Poly Boxed C_1N) = sd +--mkCall C_1N sd@(Poly Boxed C_1N) = sd -- NO! #21085 strikes. See Note [mkCall and plusSubDmd] mkCall C_0N sd@(Poly Boxed C_0N) = sd mkCall n sd = assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) $ Call n sd @@ -838,17 +822,6 @@ unboxDeeplyDmd BotDmd = BotDmd unboxDeeplyDmd dmd@(D n sd) | isStrict n = D n (unboxDeeplySubDmd sd) | otherwise = dmd -multSubDmd :: Card -> SubDemand -> SubDemand -multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod --- The following three equations don't have an impact on Demands, only on --- Boxity. They are needed so that we don't trigger the assertions in `:*` --- when called from `multDmd`. -multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` -multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` -multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality -multSubDmd n (Poly b m) = Poly b (multCard n m) -multSubDmd n (Call n' sd) = mkCall (multCard n n') sd -multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) multDmd :: Card -> Demand -> Demand multDmd C_11 dmd = dmd -- An optimisation @@ -866,170 +839,85 @@ multDmd n BotDmd = if isStrict n then BotDmd else AbsDmd -- See Note [SubDemand denotes at least one evaluation] for the strictifyCard multDmd n (D m sd) = multCard n m :* multSubDmd (strictifyCard n) sd -{- Note [Manual specialisation of lub*Dmd/plus*Dmd] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As Note [SubDemand denotes at least one evaluation] points out, we need all 4 -different combinations of lub/plus demand operations on upper and lower bounds - lubDmd, plusDmd, lubPlusDmd, plusLubDmd -and the same for lubSubDmd, etc. In order to share as much code as possible -and for the programmer to see immediately how the operations differ, we have -one implementation of opDmd (and opSubDmd) that dispatches on a 'OpMode'. - -For good perf, we specialise this one implementation to the four different -modes. So ideally we'd write -``` -lubSubDmd = opSubDmd (Lub, Lub) -opSubDmd (l, u) = ... opSubDmd ... -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -But unfortunately, 'opSubDmd' will be picked as a loop-breaker and thus never -inline into 'lubSubDmd', so its body will never actually be specialised for -the op mode `(Lub, Lub)`. So instead we write -``` -lubSubDmd = opSubDmdInl (Lub, Lub) -opSubDmdInl (l, u) = ... opSubDmd ... -{-# INLINE opSubDmdInl #-} -opSubDmd = opSubDmdInl -{-# RULES "lubSubDmd" forall l r. opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -Here, 'opSubDmdInl' will not be picked as the loop-breaker and thus inline into -'lubSubDmd' and 'opSubDmd'. Since the latter will never inline, we'll specialise -all call sites of 'opSubDmd' for the proper op mode. A nice trick! --} - -data LubOrPlus = Lub | Plus deriving Show -instance Outputable LubOrPlus where ppr = text . show - --- | Determines whether to use 'LubOrPlus' for lower bounds and upper bounds, --- respectively. See Note [Manual specialisation of lub*Dmd/plus*Dmd]. -type OpMode = (LubOrPlus, LubOrPlus) +multSubDmd :: Card -> SubDemand -> SubDemand +multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod +-- The following three equations don't have an impact on Demands, only on +-- Boxity. They are needed so that we don't trigger the assertions in `:*` +-- when called from `multDmd`. +multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` +multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` +multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality +multSubDmd n (Poly b m) = Poly b (multCard n m) +multSubDmd n (Call n' sd) = mkCall (multCard n n') sd +multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) --- | Denotes '∪' on 'SubDemand'. -lubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubSubDmd l r = opSubDmdInl (Lub, Lub) l r +lazifyIfStrict :: Card -> SubDemand -> SubDemand +lazifyIfStrict n sd = multSubDmd (glbCard C_01 n) sd -- | Denotes '∪' on 'Demand'. lubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubDmd l r = opDmdInl (Lub, Lub) l r +lubDmd BotDmd dmd2 = dmd2 +lubDmd dmd1 BotDmd = dmd1 +lubDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "lubDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + lubCard n1 n2 :* lubSubDmd sd1 sd2 --- | Denotes '+' on 'SubDemand'. -plusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusSubDmd l r = opSubDmdInl (Plus, Plus) l r +lubSubDmd :: SubDemand -> SubDemand -> SubDemand +-- Shortcuts for neutral and absorbing elements. +-- Below we assume that Boxed always wins. +lubSubDmd (Poly Unboxed C_10) sd = sd +lubSubDmd sd (Poly Unboxed C_10) = sd +lubSubDmd sd@(Poly Boxed C_0N) _ = sd +lubSubDmd _ sd@(Poly Boxed C_0N) = sd +-- Handle Prod +lubSubDmd (Prod b1 ds1) (Poly b2 n2) + | let !d = polyFieldDmd b2 n2 + = mkProd (lubBoxity b1 b2) (strictMap (lubDmd d) ds1) +lubSubDmd (Prod b1 ds1) (Prod b2 ds2) + | equalLength ds1 ds2 + = mkProd (lubBoxity b1 b2) (strictZipWith lubDmd ds1 ds2) +-- Handle Call +lubSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (lubCard n1 n2) (lubSubDmd sd1 sd2) +-- Handle Poly +lubSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (lubCard n1 n2) +-- Other Poly case by commutativity +lubSubDmd sd1 at Poly{} sd2 = lubSubDmd sd2 sd1 +-- Otherwise (Call `lub` Prod) return Top +lubSubDmd _ _ = topSubDmd -- | Denotes '+' on 'Demand'. plusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusDmd l r = opDmdInl (Plus, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -lubPlusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusSubDmd l r = opSubDmdInl (Lub, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'Demand'. -lubPlusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusDmd l r = opDmdInl (Lub, Plus) l r - --- | Denotes '+' on lower bounds and '∪' on upper bounds on 'SubDemand'. -plusLubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubSubDmd l r = opSubDmdInl (Plus, Lub) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -plusLubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubDmd l r = opDmdInl (Plus, Lub) l r - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -{-# RULES "lubDmd" opDmd (Lub, Lub) = lubDmd #-} -{-# RULES "plusSubDmd" opSubDmd (Plus, Plus) = plusSubDmd #-} -{-# RULES "plusDmd" opDmd (Plus, Plus) = plusDmd #-} -{-# RULES "lubPlusSubDmd" opSubDmd (Lub, Plus) = lubPlusSubDmd #-} -{-# RULES "lubPlusDmd" opDmd (Lub, Plus) = lubPlusDmd #-} -{-# RULES "plusLubSubDmd" opSubDmd (Plus, Lub) = plusLubSubDmd #-} -{-# RULES "plusLubDmd" opDmd (Plus, Lub) = plusLubDmd #-} - --- --- And now the actual implementation that is to be specialised: --- +plusDmd AbsDmd dmd2 = dmd2 +plusDmd dmd1 AbsDmd = dmd1 +plusDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "plusDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + -- Why lazify? See Note [SubDemand denotes at least one evaluation] + -- and also Note [Unrealised opportunity in plusDmd] which applies when both + -- n1 and n2 are lazy already + plusCard n1 n2 :* plusSubDmd (lazifyIfStrict n1 sd1) (lazifyIfStrict n2 sd2) -neutralCard :: OpMode -> Card -neutralCard (Lub, _) = C_10 -neutralCard (Plus, _) = C_00 -{-# INLINE neutralCard #-} - -absorbingCard :: OpMode -> Card -absorbingCard (Lub, _) = C_0N -absorbingCard (Plus, _) = C_1N -{-# INLINE absorbingCard #-} - -opCard :: OpMode -> Card -> Card -> Card -opCard (Lub, Lub) = lubCard -opCard (Lub, Plus) = lubPlusCard -opCard (Plus, Lub) = plusLubCard -opCard (Plus, Plus) = plusCard -{-# INLINE opCard #-} - -opDmdInl, opDmd :: OpMode -> Demand -> Demand -> Demand -opDmdInl m (n1 :* _) dmd2 | n1 == neutralCard m = dmd2 -opDmdInl m dmd1 (n2 :* _) | n2 == neutralCard m = dmd1 -opDmdInl m@(l,u) (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "opDmd" (\it -> ppr l <+> ppr u $$ ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ - opCard m n1 n2 :* case l of - Lub -> opSubDmd m sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, u) sd1 sd2 -- (D1) - (True, False) -> opSubDmd (Plus, u) sd1 (lazifySubDmd sd2) -- (D2) - (False, True) -> opSubDmd (Plus, u) (lazifySubDmd sd1) sd2 -- (D2) - (False, False) -> opSubDmd (Lub, u) sd1 sd2 -- (D3) - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opDmd = opDmdInl -{-# INLINE opDmdInl #-} -{-# NOINLINE opDmd #-} - -opSubDmdInl, opSubDmd :: OpMode -> SubDemand -> SubDemand -> SubDemand +plusSubDmd :: SubDemand -> SubDemand -> SubDemand -- Shortcuts for neutral and absorbing elements. -- Below we assume that Boxed always wins. -opSubDmdInl m (Poly Unboxed n) sd | n == neutralCard m = sd -opSubDmdInl m sd (Poly Unboxed n) | n == neutralCard m = sd -opSubDmdInl m sd@(Poly Boxed n) _ | n == absorbingCard m = sd -opSubDmdInl m _ sd@(Poly Boxed n) | n == absorbingCard m = sd +plusSubDmd (Poly Unboxed C_00) sd = sd +plusSubDmd sd (Poly Unboxed C_00) = sd +plusSubDmd sd@(Poly Boxed C_1N) _ = sd +plusSubDmd _ sd@(Poly Boxed C_1N) = sd -- Handle Prod -opSubDmdInl m (Prod b1 ds1) (Poly b2 n2) +plusSubDmd (Prod b1 ds1) (Poly b2 n2) | let !d = polyFieldDmd b2 n2 - = mkProd (lubBoxity b1 b2) (strictMap (opDmd m d) ds1) -opSubDmdInl m (Prod b1 ds1) (Prod b2 ds2) + = mkProd (lubBoxity b1 b2) (strictMap (plusDmd d) ds1) +plusSubDmd (Prod b1 ds1) (Prod b2 ds2) | equalLength ds1 ds2 - = mkProd (lubBoxity b1 b2) (strictZipWith (opDmd m) ds1 ds2) + = mkProd (lubBoxity b1 b2) (strictZipWith plusDmd ds1 ds2) -- Handle Call -opSubDmdInl m@(l, _) (Call n1 sd1) (viewCall -> Just (n2, sd2)) = - mkCall (opCard m n1 n2) $! case l of - Lub -> opSubDmd (Lub, Lub) sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]. Usage is always lubbed: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, Lub) sd1 sd2 -- (C3) - (False, True) -> opSubDmd (Plus, Lub) (lazifySubDmd sd1) sd2 -- (C2) - (True, False) -> opSubDmd (Plus, Lub) sd1 (lazifySubDmd sd2) -- (C2) - (False, False) -> opSubDmd (Lub, Lub) sd1 sd2 -- (C1) +plusSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (plusCard n1 n2) (lubSubDmd sd1 sd2) -- Handle Poly -opSubDmdInl m (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (opCard m n1 n2) +plusSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (plusCard n1 n2) -- Other Poly case by commutativity -opSubDmdInl m sd1 at Poly{} sd2 = opSubDmd m sd2 sd1 --- Otherwise (Call `op` Prod) return Top -opSubDmdInl _ _ _ = topSubDmd - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opSubDmd = opSubDmdInl -{-# INLINE opSubDmdInl #-} -{-# NOINLINE opSubDmd #-} +plusSubDmd sd1 at Poly{} sd2 = plusSubDmd sd2 sd1 +-- Otherwise (Call `plus` Prod) return Top +plusSubDmd _ _ = topSubDmd -- | Used to suppress pretty-printing of an uninformative demand isTopDmd :: Demand -> Bool @@ -1129,11 +1017,6 @@ strictifyDictDmd _ dmd = dmd lazifyDmd :: Demand -> Demand lazifyDmd = multDmd C_01 - --- | Make a 'SubDemand' lazy. -lazifySubDmd :: SubDemand -> SubDemand -lazifySubDmd = multSubDmd C_01 - -- | Wraps the 'SubDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCalledOnceDmd :: SubDemand -> SubDemand mkCalledOnceDmd sd = mkCall C_11 sd @@ -1166,7 +1049,7 @@ subDemandIfEvaluated (_ :* sd) = sd mkWorkerDemand :: Int -> Demand mkWorkerDemand n = C_01 :* go n where go 0 = topSubDmd - go n = Call C_01 $ go (n-1) + go n = mkCall C_01 $ go (n-1) argsOneShots :: DmdSig -> Arity -> [[OneShotInfo]] -- ^ See Note [Computing one-shot info] @@ -1242,22 +1125,24 @@ NB: The Premise only makes a difference for lower bounds/strictness. Upper bounds/usage are unaffected by adding or leaving out evaluations that never happen. -So if `x` was demanded with `LP(1L)`, so perhaps `` was - f1 x = (x `seq` case x of (a,b) -> a, True) -then `x` will be evaluated lazily, but any time `x` is evaluated, `e` is -evaluated with sub-demand `P(1L)`, e.g., the first field of `e` is evaluated -strictly, too. - -How does the additional strictness help? The long version is in #21081. +The Premise comes into play when we have lazy Demands. For example, if `x` was +demanded with `LP(SL,A)`, so perhaps the full expression was + let x = (e1, e2) in (x `seq` fun y `seq` case x of (a,b) -> a, True) +then `x` will be evaluated lazily, but in any trace in which `x` is evaluated, +the pair in its RHS will ultimately be evaluated deeply with sub-demand +`P(SL,A)`. That means that `e1` is ultimately evaluated strictly, even though +evaluation of the field does not directly follow the eval of `x` due to the +intermittent call `fun y`. + +How does the additional strictness help? The long version is the list of +examples at the end of this Note (as procured in #21081 and #18903). The short version is - * We get to take advantage of call-by-value/let-to-case in more situations. - See example "More let-to-case" below. + * We get to take advantage of call-by-value/let-to-case in more situations, + as for e1 above. See example "More let-to-case" below. * Note [Eta reduction based on evaluation context] applies in more situations. See example "More eta reduction" below. * We get to unbox more results, see example "More CPR" below. - * We prevent annoying issues with `Poly` equalities, #21085. In short, we'd get - `L + S = S = CS(S) < CS(L) = C(L+S)(LuS) = L + CS(S)` although `S = CS(S)`. It seems like we don't give up anything in return. Indeed that is the case: @@ -1271,47 +1156,26 @@ It seems like we don't give up anything in return. Indeed that is the case: well as when expanding absent 'Poly's to 'Call' sub-demands in 'viewCall'. Of course, we now have to maintain the Premise when we unpack and rebuild -SubDemands. For strict demands, we know that the Premise indeed always holds for +Demands. For strict demands, we know that the Premise indeed always holds for any program trace abstracted over, whereas we have to be careful for lazy demands. -That makes for a strange definition of `plusDmd`, where we use `plusSubDmd` -throughout for upper bounds (every eval returns the same, memoised heap object), -but what we do on lower bounds depends on the strictness of both arguments: - - D1 `plusSubDmd` on the nested SubDemands if both args are strict. - D2 `plusSubDmd` on the nested SubDemands if one of them is lazy, which we - *lazify* before (that's new), so that e.g. - `LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L)` - Multiplying with `M`/`C_01` is the "lazify" part here. - Example proving that point: - d2 :: - d2 x y = y `seq` (case x of (a,b) -> a, True) - -- What is demand on x in (d2 x x)? NOT SP(SL)!! - D3 `lubPlusSubDmd` on the nested SubDemands if both args are lazy. - This new operation combines `lubSubDmd` on lower bounds with `plusSubDmd` - on upper bounds. - Examples proving that point: - d3 :: - d3 x y = (case x of (a,b) -> a, y `seq` ()) - -- What is demand on x in `snd (d3 x x)`? - -- Not LP(SL)!! d3 might evaluate second argument but not first. - -- Lub lower bounds because we might evaluate one OR the other. - -Similarly, in the handling of Call SubDemands `Cn(sd)` in `plusSubDmd`, we use -`lub` for upper bounds (because every call returns a fresh heap object), but -what we do for lower bounds depends on whether the outer `n`s are strict: - - C1 `lubSubDmd` on the nested SubDemands if both args are lazy. - C2 `plusLubSubDmd` on the nested `sd`s if one of the `n`s is lazy. That one's - nested `sd` we *lazify*, so that e.g. - `CL(SL) + CS(L) = C(L+S)((M*SL)+L) = CS(L+L) = CS(L)` - `plusLubSubDmd` combines `plusSubDmd` on lower bounds with `lubSubDmd` on - upper bounds. - C3 `plusLubSubDmd` on the nested SubDemands if both args are strict. - -There are a couple of other examples in T21081. -Here is a selection of examples demonstrating the -usefulness of The Premise: + +In particular, when doing `plusDmd` we have to *lazify* the nested SubDemand +if the outer cardinality is lazy. E.g., + LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L) +Multiplying with `M`/`C_01` is the "lazify" part here and is implemented in +`lazifyIfStrict`. Example proving that point: + d2 :: + d2 x y = y `seq` (case x of (a,b) -> a, True) + -- What is the demand on x in (d2 x x)? NOT SP(SL)!! + +We used to apply the same reasoning to Call SubDemands `Cn(sd)` in `plusSubDmd`, +but that led to #21717, because different calls return different heap objects. +See Note [Call SubDemand vs. evaluation Demand]. + +There are a couple more examples that improve in T21081. +Here is a selection of those examples demonstrating the usefulness of The +Premise: * "More let-to-case" (from testcase T21081): ```hs @@ -1355,6 +1219,102 @@ usefulness of The Premise: pair. That in turn means that Nested CPR can unbox the result of the division even though it might throw. +Note [Unrealised opportunity in plusDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Recall the lazification of SubDemands happening in `plusDmd` as described in +Note [SubDemand denotes at least one evaluation]. + +We *could* do better when both Demands are lazy already. Example + (fun 1, fun 2) +Both args put Demand SCS(L) on `fun`. The lazy pair arg context lazifies +this to LCS(L), and it would be reasonable to report this Demand on `fun` for +the entire pair expression; after all, `fun` is called whenever it is evaluated. +But our definition of `plusDmd` will compute + LCS(L) + LCS(L) = (L+L)(M*CS(L) + M*CS(L)) = L(CL(L)) = L +Which is clearly less precise. +Doing better here could mean to `lub` when both demands are lazy, e.g., + LCS(L) + LCS(L) = (L+L)(CS(L) ⊔ CS(L)) = L(CS(L)) +Indeed that's what we did at one point between 9.4 and 9.6 after !7599, but it +means that we need a function `lubPlusSubDmd` that lubs on lower bounds but +plus'es upper bounds, implying maintenance challenges and complicated +explanations. + +Plus, NoFib says that this special case doesn't bring all that much +(geom. mean +0.0% counted instructions), so we don't bother anymore. + +Note [Call SubDemand vs. evaluation Demand] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Although both evaluation Demands and Call SubDemands carry a (Card,SubDemand) +pair, their interpretation is quite different. Example: + + f x = fst x * snd x + -- f :: , because 1P(1L,A)+1P(A,1L) = SP(1L,1L) + g x = fst (x 1) * snd (x 2) + -- g :: , because 1C1(P(1L,A))+1C1(P(A,1L)) = SCS(P(ML,ML)) + +The point about this example is that both demands have P(A,1L)/P(1L,A) as +sub-expressions, but when these sub-demands occur + + 1. under an evaluation demand, we combine with `plusSubDmd` + 2. whereas under a Call sub-demand, we combine with `lubSubDmd` + +And thus (1) yields a stricter demand on the pair components than (2). + +In #21717 we saw that we really need lub in (2), because otherwise we make an +unsound prediction in `g (\n -> if n == 1 then (1,1) else (bot,2))`; we'd say +that the `bot` expression is always evaluated, when it clearly is not. +Operationally, every call to `g` gives back a potentially distinct, +heap-allocated pair with potentially different contents, and we must `lubSubDmd` +over all such calls to approximate how any of those pairs might be used. + +That is in stark contrast to f's argument `x`: Operationally, every eval of +`x` must yield the same pair and `f` evaluates both components of that pair. +The theorem "every eval of `x` returns the same heap object" is a very strong +MUST-alias property and we capitalise on that by using `plusSubDmd` in (1). + +And indeed we *must* use `plusSubDmd` in (1) for sound upper bounds in an +analysis that assumes call-by-need (as opposed to the weaker call-by-name) for +let bindings. Consider + + h x = fst x * fst x + -- h :: + +And the expression `let a=1; p=(a,a)} in h p`. Here, *although* the RHS of `p` +is only evaluated once under call-by-need, `a` is still evaluated twice. +If we had used `lubSubDmd`, we'd see SP(1L,A) and the 1L unsoundly says "exactly +once". + +If the analysis had assumed call-by-name, it would be sound to say "a is used +once in p": p is used multiple times and hence so would a, as if p was a +function. So using `plusSubDmd` does not only yield better strictness, it is +also "holding up the other end of the bargain" of the call-by-need assumption +for upper bounds. + +(To SG's knowledge, the distinction between call-by-name and call-by-need does +not matter for strictness analysis/lower bounds, thus it would be sound to use +`lubSubDmd` all the time there.) + +Note [mkCall and plusSubDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We never rewrite a strict, non-absent Call sub-demand like CS(S) to a +polymorphic sub-demand like S, otherwise #21085 strikes. Consider the +following inequality (would also for M and 1 instead of L and S, but we forbid +such Polys): + + L+S = S = CS(S) < CS(L) = CL(L)+CS(S) + +Note that L=CL(L). If we also had S=CS(S), we'd be in trouble: Now +`plusSubDmd` would no longer maintain the equality relation on sub-demands, +much less monotonicity. Bad! + +Clearly, `n <= Cn(n)` is unproblematic, as is `n >= Cn(n)` for any `n` +except 1 and S. But `CS(S) >= S` would mean trouble, because then we'd get +the problematic `CS(S) = S`. We have just established that `S < CS(S)`! +As such, the rewrite CS(S) to S is anti-monotone and we forbid it, first +and foremost in `mkCall` (which is the only place that rewrites Cn(n) to n). + +Crisis and #21085 averted! + Note [Computing one-shot info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a call @@ -2102,7 +2062,7 @@ If this same function is applied to one arg, all we can say is that it uses x with 1L, and its arg with demand 1P(L,L). Note [Understanding DmdType and DmdSig] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Demand types are sound approximations of an expression's semantics relative to the incoming demand we put the expression under. Consider the following expression: ===================================== testsuite/tests/arityanal/should_compile/Arity11.stderr ===================================== @@ -53,7 +53,7 @@ F11.fib1 = GHC.Num.Integer.IS 0# -- RHS size: {terms: 52, types: 26, coercions: 0, joins: 0/5} F11.$wfib [InlPrag=[2]] :: forall {t} {a}. (t -> t -> Bool) -> (Num t, Num a) => t -> a -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] F11.$wfib = \ (@t) (@a) (ww :: t -> t -> Bool) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> let { @@ -91,7 +91,7 @@ F11.$wfib fib [InlPrag=[2]] :: forall {t} {a}. (Eq t, Num t, Num a) => t -> a [GblId, Arity=4, - Str=<1P(SCS(C1(L)),A)>, + Str=<1P(SCS(C1(L)),A)>, 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= \ (@t) (@a) ($dEq [Occ=Once1!] :: Eq t) ($dNum [Occ=Once1] :: Num t) ($dNum1 [Occ=Once1] :: Num a) (eta [Occ=Once1] :: t) -> case $dEq of { GHC.Classes.C:Eq ww [Occ=Once1] _ [Occ=Dead] -> F11.$wfib @t @a ww $dNum $dNum1 eta }}] fib = \ (@t) (@a) ($dEq :: Eq t) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> case $dEq of { GHC.Classes.C:Eq ww ww1 -> F11.$wfib @t @a ww $dNum $dNum1 eta } @@ -142,4 +142,7 @@ f11 :: (Integer, Integer) f11 = (F11.f4, F11.f1) +------ Local rules for imported ids -------- +"SPEC fib @Integer @Integer" forall ($dEq :: Eq Integer) ($dNum :: Num Integer) ($dNum1 :: Num Integer). fib @Integer @Integer $dEq $dNum $dNum1 = F11.f11_fib + ===================================== testsuite/tests/arityanal/should_compile/Arity14.stderr ===================================== @@ -14,7 +14,7 @@ F14.f2 = GHC.Num.Integer.IS 1# -- RHS size: {terms: 35, types: 23, coercions: 0, joins: 0/3} F14.$wf14 [InlPrag=[2]] :: forall {t}. (t -> t -> Bool) -> Num t => t -> t -> t -> t -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] F14.$wf14 = \ (@t) (ww :: t -> t -> Bool) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> let { @@ -41,7 +41,7 @@ F14.$wf14 f14 [InlPrag=[2]] :: forall {t}. (Ord t, Num t) => t -> t -> t -> t [GblId, Arity=4, - Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, + Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, 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= \ (@t) ($dOrd [Occ=Once1!] :: Ord t) ($dNum [Occ=Once1] :: Num t) (eta [Occ=Once1] :: t) (eta1 [Occ=Once1] :: t) -> case $dOrd of { GHC.Classes.C:Ord _ [Occ=Dead] _ [Occ=Dead] ww2 [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> F14.$wf14 @t ww2 $dNum eta eta1 }}] f14 = \ (@t) ($dOrd :: Ord t) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> case $dOrd of { GHC.Classes.C:Ord ww ww1 ww2 ww3 ww4 ww5 ww6 ww7 -> F14.$wf14 @t ww2 $dNum eta eta1 } ===================================== testsuite/tests/arityanal/should_compile/Arity16.stderr ===================================== @@ -5,7 +5,7 @@ Result size of Tidy Core = {terms: 53, types: 71, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 15, types: 15, coercions: 0, joins: 0/0} map2 [Occ=LoopBreaker] :: forall {t} {a}. (t -> a) -> [t] -> [a] -[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] map2 = \ (@t) (@a) (f :: t -> a) (ds :: [t]) -> case ds of { @@ -27,7 +27,7 @@ lvl1 = Control.Exception.Base.patError @GHC.Types.LiftedRep @() lvl Rec { -- RHS size: {terms: 31, types: 32, coercions: 0, joins: 0/0} zipWith2 [Occ=LoopBreaker] :: forall {t1} {t2} {a}. (t1 -> t2 -> a) -> [t1] -> [t2] -> [a] -[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] zipWith2 = \ (@t) (@t1) (@a) (f :: t -> t1 -> a) (ds :: [t]) (ds1 :: [t1]) -> case ds of { ===================================== testsuite/tests/simplCore/should_compile/T21261.hs ===================================== @@ -34,18 +34,26 @@ f5 c = Just (c 1 2 + c 3 4) yes2_lazy :: (Int -> Int -> Int) -> Maybe Int yes2_lazy c = f5 (\x y -> c x y) --- These last two here are disallowed in T21261_pedantic.hs, which activates --- -fpedantic-bottoms. It would be unsound to eta reduce these bindings with --- -fpedantic-bottoms, but without it's fine to eta reduce: +-- These last two here are tricky. It is unsound to eta reduce +-- the args to f6 and f7 because we could call both functions +-- at a c like `\x -> if x == 1 then undefined else id`. +-- Note that if we do so and *do* eta-reduce, we'll see a crash! +-- Whereas we *don't* see a crash if we keep the original, +-- eta-expanded arguments. +-- +-- This is issue is discussed in Note [Eta reduction soundness], condition (S). +-- +-- This is a variant of #21717 (and tested by T21717), where +-- prior to the fix we observed an unsound strictness signature. f6 :: (Int -> Int -> Int) -> Int f6 c = c 1 `seq` c 2 3 {-# NOINLINE f6 #-} -yes_non_pedantic :: (Int -> Int -> Int) -> Int -yes_non_pedantic c = f6 (\x y -> c x y) +no_tricky :: (Int -> Int -> Int) -> Int +no_tricky c = f6 (\x y -> c x y) f7 :: (Int -> Int -> Int) -> Maybe Int f7 c = Just (c 1 `seq` c 3 4) {-# NOINLINE f7 #-} -yes_non_pedantic_lazy :: (Int -> Int -> Int) -> Maybe Int -yes_non_pedantic_lazy c = f7 (\x y -> c x y) +no_tricky_lazy :: (Int -> Int -> Int) -> Maybe Int +no_tricky_lazy c = f7 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 166, types: 176, coercions: 0, joins: 0/0} + = {terms: 182, types: 191, coercions: 0, joins: 0/0} lvl = I# 3# @@ -29,13 +29,14 @@ no3 f6 = \ c -> case c lvl2 of { __DEFAULT -> c lvl3 lvl } -yes_non_pedantic = f6 +no_tricky = \ c -> f6 (\ x y -> c x y) $wf7 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl lvl1 } #) f7 = \ c -> case $wf7 c of { (# ww #) -> Just ww } -yes_non_pedantic_lazy = f7 +no_tricky_lazy + = \ c -> case $wf7 (\ x y -> c x y) of { (# ww #) -> Just ww } $wf5 = \ c -> ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.hs deleted ===================================== @@ -1,18 +0,0 @@ -{-# OPTIONS_GHC -fpedantic-bottoms #-} -- This flag must inhibit eta reduction based on demands - -module T21261_pedantic where - --- README: See T21261. These examples absolutely should not eta reduce with --- -fpedantic-bottoms. - -f1 :: (Int -> Int -> Int) -> Int -f1 c = c 1 `seq` c 2 3 -{-# NOINLINE f1 #-} -no2 :: (Int -> Int -> Int) -> Int -no2 c = f1 (\x y -> c x y) - -f2 :: (Int -> Int -> Int) -> Maybe Int -f2 c = Just (c 1 `seq` c 3 4) -{-# NOINLINE f2 #-} -no2_lazy :: (Int -> Int -> Int) -> Maybe Int -no2_lazy c = f2 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr deleted ===================================== @@ -1,26 +0,0 @@ - -==================== Tidy Core ==================== -Result size of Tidy Core - = {terms: 59, types: 63, coercions: 0, joins: 0/0} - -lvl = I# 2# - -lvl1 = I# 3# - -lvl2 = I# 1# - -f1 = \ c -> case c lvl2 of { __DEFAULT -> c lvl lvl1 } - -no2 = \ c -> f1 (\ x y -> c x y) - -lvl3 = I# 4# - -$wf2 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl1 lvl3 } #) - -f2 = \ c -> case $wf2 c of { (# ww #) -> Just ww } - -no2_lazy - = \ c -> case $wf2 (\ x y -> c x y) of { (# ww #) -> Just ww } - - - ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -407,8 +407,7 @@ test('T21144', normal, compile, ['-O']) test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. -test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) -test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # We expect to see a SPEC rule for $cm test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/stranal/should_compile/T18894.stderr ===================================== @@ -147,7 +147,7 @@ lvl :: (Int, Int) lvl = (lvl, lvl) -- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} -g1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] :: Int -> (Int, Int) +g1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: Int -> (Int, Int) [LclId, Arity=1, Str=<1!P(1L)>, @@ -266,7 +266,7 @@ lvl = GHC.Types.I# 0# -- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} $wg2 [InlPrag=NOINLINE, Dmd=LCS(C1(!P(M!P(L),1!P(L))))] :: Int -> GHC.Prim.Int# -> (# Int, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -328,9 +328,9 @@ h2 } -- RHS size: {terms: 34, types: 14, coercions: 0, joins: 0/1} -$wg1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] +$wg1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -367,7 +367,7 @@ lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} $wh1 [InlPrag=[2], Dmd=LCS(!P(L))] :: GHC.Prim.Int# -> Int -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, ===================================== testsuite/tests/stranal/should_run/T21717b.hs ===================================== @@ -0,0 +1,19 @@ +import System.Environment +import GHC.Exts + +g :: (Int -> (Int, Int)) -> Int +-- Should *not* infer strictness SCS(P(SL,SL)) for h +-- Otherwise `main` could use CbV on the error exprs below +g h = fst (h 0) + snd (h 1) +{-# NOINLINE g #-} + +main = do + m <- length <$> getArgs + -- The point here is that we print "1". + -- That means we may *not* use CbV/let-to-case on err! + -- GHC.Exts.lazy so that we don't lambda lift and float out the + -- obviously bottoming RHS (where it is no longer used strictly). + let err = GHC.Exts.lazy $ error (show m) + let f n | even n = (n+m, err) + | otherwise = (err, n+m) + print $! g f ===================================== testsuite/tests/stranal/should_run/T21717b.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/stranal/should_run/all.T ===================================== @@ -27,3 +27,4 @@ test('T14290', normal, compile_and_run, ['']) test('T14285', normal, multimod_compile_and_run, ['T14285', '']) test('T17676', normal, compile_and_run, ['']) test('T19053', normal, compile_and_run, ['']) +test('T21717b', normal, compile_and_run, ['']) ===================================== testsuite/tests/stranal/sigs/T20746.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -Foo.f: +Foo.f: Foo.foogle: ===================================== testsuite/tests/stranal/sigs/T21081.stderr ===================================== @@ -4,7 +4,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: T21081.blurg2: T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: @@ -50,7 +50,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: <1!P(SL)> T21081.blurg2: <1!P(SL)> T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: ===================================== testsuite/tests/stranal/sigs/T21119.stderr ===================================== @@ -4,7 +4,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x @@ -24,7 +24,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x ===================================== testsuite/tests/stranal/sigs/T21717.hs ===================================== @@ -0,0 +1,12 @@ +module T21717 (g) where + +-- This is the original reproducer from #21717. +-- See T21717b for a reproducer that exhibited a crash. + +f :: Bool -> (Int, Int) +f True = (42,error "m") +f False = (error "m",42) + +g :: (Bool -> (Int, Int)) -> Int +g h = fst (h True) + snd (h False) +{-# NOINLINE g #-} ===================================== testsuite/tests/stranal/sigs/T21717.stderr ===================================== @@ -0,0 +1,15 @@ + +==================== Strictness signatures ==================== +T21717.g: + + + +==================== Cpr signatures ==================== +T21717.g: 1 + + + +==================== Strictness signatures ==================== +T21717.g: + + ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -T5075.f: +T5075.f: T5075.g: <1L> T5075.h: @@ -14,7 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> +T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> T5075.g: <1L> T5075.h: <1!P(L)> ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -33,5 +33,6 @@ test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) +test('T21717', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeafdba5503b8d26a62dc7bc7078caef170d4154 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeafdba5503b8d26a62dc7bc7078caef170d4154 You're receiving 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 Sep 27 13:45:22 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 09:45:22 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <6332fe7220b82_2c975753ffac4115d6@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 68e0f310 by Andreas Klebinger at 2022-09-27T15:44:14+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,187 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. +-} + +module GHC.Builtin.PrimOps.Casts 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) + +-- from - to +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | 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 = wordOrIntToAddrRep from_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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,75 @@ 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +761,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 +776,52 @@ 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 + -- mapAccumLM (acc -> x -> m (acc, y)) acc ([x]) + ((_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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +932,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 +954,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68e0f31028ff0ec3ce01de41b6ed981a23998e01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68e0f31028ff0ec3ce01de41b6ed981a23998e01 You're receiving 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 Sep 27 13:45:46 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 09:45:46 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <6332fe8a61357_2c975751400412023@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 2b791cf0 by Andreas Klebinger at 2022-09-27T15:44:38+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,187 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. +-} + +module GHC.Builtin.PrimOps.Casts 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) + +-- from - to +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | 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 = wordOrIntToAddrRep from_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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,75 @@ 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +761,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 +776,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +931,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 +953,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b791cf0ef066a3ef34db79c41a2e7945f42779b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b791cf0ef066a3ef34db79c41a2e7945f42779b You're receiving 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 Sep 27 14:35:36 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 27 Sep 2022 10:35:36 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Minor refactoring Message-ID: <63330a38b36f3_2c9757514644219ee@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: a86cc1d4 by Sylvain Henry at 2022-09-27T15:13:31+02:00 Minor refactoring - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} #include @@ -355,34 +356,38 @@ runJsPhase pipe_env hsc_env input_fn = do let unit_env = hsc_unit_env hsc_env output_fn <- phaseOutputFilenameNew StopLn pipe_env hsc_env Nothing - need_cpp <- jsFileNeedsCpp input_fn - tmp_fn <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js" - - -- the header lets the linker recognize processed JavaScript files - -- But don't add JavaScript header to object files! - is_js_obj <- isJsObjectFile input_fn - let header - | is_js_obj = "" - | otherwise = "//JavaScript\n" -- if the input filename is the same as the output, then we've probably -- generated the object ourselves, we leave the file alone when (input_fn /= output_fn) $ do - if need_cpp - then do - doCpp logger - tmpfs - dflags - unit_env - (CppOpts - { cppUseCc = True - , cppLinePragmas = False - }) - [] - input_fn - tmp_fn - copyWithHeader header tmp_fn output_fn - else copyWithHeader header input_fn output_fn + + -- the header lets the linker recognize processed JavaScript files + -- But don't add JavaScript header to object files! + is_js_obj <- isJsObjectFile input_fn + + if is_js_obj + then copyWithHeader "" input_fn output_fn + else do + -- header appended to JS files stored as .o to recognize them. + let header = "//JavaScript\n" + jsFileNeedsCpp input_fn >>= \case + False -> copyWithHeader header input_fn output_fn + True -> do + -- run CPP on the input JS file + tmp_fn <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js" + doCpp logger + tmpfs + dflags + unit_env + (CppOpts + { cppUseCc = True + , cppLinePragmas = False + }) + [] + input_fn + tmp_fn + copyWithHeader header tmp_fn output_fn + return output_fn jsFileNeedsCpp :: FilePath -> IO Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a86cc1d4cc7bedf8650e8ddcad536d834655be7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a86cc1d4cc7bedf8650e8ddcad536d834655be7a You're receiving 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 Sep 27 14:36:15 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 27 Sep 2022 10:36:15 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Temporary fix the testsuite bug Message-ID: <63330a5fed573_2c975751464422372@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 82bc5ad5 by Sylvain Henry at 2022-09-27T16:39:16+02:00 Temporary fix the testsuite bug - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -363,7 +363,13 @@ runJsPhase pipe_env hsc_env input_fn = do -- the header lets the linker recognize processed JavaScript files -- But don't add JavaScript header to object files! - is_js_obj <- isJsObjectFile input_fn + + is_js_obj <- if True + then pure False + else isJsObjectFile input_fn + -- FIXME (Sylvain 2022-09): this call makes the + -- testsuite go into a loop, I don't know why yet! + -- Disabling it for now. if is_js_obj then copyWithHeader "" input_fn output_fn View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82bc5ad58df4f8eac6c288cc645682e468ce6036 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/82bc5ad58df4f8eac6c288cc645682e468ce6036 You're receiving 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 Sep 27 14:51:12 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 10:51:12 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63330de0f0d55_2c97575140042761b@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 1bb9f5d2 by Andreas Klebinger at 2022-09-27T16:50:06+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,206 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 + | 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 = wordOrIntToAddrRep from_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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,75 @@ 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +761,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 +776,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +931,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 +953,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bb9f5d25c8c5c31e6bb538efe17dc63da050c1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bb9f5d25c8c5c31e6bb538efe17dc63da050c1f You're receiving 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 Sep 27 15:13:01 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 11:13:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-jsem Message-ID: <633312fd23277_2c9757514644321ab@gitlab.mail> Matthew Pickering pushed new branch wip/hadrian-jsem at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-jsem You're receiving 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 Sep 27 15:21:21 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 27 Sep 2022 11:21:21 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Update filepath to filepath-1.4.100.0 Message-ID: <633314f15fe0d_2c97575143c4333dc@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job 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. - - - - - cc387800 by Ross Paterson at 2022-09-27T11:21:12-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - 30 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/TyThing.hs - compiler/GHC/Unit/Types.hs-boot - compiler/GHC/Utils/Outputable.hs - − compiler/GHC/Utils/Outputable.hs-boot - compiler/Language/Haskell/Syntax/Decls.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4691807a9826e21f3e1b3bcd0e6b83fc5a8cb0cd...cc3878008b0adf15264386347638421c9b5168ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4691807a9826e21f3e1b3bcd0e6b83fc5a8cb0cd...cc3878008b0adf15264386347638421c9b5168ab You're receiving 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 Sep 27 15:24:16 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 11:24:16 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <633315a044a79_2c9757514644390dd@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 4f859687 by Andreas Klebinger at 2022-09-27T17:23:14+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,206 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 + | 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 from_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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,75 @@ 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +761,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 +776,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +931,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 +953,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f859687ee1fcecf6cdae66dd25a15b4f168128a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f859687ee1fcecf6cdae66dd25a15b4f168128a You're receiving 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 Sep 27 15:33:38 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 11:33:38 -0400 Subject: [Git][ghc/ghc][wip/T21470] 58 commits: Add native delimited continuations to the RTS Message-ID: <633317d282c32_2c97575140044196e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - d5c07d40 by Simon Peyton Jones at 2022-09-27T14:46:37+01: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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - f7b060e1 by Simon Peyton Jones at 2022-09-27T14:47:20+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/651265b431eacc3c35d001582d4de0eb36b66f74...f7b060e1c6a62da77a6a583816c691d1668fda9e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/651265b431eacc3c35d001582d4de0eb36b66f74...f7b060e1c6a62da77a6a583816c691d1668fda9e You're receiving 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 Sep 27 15:33:46 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 11:33:46 -0400 Subject: [Git][ghc/ghc][wip/T19001] 628 commits: Allow `let` just before pure/return in ApplicativeDo Message-ID: <633317da91c5a_2c97575142844273e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T19001 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 9725dd6d by Simon Peyton Jones at 2022-09-27T14:51:23+01:00 Kill ad hoc Note [Case MFEs] hack See discussion in #19001. I'm keen to kill this hack off. This MR is to check CI and perf. Also enable CaseOfCase in InitialPhase - - - - - 19 changed files: - − .appveyor.sh - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - + .gitlab/upload_ghc_libs.py - − MAKEHELP.md - − Makefile - − appveyor.yml - − bindisttest/ghc.mk - boot - compiler/.hlint.yaml - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ab668fbf5ee583a3663313d842d93ccbaf5cf0e...9725dd6d418cc4fce0d01083fef1a82cf2633283 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ab668fbf5ee583a3663313d842d93ccbaf5cf0e...9725dd6d418cc4fce0d01083fef1a82cf2633283 You're receiving 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 Sep 27 16:04:22 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 12:04:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-multi-repl Message-ID: <63331f0655028_2c975753ffac44759e@gitlab.mail> Matthew Pickering pushed new branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-multi-repl You're receiving 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 Sep 27 16:04:41 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 12:04:41 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] 4 commits: ci: Add job to test hadrian-multi command Message-ID: <63331f1953b1b_2c9757514144479c1@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 7f363bb5 by Matthew Pickering at 2022-09-27T17:04:31+01:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - 4fe1815f by Matthew Pickering at 2022-09-27T17:04:31+01:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - dc1247cb by Matthew Pickering at 2022-09-27T17:04:31+01:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 626ebd0b by Matthew Pickering at 2022-09-27T17:04:31+01:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - 4 changed files: - .gitlab-ci.yml - compiler/GHC/Driver/Make.hs - hadrian/ghci-multi-cabal.in - hadrian/src/Rules/ToolArgs.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -367,6 +367,53 @@ hadrian-ghc-in-ghci: paths: - cabal-cache +############################################################ +# Hadrian Multi-Repl +############################################################ + +hadrian-multi: + needs: + - job: x86_64-linux-fedora33-release + optional: true + - job: nightly-x86_64-linux-fedora33-release + optional: true + - job: release-x86_64-linux-fedora33-release + optional: true + dependencies: null + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + variables: + GHC_FLAGS: -Werror + CONFIGURE_ARGS: --enable-bootstrap-with-devel-snapshot + tags: + - x86_64-linux + script: + - git clean -xdf && git submodule foreach git clean -xdf + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ../ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - export HC=$root/bin/ghc + - export GHC=$root/bin/ghc + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + # Load hadrian-multi then immediately exit and check the modules loaded + - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," + after_script: + - .gitlab/ci.sh save_cache + cache: + key: hadrian-ghci-$CACHE_REV + paths: + - cabal-cache + ############################################################ # stack-hadrian-build ############################################################ ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1162,9 +1162,10 @@ interpretBuildPlan hug mhmi_cache old_hpt plan = do hug_var <- gets hug_var !build_map <- getBuildMap res_var <- liftIO newEmptyMVar - let + let loop_unit :: UnitId + !loop_unit = nodeKeyUnitId (gwib_mod (head deps)) !build_deps = getDependencies (map gwib_mod deps) build_map - let loop_action = do + let loop_action = withCurrentUnit loop_unit $ do (hug, tdeps) <- wait_deps_hug hug_var build_deps hsc_env <- asks hsc_env let new_hsc = setHUG hug hsc_env ===================================== hadrian/ghci-multi-cabal.in ===================================== @@ -10,4 +10,4 @@ export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args # Replace newlines with spaces, as these otherwise break the ghci invocation on windows. CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')" -$GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci_multi/interface -O0 +RTS -A128m +$GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -84,9 +84,11 @@ multiSetup pkg_s = do gens <- interpretInContext c generatedDependencies need (srcs ++ gens) let rexp m = ["-reexported-module", m] + let hidir = root "interfaces" pkgPath p writeFile' (resp_file root p) (intercalate "\n" (th_hack arg_list ++ modules cd - ++ concatMap rexp (reexportModules cd) )) + ++ concatMap rexp (reexportModules cd) + ++ ["-outputdir", hidir])) return (resp_file root p) @@ -151,6 +153,7 @@ toolTargets = [ binary , directory , process , exceptions + , filepath -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/27d19a7b6f9c5e89d570c8f378ea35d025520df4...626ebd0bbb06982b79c2308c6c83dcedb046cb67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/27d19a7b6f9c5e89d570c8f378ea35d025520df4...626ebd0bbb06982b79c2308c6c83dcedb046cb67 You're receiving 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 Sep 27 16:05:38 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 12:05:38 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix Message-ID: <63331f525fc0a_2c97575140045021e@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 9f1da5bf by Matthew Pickering at 2022-09-27T17:05:31+01:00 fix - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -372,6 +372,7 @@ hadrian-ghc-in-ghci: ############################################################ hadrian-multi: + stage: testing needs: - job: x86_64-linux-fedora33-release optional: true View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f1da5bf4e420746f1fec2a238182301bb405aa8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f1da5bf4e420746f1fec2a238182301bb405aa8 You're receiving 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 Sep 27 16:18:41 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 12:18:41 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] Make rewrite rules "win" over inlining Message-ID: <63332261aa4cc_2c9757514284550b5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: c434c0a4 by Simon Peyton Jones at 2022-09-27T17:19:57+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 quite a bit, but the trend is slightly down Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change ------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 4,566,082,536 -25.0% GOOD T10421(normal) ghc/alloc 111,994,304 116,148,544 +3.7% BAD T10421a(normal) ghc/alloc 79,150,034 83,423,664 +5.4% T10547(normal) ghc/alloc 28,211,501 28,177,960 -0.1% T12545(normal) ghc/alloc 1,633,149,272 1,614,005,512 -1.2% T13253(normal) ghc/alloc 343,592,469 347,635,808 +1.2% T14052(ghci) ghc/alloc 3,681,055,512 3,749,063,688 +1.8% T15304(normal) ghc/alloc 1,295,512,578 1,277,067,608 -1.4% T16577(normal) ghc/alloc 8,050,423,421 8,291,093,504 +3.0% BAD T17516(normal) ghc/alloc 1,800,051,592 1,840,575,008 +2.3% T17836(normal) ghc/alloc 829,913,981 812,805,232 -2.1% T17836b(normal) ghc/alloc 45,437,680 45,057,120 -0.8% T18223(normal) ghc/alloc 734,732,288 646,329,352 -12.0% GOOD T3064(normal) ghc/alloc 180,023,717 182,061,608 +1.1% T9630(normal) ghc/alloc 1,523,682,706 1,492,863,632 -2.0% GOOD T9961(normal) ghc/alloc 358,760,821 368,223,992 +2.6% BAD geo. mean -0.3% minimum -25.0% maximum +5.4% Metric Decrease: LargeRecord T18223 T9630 Metric Increase: T10421 T16577 T9961 - - - - - 8 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - testsuite/tests/lib/integer/Makefile - + testsuite/tests/simplCore/should_compile/T21851.hs - + testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851a.hs - testsuite/tests/simplCore/should_compile/T6056.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1919,7 +1919,9 @@ wrapJoinCont env cont thing_inside -------------------- -trimJoinCont :: Id -> Maybe JoinArity -> SimplCont -> SimplCont +trimJoinCont :: Id -- Used only in error message + -> Maybe JoinArity + -> SimplCont -> SimplCont -- Drop outer context from join point invocation (jump) -- See Note [Join points and case-of-case] @@ -2017,6 +2019,17 @@ outside. Surprisingly tricky! Variables * * ************************************************************************ + +Note [zapSubstEnv] +~~~~~~~~~~~~~~~~~~ +When simplifying something that has already been simplified, be sure to +zap the SubstEnv. This is VITAL. Consider + let x = e in + let y = \z -> ...x... in + \ x -> ...y... + +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!! -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2035,86 +2048,28 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont = case substId env var of - ContEx tvs cvs ids e -> - let env' = setSubstEnv env tvs cvs ids - in simplExprF env' e cont - -- Don't trim; haven't already simplified e, - -- so the cont is not embodied in e - - DoneId var1 -> do - logger <- getLogger - let cont' = trimJoinCont var (isJoinId_maybe var1) cont - completeCall logger env var1 cont' - - DoneEx e mb_join -> - let env' = zapSubstEnv env - cont' = trimJoinCont var mb_join cont - in simplExprF env' e cont' - -- Note [zapSubstEnv] - -- ~~~~~~~~~~~~~~~~~~ - -- The template is already simplified, so don't re-substitute. - -- This is VITAL. Consider - -- let x = e in - -- let y = \z -> ...x... in - -- \ x -> ...y... - -- 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!! - ---------------------------------------------------------- --- Dealing with a call site - -completeCall :: Logger -> SimplEnv -> OutId -> SimplCont -> SimplM (SimplFloats, OutExpr) -completeCall logger env var cont - | Just expr <- callSiteInline logger uf_opts case_depth var active_unf - lone_variable arg_infos interesting_cont - -- Inline the variable's RHS - = do { checkedTick (UnfoldingDone var) - ; dump_inline expr cont - ; let env1 = zapSubstEnv env - ; simplExprF env1 expr cont } - - | otherwise - -- Don't inline; instead rebuild the call - = do { rule_base <- getSimplRules - ; let rules = getRules rule_base var - info = mkArgInfo env var rules - n_val_args call_cont - ; rebuildCall env info cont } + ContEx tvs cvs ids e -> simplExprF env' e cont + -- Don't trimJoinCont; haven't already simplified e, + -- so the cont is not embodied in e + where + env' = setSubstEnv env tvs cvs ids - where - uf_opts = seUnfoldingOpts env - case_depth = seCaseDepth env - (lone_variable, arg_infos, call_cont) = contArgs cont - n_val_args = length arg_infos - interesting_cont = interestingCallContext env call_cont - active_unf = activeUnfolding (seMode env) var + DoneId var1 -> + do { rule_base <- getSimplRules + ; let cont' = trimJoinCont var1 (isJoinId_maybe var1) cont + info = mkArgInfo env rule_base var1 cont' + ; rebuildCall env info cont' } - log_inlining doc - = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify) - Opt_D_dump_inlinings - "" FormatText doc + DoneEx e mb_join -> simplExprF env' e cont' + where + cont' = trimJoinCont var mb_join cont + env' = zapSubstEnv env -- See Note [zapSubstEnv] - dump_inline unfolding cont - | not (logHasDumpFlag logger Opt_D_dump_inlinings) = return () - | not (logHasDumpFlag logger Opt_D_verbose_core2core) - = when (isExternalName (idName var)) $ - log_inlining $ - sep [text "Inlining done:", nest 4 (ppr var)] - | otherwise - = log_inlining $ - sep [text "Inlining done: " <> ppr var, - nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), - text "Cont: " <+> ppr cont])] +--------------------------------------------------------- +-- Dealing with a call site -rebuildCall :: SimplEnv - -> ArgInfo - -> SimplCont +rebuildCall :: SimplEnv -> ArgInfo -> SimplCont -> SimplM (SimplFloats, OutExpr) --- We decided not to inline, so --- - simplify the arguments --- - try rewrite rules --- - and rebuild ---------- Bottoming applications -------------- rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_dmds = [] }) cont @@ -2137,27 +2092,48 @@ rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_dmds = [] }) con res = argInfoExpr fun rev_args cont_ty = contResultType cont ----------- Try rewrite RULES -------------- --- See Note [Trying rewrite rules] +---------- Try inlining, if ai_rewrite = TryInlining -------- +-- In the TryInlining case we try inlining immediately, before simplifying +-- any (more) arguments. Why? See Note [Rewrite rules and inlining]. +-- +-- If there are rewrite rules we'll skip this case until we have +-- simplified enough args to satisfy nr_wanted==0 in the TryRules case below +-- Then we'll try the rules, and if that fails, we'll do TryInlining +rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args + , ai_rewrite = TryInlining }) cont + = do { logger <- getLogger + ; let full_cont = pushSimplifiedRevArgs env rev_args cont + ; mb_inline <- tryInlining env logger fun full_cont + ; case mb_inline of + Just expr -> do { checkedTick (UnfoldingDone fun) + ; let env1 = zapSubstEnv env + ; simplExprF env1 expr full_cont } + Nothing -> rebuildCall env (info { ai_rewrite = TryNothing }) cont + } + +---------- Try rewrite RULES, if ai_rewrite = TryRules -------------- +-- See Note [Rewrite rules and inlining] +-- See also Note [Trying rewrite rules] rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args - , ai_rules = Just (nr_wanted, rules) }) cont + , ai_rewrite = TryRules nr_wanted rules }) cont | nr_wanted == 0 || no_more_args - , let info' = info { ai_rules = Nothing } = -- We've accumulated a simplified call in -- so try rewrite rules; see Note [RULES apply to simplified arguments] -- See also Note [Rules for recursive functions] do { mb_match <- tryRules env rules fun (reverse rev_args) cont ; case mb_match of Just (env', rhs, cont') -> simplExprF env' rhs cont' - Nothing -> rebuildCall env info' cont } + Nothing -> rebuildCall env (info { ai_rewrite = TryInlining }) cont } where + -- If we have run out of arguments, just try the rules; there might + -- be some with lower arity. Casts get in the way -- they aren't + -- allowed on rule LHSs no_more_args = case cont of ApplyToTy {} -> False ApplyToVal {} -> False _ -> True - ----------- Simplify applications and casts -------------- +---------- Simplify type applications and casts -------------- rebuildCall env info (CastIt co cont) = rebuildCall env (addCastTo info co) cont @@ -2202,6 +2178,7 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) call' = mkApps (Var fun_id) [mkTyArg rr', mkTyArg ty', arg'] ; return (emptyFloats env, call') } +---------- Simplify value arguments -------------------- rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty @@ -2237,6 +2214,42 @@ rebuildCall env fun_info rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) cont = rebuild env (argInfoExpr fun rev_args) cont +----------------------------------- +tryInlining :: SimplEnv -> Logger -> OutId -> SimplCont -> SimplM (Maybe OutExpr) +tryInlining env logger var cont + | Just expr <- callSiteInline logger uf_opts case_depth var active_unf + lone_variable arg_infos interesting_cont + = do { dump_inline expr cont + ; return (Just expr) } + + | otherwise + = return Nothing + + where + uf_opts = seUnfoldingOpts env + case_depth = seCaseDepth env + (lone_variable, arg_infos, call_cont) = contArgs cont + interesting_cont = interestingCallContext env call_cont + active_unf = activeUnfolding (seMode env) var + + log_inlining doc + = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify) + Opt_D_dump_inlinings + "" FormatText doc + + dump_inline unfolding cont + | not (logHasDumpFlag logger Opt_D_dump_inlinings) = return () + | not (logHasDumpFlag logger Opt_D_verbose_core2core) + = when (isExternalName (idName var)) $ + log_inlining $ + sep [text "Inlining done:", nest 4 (ppr var)] + | otherwise + = log_inlining $ + sep [text "Inlining done: " <> ppr var, + nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), + text "Cont: " <+> ppr cont])] + + {- Note [Trying rewrite rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider an application (f e1 e2 e3) where the e1,e2,e3 are not yet @@ -2272,6 +2285,38 @@ makes a particularly big difference when superclass selectors are involved: op ($p1 ($p2 (df d))) We want all this to unravel in one sweep. +Note [Rewrite rules and inlining] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general we try to arrange that inlining is disabled (via a pragma) if +a rewrite rule should apply, so that the rule has a decent chance to fire +before we inline the function. + +But it turns out that (especially when type-class specialisation or +SpecConstr is involved) it is very helpful for the the rewrite rule to +"win" over inlining when both are active at once: see #21851, #22097. + +The simplifier arranges to do this, as follows. In effect, the ai_rewrite +field of the ArgInfo record is the state of a little state-machine: + +* mkArgInfo sets the ai_rewrite field to TryRules if there are any rewrite + rules avaialable for that function. + +* rebuildCall simplifies arguments until enough are simplified to match the + rule with greatest arity. See Note [RULES apply to simplified arguments] + and the first field of `TryRules`. + + But no more! As soon as we have simplified enough arguments to satisfy the + maximum-arity rules, we try the rules; see Note [Trying rewrite rules]. + +* Once we have tried rules (or immediately if there are no rules) set + ai_rewrite to TryInlining, and the Simplifier will try to inline the + function. We want to try this immediately (before simplifying any (more) + arguments). Why? Consider + f BIG where f = \x{OneOcc}. ...x... + If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, + and we'll simplify BIG once, at x's occurrence, rather than twice. + + Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Because RULES apply to simplified arguments, there's a danger of repeatedly @@ -2327,7 +2372,8 @@ See Note [No free join points in arityType] in GHC.Core.Opt.Arity -} tryRules :: SimplEnv -> [CoreRule] - -> Id -> [ArgSpec] + -> Id + -> [ArgSpec] -- In /normal, forward/ order -> SimplCont -> SimplM (Maybe (SimplEnv, CoreExpr, SimplCont)) @@ -3668,7 +3714,7 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty | otherwise = do { join_bndr <- newJoinId [arg_bndr] res_ty ; let arg_info = ArgInfo { ai_fun = join_bndr - , ai_rules = Nothing, ai_args = [] + , ai_rewrite = TryNothing, ai_args = [] , ai_encl = False, ai_dmds = repeat topDmd , ai_discs = repeat 0 } ; return ( addJoinFloats (emptyFloats env) $ ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -30,9 +30,10 @@ module GHC.Core.Opt.Simplify.Utils ( interestingCallContext, -- ArgInfo - ArgInfo(..), ArgSpec(..), mkArgInfo, + ArgInfo(..), ArgSpec(..), RewriteCall(..), mkArgInfo, addValArgTo, addCastTo, addTyArgTo, - argInfoExpr, argInfoAppArgs, pushSimplifiedArgs, + argInfoExpr, argInfoAppArgs, + pushSimplifiedArgs, pushSimplifiedRevArgs, isStrictArgInfo, lazyArgContext, abstractFloats, @@ -52,6 +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.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make @@ -210,6 +212,7 @@ data SimplCont type StaticEnv = SimplEnv -- Just the static part is relevant +-- See Note [DupFlag invariants] data DupFlag = NoDup -- Unsimplified, might be big | Simplified -- Simplified | OkToDup -- Simplified and small @@ -226,8 +229,9 @@ perhapsSubstTy dup env ty {- Note [StaticEnv invariant] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We pair up an InExpr or InAlts with a StaticEnv, which establishes the -lexical scope for that InExpr. When we simplify that InExpr/InAlts, we -use +lexical scope for that InExpr. + +When we simplify that InExpr/InAlts, we use - Its captured StaticEnv - Overriding its InScopeSet with the larger one at the simplification point. @@ -244,13 +248,14 @@ isn't big enough. Note [DupFlag invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~ -In both (ApplyToVal dup _ env k) - and (Select dup _ _ env k) +In both ApplyToVal { se_dup = dup, se_env = env, se_cont = k} + and Select { se_dup = dup, se_env = env, se_cont = k} the following invariants hold (a) if dup = OkToDup, then continuation k is also ok-to-dup - (b) if dup = OkToDup or Simplified, the subst-env is empty - (and hence no need to re-simplify) + (b) if dup = OkToDup or Simplified, the subst-env is empty, + or at least is always ignored; the payload is + already an OutThing -} instance Outputable DupFlag where @@ -309,7 +314,8 @@ data ArgInfo ai_fun :: OutId, -- The function ai_args :: [ArgSpec], -- ...applied to these args (which are in *reverse* order) - ai_rules :: FunRules, -- Rules for this function + ai_rewrite :: RewriteCall, -- Says what transformation to + -- try next for this call ai_encl :: Bool, -- Flag saying whether this function -- or an enclosing one has rules (recursively) @@ -325,6 +331,12 @@ data ArgInfo -- Always infinite } +data RewriteCall -- What rewriting to try next for this call + -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration + = TryRules FullArgCount [CoreRule] + | TryInlining + | TryNothing + data ArgSpec = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal @@ -349,20 +361,20 @@ instance Outputable ArgSpec where addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo addValArgTo ai arg hole_ty - | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai + | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rewrite = rew } <- ai -- Pop the top demand and and discounts off , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } - = ai { ai_args = arg_spec : ai_args ai - , ai_dmds = dmds - , ai_discs = discs - , ai_rules = decRules rules } + = ai { ai_args = arg_spec : ai_args ai + , ai_dmds = dmds + , ai_discs = discs + , ai_rewrite = decArgCount rew } | otherwise = pprPanic "addValArgTo" (ppr ai $$ ppr arg) -- There should always be enough demands and discounts addTyArgTo :: ArgInfo -> OutType -> OutType -> ArgInfo -addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai - , ai_rules = decRules (ai_rules ai) } +addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai + , ai_rewrite = decArgCount (ai_rewrite ai) } where arg_spec = TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } @@ -381,19 +393,22 @@ argInfoAppArgs (CastBy {} : _) = [] -- Stop at a cast argInfoAppArgs (ValArg { as_arg = arg } : as) = arg : argInfoAppArgs as argInfoAppArgs (TyArg { as_arg_ty = ty } : as) = Type ty : argInfoAppArgs as -pushSimplifiedArgs :: SimplEnv -> [ArgSpec] -> SimplCont -> SimplCont -pushSimplifiedArgs _env [] k = k -pushSimplifiedArgs env (arg : args) k - = case arg of - TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } - -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty } - -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest } - CastBy c -> CastIt c rest - where - rest = pushSimplifiedArgs env args k - -- The env has an empty SubstEnv +pushSimplifiedArgs, pushSimplifiedRevArgs + :: SimplEnv + -> [ArgSpec] -- In normal, forward order for pushSimplifiedArgs, + -- in /reverse/ order for pushSimplifiedRevArgs + -> SimplCont -> SimplCont +pushSimplifiedArgs env args cont = foldr (pushSimplifiedArg env) cont args +pushSimplifiedRevArgs env args cont = foldl (\k a -> pushSimplifiedArg env a k) cont args + +pushSimplifiedArg :: SimplEnv -> ArgSpec -> SimplCont -> SimplCont +pushSimplifiedArg _env (TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty }) cont + = ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = cont } +pushSimplifiedArg env (ValArg { as_arg = arg, as_hole_ty = hole_ty }) cont + = ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified + -- The SubstEnv will be ignored since sc_dup=Simplified + , sc_hole_ty = hole_ty, sc_cont = cont } +pushSimplifiedArg _ (CastBy c) cont = CastIt c cont argInfoExpr :: OutId -> [ArgSpec] -> OutExpr -- NB: the [ArgSpec] is reversed so that the first arg @@ -406,18 +421,14 @@ argInfoExpr fun rev_args go (TyArg { as_arg_ty = ty } : as) = go as `App` Type ty go (CastBy co : as) = mkCast (go as) co +decArgCount :: RewriteCall -> RewriteCall +decArgCount (TryRules n rules) = TryRules (n-1) rules +decArgCount rew = rew -type FunRules = Maybe (Int, [CoreRule]) -- Remaining rules for this function - -- Nothing => No rules - -- Just (n, rules) => some rules, requiring at least n more type/value args - -decRules :: FunRules -> FunRules -decRules (Just (n, rules)) = Just (n-1, rules) -decRules Nothing = Nothing - -mkFunRules :: [CoreRule] -> FunRules -mkFunRules [] = Nothing -mkFunRules rs = Just (n_required, rs) +mkTryRules :: [CoreRule] -> RewriteCall +-- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration +mkTryRules [] = TryInlining +mkTryRules rs = TryRules n_required rs where n_required = maximum (map ruleArity rs) @@ -516,6 +527,7 @@ contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k + ------------------- countArgs :: SimplCont -> Int -- Count all arguments, including types, coercions, @@ -525,6 +537,14 @@ countArgs (ApplyToVal { sc_cont = cont }) = 1 + countArgs cont countArgs (CastIt _ cont) = countArgs cont countArgs _ = 0 +countValArgs :: SimplCont -> Int +-- Count value arguments only +countValArgs (ApplyToTy { sc_cont = cont }) = 1 + countValArgs cont +countValArgs (ApplyToVal { sc_cont = cont }) = 1 + countValArgs cont +countValArgs (CastIt _ cont) = countValArgs cont +countValArgs _ = 0 + +------------------- contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont) -- Summarises value args, discards type args and coercions -- The returned continuation of the call is only used to @@ -579,29 +599,26 @@ contEvalContext k = case k of -- and case binder dmds, see addCaseBndrDmd. No priority right now. ------------------- -mkArgInfo :: SimplEnv - -> Id - -> [CoreRule] -- Rules for function - -> Int -- Number of value args - -> SimplCont -- Context of the call - -> ArgInfo - -mkArgInfo env fun rules n_val_args call_cont +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_rules = fun_rules + , ai_rewrite = fun_rules , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rules = fun_rules - , ai_encl = interestingArgContext rules call_cont + , ai_rewrite = fun_rules + , ai_encl = notNull rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - fun_rules = mkFunRules rules + rules = getRules rule_base fun + fun_rules = mkTryRules rules + n_val_args = countValArgs cont vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 @@ -814,7 +831,7 @@ interestingCallContext env cont -- a build it's *great* to inline it here. So we must ensure that -- the context for (f x) is not totally uninteresting. -interestingArgContext :: [CoreRule] -> SimplCont -> Bool +contHasRules :: SimplCont -> Bool -- If the argument has form (f x y), where x,y are boring, -- and f is marked INLINE, then we don't want to inline f. -- But if the context of the argument is @@ -822,33 +839,29 @@ interestingArgContext :: [CoreRule] -> SimplCont -> Bool -- where g has rules, then we *do* want to inline f, in case it -- exposes a rule that might fire. Similarly, if the context is -- h (g (f x x)) --- where h has rules, then we do want to inline f; hence the --- call_cont argument to interestingArgContext +-- where h has rules, then we do want to inline f. So contHasRules +-- tries to see if the context of the f-call is a call to a function +-- with rules. -- --- The ai-rules flag makes this happen; if it's +-- The ai_encl flag makes this happen; if it's -- set, the inliner gets just enough keener to inline f -- regardless of how boring f's arguments are, if it's marked INLINE -- -- The alternative would be to *always* inline an INLINE function, -- regardless of how boring its context is; but that seems overkill -- For example, it'd mean that wrapper functions were always inlined --- --- The call_cont passed to interestingArgContext is the context of --- the call itself, e.g. g in the example above -interestingArgContext rules call_cont - = notNull rules || enclosing_fn_has_rules +contHasRules cont + = go cont where - enclosing_fn_has_rules = go call_cont - - go (Select {}) = False - go (ApplyToVal {}) = False -- Shouldn't really happen - go (ApplyToTy {}) = False -- Ditto - go (StrictArg { sc_fun = fun }) = ai_encl fun - go (StrictBind {}) = False -- ?? - go (CastIt _ c) = go c - go (Stop _ RuleArgCtxt _) = True - go (Stop _ _ _) = False - go (TickIt _ c) = go c + go (ApplyToVal { sc_cont = cont }) = go cont + go (ApplyToTy { sc_cont = cont }) = go cont + go (CastIt _ cont) = go cont + go (StrictArg { sc_fun = fun }) = ai_encl fun + go (Stop _ RuleArgCtxt _) = True + go (TickIt _ c) = go c + go (Select {}) = False + go (StrictBind {}) = False -- ?? + go (Stop _ _ _) = False {- Note [Interesting arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/lib/integer/Makefile ===================================== @@ -11,8 +11,9 @@ CHECK2 = grep -q -- '$1' folding.simpl || \ .PHONY: integerConstantFolding integerConstantFolding: - '$(TEST_HC)' -Wall -v0 -O --make integerConstantFolding -fforce-recomp -ddump-simpl > folding.simpl + '$(TEST_HC)' -Wall -v0 -O --make integerConstantFolding -fforce-recomp -ddump-simpl -dno-debug-output > folding.simpl # All the 100nnn values should be constant-folded away +# -dno-debug-output suppresses a "Glomming" message ! grep -q '\<100[0-9][0-9][0-9]\>' folding.simpl || { echo "Unfolded values found"; grep '\<100[0-9][0-9][0-9]\>' folding.simpl; } $(call CHECK,\<200007\>,plusInteger) $(call CHECK,\<683234160\>,timesInteger) @@ -64,8 +65,9 @@ IntegerConversionRules: .PHONY: naturalConstantFolding naturalConstantFolding: - '$(TEST_HC)' -Wall -v0 -O --make naturalConstantFolding -fforce-recomp -ddump-simpl > folding.simpl + '$(TEST_HC)' -Wall -v0 -O --make naturalConstantFolding -fforce-recomp -ddump-simpl -dno-debug-output > folding.simpl # All the 100nnn values should be constant-folded away +# -dno-debug-output suppresses a "Glomming" message ! grep -q '\<100[0-9][0-9][0-9]\>' folding.simpl || { echo "Unfolded values found"; grep '\<100[0-9][0-9][0-9]\>' folding.simpl; } # Bit arithmetic $(call CHECK,\<532\>,andNatural) ===================================== testsuite/tests/simplCore/should_compile/T21851.hs ===================================== @@ -0,0 +1,11 @@ +{-# OPTIONS_GHC -ddump-simpl #-} + +module T21851 (g') where +import T21851a + +g :: Num a => a -> a +g x = fst (f x) +{-# NOINLINE[99] g #-} + +g' :: Int -> Int +g' = g ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== ===================================== testsuite/tests/simplCore/should_compile/T21851a.hs ===================================== @@ -0,0 +1,5 @@ +module T21851a where + +f :: Num b => b -> (b, b) -- note: recursive to prevent inlining +f x = (x + 1, snd (f x)) -- on such a small example +{-# SPECIALIZE f :: Int -> (Int, Int) #-} ===================================== testsuite/tests/simplCore/should_compile/T6056.stderr ===================================== @@ -1,4 +1,4 @@ Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) -Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) +Rule fired: SPEC/T6056 smallerAndRest @Int (T6056) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -429,3 +429,4 @@ test('T21763', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) test('T21763a', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) test('T22028', normal, compile, ['-O -ddump-rule-firings']) test('T22114', normal, compile, ['-O']) +test('T21851', [grep_errmsg(r'case.*w\$sf') ], multimod_compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c434c0a4977637dec45a29755b39c50930fe597d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c434c0a4977637dec45a29755b39c50930fe597d You're receiving 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 Sep 27 16:19:34 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 12:19:34 -0400 Subject: [Git][ghc/ghc][wip/ghc-fat-interface] 2 commits: Interface Files with Core Definitions Message-ID: <633322961e42_2c97575142845587c@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-fat-interface at Glasgow Haskell Compiler / GHC Commits: 6911a39e by Matthew Pickering at 2022-09-27T17:19:24+01: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 - - - - - a106484b by Matthew Pickering at 2022-09-27T17:19:24+01: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 - - - - - 30 changed files: - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.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/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Unit/Home/ModInfo.hs - compiler/GHC/Unit/Module/Graph.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/GHC/Unit/Module/Status.hs - + compiler/GHC/Unit/Module/WholeCoreBindings.hs - compiler/ghc.cabal.in - docs/users_guide/phases.rst - ghc/GHCi/Leak.hs - ghc/Main.hs - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - testsuite/tests/driver/T20300/T20300.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c322be403375851d5a5fd1e0607ca90a0480b62...a106484bc29672138539381c112e17301b41e9fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c322be403375851d5a5fd1e0607ca90a0480b62...a106484bc29672138539381c112e17301b41e9fc You're receiving 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 Sep 27 16:31:43 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 12:31:43 -0400 Subject: [Git][ghc/ghc][wip/T21470] Fix binder-swap bug Message-ID: <6333256fe2c6d_2c975751450459318@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: eecfacae by Simon Peyton Jones at 2022-09-27T17:33:20+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 8 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - testsuite/tests/linters/notes.stdout - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -19,7 +19,7 @@ core expression with (hopefully) improved usage information. module GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr, - zapLambdaBndrs + zapLambdaBndrs, scrutBinderSwap_maybe ) where import GHC.Prelude @@ -27,11 +27,12 @@ import GHC.Prelude import GHC.Core import GHC.Core.FVs import GHC.Core.Utils ( exprIsTrivial, isDefaultAlt, isExpandableApp, - stripTicksTopE, mkTicks ) + mkCastMCo, mkTicks ) import GHC.Core.Opt.Arity ( joinRhsArity, isOneShotBndr ) import GHC.Core.Coercion +import GHC.Core.Predicate ( isDictId ) import GHC.Core.Type -import GHC.Core.TyCo.FVs( tyCoVarsOfMCo ) +import GHC.Core.TyCo.FVs ( tyCoVarsOfMCo ) import GHC.Data.Maybe( isJust, orElse ) import GHC.Data.Graph.Directed ( SCC(..), Node(..) @@ -2462,8 +2463,8 @@ data OccEnv -- See Note [The binder-swap substitution] -- If x :-> (y, co) is in the env, - -- then please replace x by (y |> sym mco) - -- Invariant of course: idType x = exprType (y |> sym mco) + -- then please replace x by (y |> mco) + -- Invariant of course: idType x = exprType (y |> mco) , occ_bs_env :: !(VarEnv (OutId, MCoercion)) , occ_bs_rng :: !VarSet -- Vars free in the range of occ_bs_env -- Domain is Global and Local Ids @@ -2669,7 +2670,7 @@ The binder-swap is implemented by the occ_bs_env field of OccEnv. There are two main pieces: * Given case x |> co of b { alts } - we add [x :-> (b, co)] to the occ_bs_env environment; this is + we add [x :-> (b, sym co)] to the occ_bs_env environment; this is done by addBndrSwap. * Then, at an occurrence of a variable, we look up in the occ_bs_env @@ -2737,30 +2738,8 @@ Some tricky corners: (BS5) We have to apply the occ_bs_env substitution uniformly, including to (local) rules and unfoldings. -Historical note ---------------- -We used to do the binder-swap transformation by introducing -a proxy let-binding, thus; - - case x of b { pi -> ri } - ==> - case x of b { pi -> let x = b in ri } - -But that had two problems: - -1. If 'x' is an imported GlobalId, we'd end up with a GlobalId - on the LHS of a let-binding which isn't allowed. We worked - around this for a while by "localising" x, but it turned - out to be very painful #16296, - -2. In CorePrep we use the occurrence analyser to do dead-code - elimination (see Note [Dead code in CorePrep]). But that - occasionally led to an unlifted let-binding - case x of b { DEFAULT -> let x::Int# = b in ... } - which disobeys one of CorePrep's output invariants (no unlifted - let-bindings) -- see #5433. - -Doing a substitution (via occ_bs_env) is much better. +(BS6) We must be very careful with dictionaries. + See Note [Care with binder-swap on dictionaries] Note [Case of cast] ~~~~~~~~~~~~~~~~~~~ @@ -2770,6 +2749,54 @@ We'd like to eliminate the inner case. That is the motivation for equation (2) in Note [Binder swap]. When we get to the inner case, we inline x, cancel the casts, and away we go. +Note [Care with binder-swap on dictionaries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This Note explains why we need isDictId in scrutBinderSwap_maybe. +Consider this tricky example (#21229, #21470): + + class Sing (b :: Bool) where sing :: Bool + instance Sing 'True where sing = True + instance Sing 'False where sing = False + + f :: forall a. Sing a => blah + + h = \ @(a :: Bool) ($dSing :: Sing a) + let the_co = Main.N:Sing[0] :: Sing a ~R# Bool + case ($dSing |> the_co) of wild + True -> f @'True (True |> sym the_co) + False -> f @a dSing + +Now do a binder-swap on the case-expression: + + h = \ @(a :: Bool) ($dSing :: Sing a) + let the_co = Main.N:Sing[0] :: Sing a ~R# Bool + case ($dSing |> the_co) of wild + True -> f @'True (True |> sym the_co) + False -> f @a (wild |> sym the_co) + +And now substitute `False` for `wild` (since wild=False in the False branch): + + h = \ @(a :: Bool) ($dSing :: Sing a) + let the_co = Main.N:Sing[0] :: Sing a ~R# Bool + case ($dSing |> the_co) of wild + True -> f @'True (True |> sym the_co) + False -> f @a (False |> sym the_co) + +And now we have a problem. The specialiser will specialise (f @a d)a (for all +vtypes a and dictionaries d!!) with the dictionary (False |> sym the_co), using +Note [Specialising polymorphic dictionaries] in GHC.Core.Opt.Specialise. + +The real problem is the binder-swap. It swaps a dictionary variable $dSing +(of kind Constraint) for a term variable wild (of kind Type). And that is +dangerous: a dictionary is a /singleton/ type whereas a general term variable is +not. In this particular example, Bool is most certainly not a singleton type! + +Conclusion: + for a /dictionary variable/ do not perform + the clever cast version of the binder-swap + +Hence the subtle isDictId in scrutBinderSwap_maybe. + Note [Zap case binders in proxy bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From the original @@ -2784,8 +2811,87 @@ binding x = cb. See #5028. NB: the OccInfo on /occurrences/ really doesn't matter much; the simplifier doesn't use it. So this is only to satisfy the perhaps-over-picky Lint. +-} + +addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv +-- See Note [The binder-swap substitution] +addBndrSwap scrut case_bndr + env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) + | Just (scrut_var, mco) <- scrutBinderSwap_maybe scrut + , scrut_var /= case_bndr + -- Consider: case x of x { ... } + -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop + = env { occ_bs_env = extendVarEnv swap_env scrut_var (case_bndr', mco) + , occ_bs_rng = rng_vars `extendVarSet` case_bndr' + `unionVarSet` tyCoVarsOfMCo mco } + + | otherwise + = env + where + case_bndr' = zapIdOccInfo case_bndr + -- See Note [Zap case binders in proxy bindings] + +scrutBinderSwap_maybe :: OutExpr -> Maybe (OutVar, MCoercion) +-- If (scrutBinderSwap_maybe e = Just (v, mco), then +-- v = e |> mco +-- See Note [Case of cast] +-- See Note [Care with binder-swap on dictionaries] +-- +-- We use this same function in SpecConstr, and Simplify.Iteration, +-- when something binder-swap-like is happening +scrutBinderSwap_maybe (Var v) = Just (v, MRefl) +scrutBinderSwap_maybe (Cast (Var v) co) + | not (isDictId v) = Just (v, MCo (mkSymCo co)) + -- Cast: see Note [Case of cast] + -- isDictId: see Note [Care with binder-swap on dictionaries] + -- The isDictId rejects a Constraint/Constraint binder-swap, perhaps + -- over-conservatively. But I have never seen one, so I'm leaving + -- the code as simple as possible Losing +the binder-swap in a rare case probably has very low impact. +scrutBinderSwap_maybe (Tick _ e) = scrutBinderSwap_maybe e -- Drop ticks +scrutBinderSwap_maybe _ = Nothing + +lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) +-- See Note [The binder-swap substitution] +-- Returns an expression of the same type as Id +lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr + = case lookupVarEnv bs_env bndr of { + Nothing -> (Var bndr, bndr) ; + Just (bndr1, mco) -> + + -- Why do we iterate here? + -- See (BS2) in Note [The binder-swap substitution] + case lookupBndrSwap env bndr1 of + (fun, fun_id) -> (mkCastMCo fun mco, fun_id) } + + +{- Historical note [Proxy let-bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We used to do the binder-swap transformation by introducing +a proxy let-binding, thus; + + case x of b { pi -> ri } + ==> + case x of b { pi -> let x = b in ri } + +But that had two problems: + +1. If 'x' is an imported GlobalId, we'd end up with a GlobalId + on the LHS of a let-binding which isn't allowed. We worked + around this for a while by "localising" x, but it turned + out to be very painful #16296, + +2. In CorePrep we use the occurrence analyser to do dead-code + elimination (see Note [Dead code in CorePrep]). But that + occasionally led to an unlifted let-binding + case x of b { DEFAULT -> let x::Int# = b in ... } + which disobeys one of CorePrep's output invariants (no unlifted + let-bindings) -- see #5433. + +Doing a substitution (via occ_bs_env) is much better. + Historical Note [no-case-of-case] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We *used* to suppress the binder-swap in case expressions when -fno-case-of-case is on. Old remarks: "This happens in the first simplifier pass, @@ -2844,53 +2950,8 @@ binder-swap in OccAnal: It's fixed by doing the binder-swap in OccAnal because we can do the binder-swap unconditionally and still get occurrence analysis information right. --} -addBndrSwap :: OutExpr -> Id -> OccEnv -> OccEnv --- See Note [The binder-swap substitution] -addBndrSwap scrut case_bndr - env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) - | Just (scrut_var, mco) <- get_scrut_var (stripTicksTopE (const True) scrut) - , scrut_var /= case_bndr - -- Consider: case x of x { ... } - -- Do not add [x :-> x] to occ_bs_env, else lookupBndrSwap will loop - = env { occ_bs_env = extendVarEnv swap_env scrut_var (case_bndr', mco) - , occ_bs_rng = rng_vars `extendVarSet` case_bndr' - `unionVarSet` tyCoVarsOfMCo mco } - - | otherwise - = env - where - get_scrut_var :: OutExpr -> Maybe (OutVar, MCoercion) - get_scrut_var (Var v) = Just (v, MRefl) - get_scrut_var (Cast (Var v) co) = Just (v, MCo co) -- See Note [Case of cast] - get_scrut_var _ = Nothing - - case_bndr' = zapIdOccInfo case_bndr - -- See Note [Zap case binders in proxy bindings] -lookupBndrSwap :: OccEnv -> Id -> (CoreExpr, Id) --- See Note [The binder-swap substitution] --- Returns an expression of the same type as Id -lookupBndrSwap env@(OccEnv { occ_bs_env = bs_env }) bndr - = case lookupVarEnv bs_env bndr of { - Nothing -> (Var bndr, bndr) ; - Just (bndr1, mco) -> - - -- Why do we iterate here? - -- See (BS2) in Note [The binder-swap substitution] - case lookupBndrSwap env bndr1 of - (fun, fun_id) -> (add_cast fun mco, fun_id) } - - where - add_cast fun MRefl = fun - add_cast fun (MCo co) = Cast fun (mkSymCo co) - -- We must switch that 'co' to 'sym co'; - -- see the comment with occ_bs_env - -- No need to test for isReflCo, because 'co' came from - -- a (Cast e co) and hence is unlikely to be Refl - -{- ************************************************************************ * * \subsection[OccurAnal-types]{OccEnv} ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -51,17 +51,6 @@ The simplifier tries to get rid of occurrences of x, in favour of wild, in the hope that there will only be one remaining occurrence of x, namely the scrutinee of the case, and we can inline it. - - This can only work if @wild@ is an unrestricted binder. Indeed, even with the - extended typing rule (in the linter) for case expressions, if - case x of wild % 1 { p -> e} - is well-typed, then - case x of wild % 1 { p -> e[wild\x] } - is only well-typed if @e[wild\x] = e@ (that is, if @wild@ is not used in @e@ - at all). In which case, it is, of course, pointless to do the substitution - anyway. So for a linear binder (and really anything which isn't unrestricted), - doing this substitution would either produce ill-typed terms or be the - identity. -} module GHC.Core.Opt.SetLevels ( @@ -1602,7 +1591,9 @@ extendCaseBndrEnv :: LevelEnv -> LevelEnv extendCaseBndrEnv le@(LE { le_subst = subst, le_env = id_env }) case_bndr (Var scrut_var) - | Many <- varMult case_bndr + -- We could use OccurAnal. scrutBinderSwap_maybe here, and perhaps + -- get a bit more floating. But we didn't in the past and it's + -- an unforced change, so I'm leaving it. = le { le_subst = extendSubstWithVar subst case_bndr scrut_var , le_env = add_id id_env (case_bndr, scrut_var) } extendCaseBndrEnv env _ _ = env ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -22,7 +22,7 @@ import GHC.Core.Opt.Simplify.Monad import GHC.Core.Type hiding ( substTy, substTyVar, extendTvSubst, extendCvSubst ) import GHC.Core.Opt.Simplify.Env import GHC.Core.Opt.Simplify.Utils -import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs ) +import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr, zapLambdaBndrs, scrutBinderSwap_maybe ) import GHC.Core.Make ( FloatBind, mkImpossibleExpr, castBottomExpr ) import qualified GHC.Core.Make import GHC.Core.Coercion hiding ( substCo, substCoVar ) @@ -3240,19 +3240,21 @@ zapIdOccInfoAndSetEvald str v = -- see Note [Case alternative occ info] addAltUnfoldings :: SimplEnv -> Maybe OutExpr -> OutId -> OutExpr -> SimplM SimplEnv -addAltUnfoldings env scrut case_bndr con_app +addAltUnfoldings env mb_scrut case_bndr con_app = do { let con_app_unf = mk_simple_unf con_app env1 = addBinderUnfolding env case_bndr con_app_unf -- See Note [Add unfolding for scrutinee] - env2 | Many <- idMult case_bndr = case scrut of - Just (Var v) -> addBinderUnfolding env1 v con_app_unf - Just (Cast (Var v) co) -> addBinderUnfolding env1 v $ - mk_simple_unf (Cast con_app (mkSymCo co)) - _ -> env1 + env2 | Just scrut <- mb_scrut + , Just (v,mco) <- scrutBinderSwap_maybe scrut + = addBinderUnfolding env1 v $ + if isReflMCo mco -- isReflMCo: avoid calling mk_simple_unf + then con_app_unf -- twice in the common case + else mk_simple_unf (mkCastMCo con_app mco) + | otherwise = env1 - ; traceSmpl "addAltUnf" (vcat [ppr case_bndr <+> ppr scrut, ppr con_app]) + ; traceSmpl "addAltUnf" (vcat [ppr case_bndr <+> ppr mb_scrut, ppr con_app]) ; return env2 } where -- Force the opts, so that the whole SimplEnv isn't retained @@ -3315,9 +3317,6 @@ it's also good for case-elimination -- suppose that 'f' was inlined and did multi-level case analysis, then we'd solve it in one simplifier sweep instead of two. -Exactly the same issue arises in GHC.Core.Opt.SpecConstr; -see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr - HOWEVER, given case x of y { Just a -> r1; Nothing -> r2 } we do not want to add the unfolding x -> y to 'x', which might seem cool, @@ -3328,8 +3327,11 @@ piece of information. So instead we add the unfolding x -> Just a, and x -> Nothing in the respective RHSs. -Since this transformation is tantamount to a binder swap, the same caveat as in -Note [Suppressing binder-swaps on linear case] in OccurAnal apply. +Since this transformation is tantamount to a binder swap, we use +GHC.Core.Opt.OccurAnal.scrutBinderSwap_maybe to do the check. + +Exactly the same issue arises in GHC.Core.Opt.SpecConstr; +see Note [Add scrutinee to ValueEnv too] in GHC.Core.Opt.SpecConstr ************************************************************************ ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -35,6 +35,7 @@ import GHC.Core.Unfold import GHC.Core.FVs ( exprsFreeVarsList, exprFreeVars ) import GHC.Core.Opt.Monad import GHC.Core.Opt.WorkWrap.Utils +import GHC.Core.Opt.OccurAnal( scrutBinderSwap_maybe ) import GHC.Core.DataCon import GHC.Core.Class( classTyVars ) import GHC.Core.Coercion hiding( substCo ) @@ -1073,8 +1074,8 @@ extendCaseBndrs env scrut case_bndr con alt_bndrs = (env2, alt_bndrs') where live_case_bndr = not (isDeadBinder case_bndr) - env1 | Var v <- stripTicksTopE (const True) scrut - = extendValEnv env v cval + env1 | Just (v, mco) <- scrutBinderSwap_maybe scrut + , isReflMCo mco = extendValEnv env v cval | otherwise = env -- See Note [Add scrutinee to ValueEnv too] env2 | live_case_bndr = extendValEnv env1 case_bndr cval | otherwise = env1 @@ -1164,6 +1165,10 @@ though the simplifier has systematically replaced uses of 'x' with 'y' and 'b' with 'c' in the code. The use of 'b' in the ValueEnv came from outside the case. See #4908 for the live example. +It's very like the binder-swap story, so we use scrutBinderSwap_maybe +to identify suitable scrutinees -- but only if there is no cast +(isReflMCo) because that's all that the ValueEnv allows. + Note [Avoiding exponential blowup] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The sc_count field of the ScEnv says how many times we are prepared to ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -535,25 +535,23 @@ Note [Specialisation and overlapping instances] Here is at tricky case (see a comment in MR !8916): module A where + class C a where + meth :: a -> String + instance {-# OVERLAPPABLE #-} C (Maybe a) where + meth _ = "Maybe" - class C a where - meth :: a -> String - - instance {-# OVERLAPPABLE #-} C (Maybe a) where - meth _ = "Maybe" - - {-# SPECIALISE f :: Maybe a -> Bool -> String #-} - f :: C a => a -> Bool -> String - f a True = f a False - f a _ = meth a + {-# SPECIALISE f :: Maybe a -> Bool -> String #-} + f :: C a => a -> Bool -> String + f a True = f a False + f a _ = meth a module B where - import A + import A - instance C (Maybe Int) where - meth _ = "Int" + instance C (Maybe Int) where + meth _ = "Int" - main = putStrLn $ f (Just 42 :: Maybe Int) True + main = putStrLn $ f (Just 42 :: Maybe Int) True Running main without optimisations yields "Int", the correct answer. Activating optimisations yields "Maybe" due to a rewrite rule in module ===================================== compiler/GHC/Core/Subst.hs ===================================== @@ -42,7 +42,6 @@ import GHC.Core import GHC.Core.FVs import GHC.Core.Seq import GHC.Core.Utils -import GHC.Core.TyCo.Subst ( substCo ) -- We are defining local versions import GHC.Core.Type hiding ( substTy ) ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -2,7 +2,6 @@ ref compiler/GHC/Core/Coercion/Axiom.hs:461:2: Note [RoughMap and rm_empt ref compiler/GHC/Core/Opt/OccurAnal.hs:857:15: Note [Loop breaking] ref compiler/GHC/Core/Opt/SetLevels.hs:1580:30: Note [Top level scope] ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:2675:13: Note [Case binder next] -ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:3303:0: Note [Suppressing binder-swaps on linear case] ref compiler/GHC/Core/Opt/Simplify/Iteration.hs:3854:8: Note [Lambda-bound unfoldings] ref compiler/GHC/Core/Opt/Simplify/Utils.hs:1257:37: Note [Gentle mode] ref compiler/GHC/Core/Opt/Specialise.hs:1623:28: Note [Arity decrease] ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -359,7 +359,6 @@ test('T19586', normal, compile, ['']) test('T19599', normal, compile, ['-O -ddump-rules']) test('T19599a', normal, compile, ['-O -ddump-rules']) -test('T13873', [expect_broken(21229), grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) # Look for a specialisation rule for wimwam test('T19672', normal, compile, ['-O2 -ddump-rules']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eecfacae84930f2dfef082d205c168543512117c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eecfacae84930f2dfef082d205c168543512117c You're receiving 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 Sep 27 16:51:20 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 27 Sep 2022 12:51:20 -0400 Subject: [Git][ghc/ghc][wip/T22084] 57 commits: Add native delimited continuations to the RTS Message-ID: <63332a0827f75_2c9757514784615ca@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22084 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - bef9a552 by Simon Peyton Jones at 2022-09-27T17:52:49+01:00 Don't keep exit join points so much ToDo: write a proper Note and commit message. This is for CI - - - - - 30 changed files: - − .appveyor.sh - .gitlab/ci.sh - − 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/827f97bedd494025e969166b4c18cbb198515e34...bef9a55228552e85e26bba5ce782bbeb9404391c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/827f97bedd494025e969166b4c18cbb198515e34...bef9a55228552e85e26bba5ce782bbeb9404391c You're receiving 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 Sep 27 17:00:59 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 27 Sep 2022 13:00:59 -0400 Subject: [Git][ghc/ghc][wip/js-staging] JS.StgToJS.Types: Docs and cleanup Message-ID: <63332c4b24509_2c975751478463483@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 97437f2e by doyougnu at 2022-09-27T13:00:36-04:00 JS.StgToJS.Types: Docs and cleanup - - - - - 1 changed file: - compiler/GHC/StgToJS/Types.hs Changes: ===================================== compiler/GHC/StgToJS/Types.hs ===================================== @@ -3,6 +3,22 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} +----------------------------------------------------------------------------- +-- | +-- Module : GHC.StgToJS.Types +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- +-- Module that holds the Types required for the StgToJS pass +----------------------------------------------------------------------------- + module GHC.StgToJS.Types where import GHC.Prelude @@ -34,8 +50,10 @@ import Data.Typeable (Typeable) import GHC.Generics (Generic) import Control.DeepSeq +-- | A State monad over IO holding the generator state. type G = StateT GenState IO +-- | The JS code generator state data GenState = GenState { gsSettings :: StgToJSConfig -- ^ codegen settings, read-only , gsModule :: !Module -- ^ current module @@ -46,7 +64,7 @@ data GenState = GenState , gsGlobal :: [JStat] -- ^ global (per module) statements (gets included when anything else from the module is used) } --- | the state relevant for the current binding group +-- | The JS code generator state relevant for the current binding group data GenGroupState = GenGroupState { ggsToplevelStats :: [JStat] -- ^ extra toplevel statements for the binding group , ggsClosureInfo :: [ClosureInfo] -- ^ closure metadata (info tables) for the binding group @@ -58,6 +76,7 @@ data GenGroupState = GenGroupState , ggsForeignRefs :: [ForeignJSRef] } +-- | The Configuration record for the StgToJS pass data StgToJSConfig = StgToJSConfig -- flags { csInlinePush :: !Bool @@ -75,6 +94,7 @@ data StgToJSConfig = StgToJSConfig , csContext :: !SDocContext } +-- | Information relevenat to code generation for closures. data ClosureInfo = ClosureInfo { ciVar :: FastString -- ^ object being infod , ciRegs :: CIRegs -- ^ size of the payload (in number of JS values) @@ -85,8 +105,9 @@ data ClosureInfo = ClosureInfo } deriving stock (Eq, Show, Generic) +-- | Closure information, 'ClosureInfo', registers data CIRegs - = CIRegsUnknown + = CIRegsUnknown -- ^ A value witnessing a state of unknown registers | CIRegs { ciRegsSkip :: Int -- ^ unused registers before actual args start , ciRegsTypes :: [VarType] -- ^ args } @@ -94,28 +115,30 @@ data CIRegs instance NFData CIRegs +-- | Closure Information, 'ClosureInfo', layout data CILayout - = CILayoutVariable -- layout stored in object itself, first position from the start - | CILayoutUnknown -- fixed size, but content unknown (for example stack apply frame) + = CILayoutVariable -- ^ layout stored in object itself, first position from the start + | CILayoutUnknown -- ^ fixed size, but content unknown (for example stack apply frame) { layoutSize :: !Int } - | CILayoutFixed -- whole layout known - { layoutSize :: !Int -- closure size in array positions, including entry - , layout :: [VarType] + | CILayoutFixed -- ^ whole layout known + { layoutSize :: !Int -- ^ closure size in array positions, including entry + , layout :: [VarType] -- ^ The set of sized Types to layout } deriving stock (Eq, Ord, Show, Generic) instance NFData CILayout +-- | The type of 'ClosureInfo' data CIType - = CIFun { citArity :: !Int -- ^ function arity - , citRegs :: !Int -- ^ number of registers for the args + = CIFun { citArity :: !Int -- ^ function arity + , citRegs :: !Int -- ^ number of registers for the args } - | CIThunk - | CICon { citConstructor :: !Int } - | CIPap - | CIBlackhole - | CIStackFrame + | CIThunk -- ^ The closure is a THUNK + | CICon { citConstructor :: !Int } -- ^ The closure is a Constructor + | CIPap -- ^ The closure is a Partial Application + | CIBlackhole -- ^ The closure is a black hole + | CIStackFrame -- ^ The closure is a stack frame deriving stock (Eq, Ord, Show, Generic) instance NFData CIType @@ -131,18 +154,18 @@ instance ToJExpr CIStatic where toJExpr (CIStaticRefs []) = null_ -- [je| null |] toJExpr (CIStaticRefs rs) = toJExpr (map TxtI rs) --- function argument and free variable types +-- | Free variable types data VarType - = PtrV -- pointer = reference to heap object (closure object) - | VoidV -- no fields + = PtrV -- ^ pointer = reference to heap object (closure object) + | VoidV -- ^ no fields -- | FloatV -- one field -- no single precision supported - | DoubleV -- one field - | IntV -- one field - | LongV -- two fields - | AddrV -- a pointer not to the heap: two fields, array + index - | RtsObjV -- some RTS object from GHCJS (for example TVar#, MVar#, MutVar#, Weak#) - | ObjV -- some JS object, user supplied, be careful around these, can be anything - | ArrV -- boxed array + | DoubleV -- ^ A Double: one field + | IntV -- ^ An Int (32bit because JS): one field + | LongV -- ^ A Long: two fields one for the upper 32bits, one for the lower (NB: JS is little endian) + | AddrV -- ^ a pointer not to the heap: two fields, array + index + | RtsObjV -- ^ some RTS object from GHCJS (for example TVar#, MVar#, MutVar#, Weak#) + | ObjV -- ^ some JS object, user supplied, be careful around these, can be anything + | ArrV -- ^ boxed array deriving stock (Eq, Ord, Enum, Bounded, Show, Generic) instance NFData VarType @@ -150,16 +173,36 @@ instance NFData VarType instance ToJExpr VarType where toJExpr = toJExpr . fromEnum +-- | The type of identifiers. These determine the suffix of generated functions +-- in JS Land. For example, the entry function for the 'Just' constructor is a +-- 'IdConEntry' which compiles to: +-- @ +-- function h$baseZCGHCziMaybeziJust_con_e() { return h$rs() }; +-- @ +-- which just returns whatever the stack point is pointing to. Whereas the entry +-- function to 'Just' is an 'IdEntry' and does the work. It compiles to: +-- @ +-- function h$baseZCGHCziMaybeziJust_e() { +-- var h$$baseZCGHCziMaybezieta_8KXnScrCjF5 = h$r2; +-- h$r1 = h$c1(h$baseZCGHCziMaybeziJust_con_e, h$$baseZCGHCziMaybezieta_8KXnScrCjF5); +-- return h$rs(); +-- }; +-- @ +-- Which loads some payload from register 2, and applies the Constructor Entry +-- function for the Just to the payload, returns the result in register 1 and +-- returns whatever is on top of the stack data IdType - = IdPlain - | IdEntry - | IdConEntry + = IdPlain -- ^ A plain identifier for values, no suffix added + | IdEntry -- ^ An entry function, suffix = "_e" in 'GHC.StgToJS.Ids.makeIdentForId' + | IdConEntry -- ^ A Constructor entry function, suffix = "_con_e" in 'GHC.StgToJS.Ids.makeIdentForId' deriving (Enum, Eq, Ord) +-- | Keys to differentiate Ident's in the ID Cache data IdKey = IdKey !Int !Int !IdType deriving (Eq, Ord) +-- | Some other symbol data OtherSymb = OtherSymb !Module !FastString deriving Eq @@ -168,17 +211,21 @@ instance Ord OtherSymb where compare (OtherSymb m1 t1) (OtherSymb m2 t2) = stableModuleCmp m1 m2 <> lexicalCompareFS t1 t2 +-- | The identifier cache indexed on 'IdKey' local to a module newtype IdCache = IdCache (M.Map IdKey Ident) + +-- | The global Identifier Cache newtype GlobalIdCache = GlobalIdCache (M.Map Ident (IdKey, Id)) +-- | A Stack Slot is either known or unknown. We avoid maybe here for more +-- strictness. data StackSlot = SlotId !Id !Int | SlotUnknown deriving (Eq, Ord) - data StaticInfo = StaticInfo - { siVar :: !FastString -- ^ global object + { siVar :: !FastString -- ^ global object , siVal :: !StaticVal -- ^ static initialization , siCC :: !(Maybe Ident) -- ^ optional CCS name } deriving stock (Eq, Show, Typeable, Generic) @@ -207,15 +254,17 @@ data StaticUnboxed instance NFData StaticUnboxed +-- | Static Arguments data StaticArg - = StaticObjArg !FastString -- ^ reference to a heap object - | StaticLitArg !StaticLit -- ^ literal + = StaticObjArg !FastString -- ^ reference to a heap object + | StaticLitArg !StaticLit -- ^ literal | StaticConArg !FastString [StaticArg] -- ^ unfloated constructor deriving stock (Eq, Show, Generic) instance Outputable StaticArg where ppr x = text (show x) +-- | A Static literal value data StaticLit = BoolLit !Bool | IntLit !Integer @@ -239,6 +288,7 @@ instance ToJExpr StaticLit where toJExpr (BinLit b) = app (mkFastString "h$rstr") [toJExpr (map toInteger (BS.unpack b))] toJExpr (LabelLit _isFun lbl) = var lbl +-- | A foreign reference to some JS code data ForeignJSRef = ForeignJSRef { foreignRefSrcSpan :: !FastString , foreignRefPattern :: !FastString @@ -260,13 +310,13 @@ data LinkableUnit = LinkableUnit , luForeignRefs :: [ForeignJSRef] } --- one toplevel block in the object file +-- | one toplevel block in the object file data ObjUnit = ObjUnit - { oiSymbols :: ![FastString] -- toplevel symbols (stored in index) - , oiClInfo :: ![ClosureInfo] -- closure information of all closures in block - , oiStatic :: ![StaticInfo] -- static closure data - , oiStat :: !JStat -- the code - , oiRaw :: !BS.ByteString -- raw JS code + { oiSymbols :: ![FastString] -- ^ toplevel symbols (stored in index) + , oiClInfo :: ![ClosureInfo] -- ^ closure information of all closures in block + , oiStatic :: ![StaticInfo] -- ^ static closure data + , oiStat :: !JStat -- ^ the code + , oiRaw :: !BS.ByteString -- ^ raw JS code , oiFExports :: ![ExpFun] , oiFImports :: ![ForeignJSRef] } @@ -277,6 +327,7 @@ data ExpFun = ExpFun , result :: !JSFFIType } deriving (Eq, Ord, Show) +-- | Types of FFI values data JSFFIType = Int8Type | Int16Type @@ -303,6 +354,8 @@ instance Outputable TypedExpr where ppr x = text "TypedExpr: " <+> ppr (typex_expr x) $$ text "PrimReps: " <+> ppr (typex_typ x) +-- | A Primop result is either an inlining of some JS payload, or a primitive +-- call to a JS function defined in Shim files in base. data PrimRes = PrimInline JStat -- ^ primop is inline, result is assigned directly | PRPrimCall JStat -- ^ primop is async call, primop returns the next @@ -316,16 +369,17 @@ data ExprResult newtype ExprValData = ExprValData [JExpr] deriving newtype (Eq) --- closure types +-- | A Closure is one of six types data ClosureType - = Thunk - | Fun - | Pap - | Con - | Blackhole - | StackFrame + = Thunk -- ^ The closure is a THUNK + | Fun -- ^ The closure is a Function + | Pap -- ^ The closure is a Partial Application + | Con -- ^ The closure is a Constructor + | Blackhole -- ^ The closure is a Blackhole + | StackFrame -- ^ The closure is a stack frame deriving (Show, Eq, Ord, Enum, Bounded) +-- | Convert 'ClosureType' to an Int ctNum :: ClosureType -> Int ctNum Fun = 1 ctNum Con = 2 @@ -334,6 +388,7 @@ ctNum Pap = 3 ctNum Blackhole = 5 ctNum StackFrame = -1 +-- | Convert 'ClosureType' to a String ctJsName :: ClosureType -> String ctJsName = \case Thunk -> "CLOSURE_TYPE_THUNK" @@ -347,13 +402,15 @@ instance ToJExpr ClosureType where toJExpr e = toJExpr (ctNum e) +-- | A thread is in one of 4 states data ThreadStatus - = Running - | Blocked - | Finished - | Died + = Running -- ^ The thread is running + | Blocked -- ^ The thread is blocked + | Finished -- ^ The thread is done + | Died -- ^ The thread has died deriving (Show, Eq, Ord, Enum, Bounded) +-- | Convert the status of a thread in JS land to an Int threadStatusNum :: ThreadStatus -> Int threadStatusNum = \case Running -> 0 @@ -361,6 +418,7 @@ threadStatusNum = \case Finished -> 16 Died -> 17 +-- | convert the status of a thread in JS land to a string threadStatusJsName :: ThreadStatus -> String threadStatusJsName = \case Running -> "THREAD_RUNNING" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97437f2e30434f667a5d45e6664c95d58095628f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97437f2e30434f667a5d45e6664c95d58095628f You're receiving 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 Sep 27 18:07:06 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Tue, 27 Sep 2022 14:07:06 -0400 Subject: [Git][ghc/ghc][wip/js-staging] change JS.Transform.Idents* to use UniqDSet from Set Message-ID: <63333bca1607b_2c975751464471270@gitlab.mail> Josh Meredith pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: b679d796 by Josh Meredith at 2022-09-27T18:06:50+00:00 change JS.Transform.Idents* to use UniqDSet from Set - - - - - 5 changed files: - compiler/GHC/JS/Syntax.hs - compiler/GHC/JS/Transform.hs - compiler/GHC/StgToJS/Linker/Compactor.hs - compiler/GHC/StgToJS/Monad.hs - compiler/GHC/Types/Unique/Map.hs Changes: ===================================== compiler/GHC/JS/Syntax.hs ===================================== @@ -103,6 +103,7 @@ import GHC.Generics import GHC.Data.FastString import GHC.Utils.Monad.State.Strict +import GHC.Types.Unique import GHC.Types.Unique.Map -- | A supply of identifiers, possibly empty @@ -385,7 +386,8 @@ instance Show SaneDouble where -- | A newtype wrapper around 'FastString' for JS identifiers. newtype Ident = TxtI { itxt :: FastString } - deriving stock (Show, Typeable, Eq, Generic) + deriving stock (Show, Typeable, Eq, Generic) + deriving newtype (Uniquable) instance Ord Ident where compare (TxtI fs1) (TxtI fs2) = lexicalCompareFS fs1 fs2 ===================================== compiler/GHC/JS/Transform.hs ===================================== @@ -39,15 +39,14 @@ import qualified Data.Map as M import Text.Read (readMaybe) import Data.Functor.Identity import Control.Monad -import Data.Semigroup import Data.Bifunctor -import Data.Set (Set) -import qualified Data.Set as Set import GHC.Data.FastString import GHC.Utils.Monad.State.Strict import GHC.Utils.Panic +import GHC.Types.Unique.FM import GHC.Types.Unique.Map +import GHC.Types.Unique.DSet mapExprIdent :: (Ident -> JExpr) -> JExpr -> JExpr mapExprIdent f = fst (mapIdent f) @@ -98,50 +97,51 @@ mapIdent f = (map_expr, map_stat) ContinueStat{} -> s {-# INLINE identsS #-} -identsS :: JStat -> Set Ident +identsS :: JStat -> UniqDSet Ident identsS = \case - DeclStat i -> Set.singleton i + DeclStat i -> unitUniqDSet i ReturnStat e -> identsE e - IfStat e s1 s2 -> identsE e <> identsS s1 <> identsS s2 - WhileStat _ e s -> identsE e <> identsS s - ForInStat _ i e s -> Set.singleton i <> identsE e <> identsS s - SwitchStat e xs s -> identsE e <> foldl' (<>) Set.empty (map traverseCase xs) <> identsS s - where traverseCase (e,s) = identsE e <> identsS s - TryStat s1 i s2 s3 -> identsS s1 <> Set.singleton i <> identsS s2 <> identsS s3 - BlockStat xs -> foldl' (<>) Set.empty (map identsS xs) - ApplStat e es -> identsE e <> foldl' (<>) Set.empty (map identsE es) + IfStat e s1 s2 -> identsE e `unionUniqDSets` identsS s1 `unionUniqDSets` identsS s2 + WhileStat _ e s -> identsE e `unionUniqDSets` identsS s + ForInStat _ i e s -> unitUniqDSet i `unionUniqDSets` identsE e `unionUniqDSets` identsS s + SwitchStat e xs s -> identsE e `unionUniqDSets` foldl' unionUniqDSets emptyUniqDSet (map traverseCase xs) `unionUniqDSets` identsS s + where traverseCase (e,s) = identsE e `unionUniqDSets` identsS s + TryStat s1 i s2 s3 -> identsS s1 `unionUniqDSets` unitUniqDSet i `unionUniqDSets` identsS s2 `unionUniqDSets` identsS s3 + BlockStat xs -> foldl' unionUniqDSets emptyUniqDSet (map identsS xs) + ApplStat e es -> identsE e `unionUniqDSets` foldl' unionUniqDSets emptyUniqDSet (map identsE es) UOpStat _op e -> identsE e - AssignStat e1 e2 -> identsE e1 <> identsE e2 + AssignStat e1 e2 -> identsE e1 `unionUniqDSets` identsE e2 UnsatBlock{} -> error "identsS: UnsatBlock" LabelStat _l s -> identsS s - BreakStat{} -> Set.empty - ContinueStat{} -> Set.empty + BreakStat{} -> emptyUniqDSet + ContinueStat{} -> emptyUniqDSet {-# INLINE identsE #-} -identsE :: JExpr -> Set Ident +identsE :: JExpr -> UniqDSet Ident identsE = \case ValExpr v -> identsV v SelExpr e _i -> identsE e -- do not rename properties - IdxExpr e1 e2 -> identsE e1 <> identsE e2 - InfixExpr _ e1 e2 -> identsE e1 <> identsE e2 + IdxExpr e1 e2 -> identsE e1 `unionUniqDSets` identsE e2 + InfixExpr _ e1 e2 -> identsE e1 `unionUniqDSets` identsE e2 UOpExpr _ e -> identsE e - IfExpr e1 e2 e3 -> identsE e1 <> identsE e2 <> identsE e3 - ApplExpr e es -> identsE e <> foldl' (<>) Set.empty (map identsE es) + IfExpr e1 e2 e3 -> identsE e1 `unionUniqDSets` identsE e2 `unionUniqDSets` identsE e3 + ApplExpr e es -> identsE e `unionUniqDSets` foldl' unionUniqDSets emptyUniqDSet (map identsE es) UnsatExpr{} -> error "identsE: UnsatExpr" {-# INLINE identsV #-} -identsV :: JVal -> Set Ident +identsV :: JVal -> UniqDSet Ident identsV = \case - JVar i -> Set.singleton i - JList xs -> foldl' (<>) Set.empty (map identsE xs) - JDouble{} -> Set.empty - JInt{} -> Set.empty - JStr{} -> Set.empty - JRegEx{} -> Set.empty + JVar i -> unitUniqDSet i + JList xs -> foldl' unionUniqDSets emptyUniqDSet (map identsE xs) + JDouble{} -> emptyUniqDSet + JInt{} -> emptyUniqDSet + JStr{} -> emptyUniqDSet + JRegEx{} -> emptyUniqDSet -- nonDetEltsUniqMap doesn't introduce non-determinism because the Set ignores -- the List's ordering in favour of lexical comparisons - JHash m -> foldl' (<>) Set.empty (map (identsE . snd) $ nonDetEltsUniqMap m) - JFunc args s -> Set.fromList args <> identsS s + -- foldl' (<>) Set.empty (map (identsE . snd) $ nonDetEltsUniqMap m) + JHash m -> foldUFM unionUniqDSets emptyUniqDSet (mapUFM snd . getUniqMap $ mapUniqMap identsE m) + JFunc args s -> mkUniqDSet args `unionUniqDSets` identsS s UnsatVal{} -> error "identsV: UnsatVal" ===================================== compiler/GHC/StgToJS/Linker/Compactor.hs ===================================== @@ -60,7 +60,6 @@ import Data.Map (Map) import Data.Int import qualified Data.List as List import Data.Maybe -import qualified Data.Set as S import GHC.Data.FastString import GHC.JS.Syntax @@ -451,7 +450,7 @@ buildFunId i = TxtI (mkFastString $ "h$$$f" ++ show i) -- result is ordered, does not contain duplicates findGlobals :: UniqSet FastString -> JStat -> [FastString] -findGlobals globals stat = filter isGlobal . map itxt . S.toList $ identsS stat +findGlobals globals stat = filter isGlobal . map itxt . uniqDSetToList $ identsS stat where locals = mkUniqSet (findLocals stat) isGlobal i = elementOfUniqSet i globals && not (elementOfUniqSet i locals) @@ -787,7 +786,7 @@ findDefinitions _ = [] hashSingleDefinition :: UniqSet FastString -> Ident -> JExpr -> (FastString, HashBuilder) hashSingleDefinition globals (TxtI i) expr = (i, ht 0 <> render st <> mconcat (map hobj globalRefs)) where - globalRefs = filter (`elementOfUniqSet` globals) . map itxt $ S.toList (identsE expr) + globalRefs = filter (`elementOfUniqSet` globals) . map itxt $ uniqDSetToList (identsE expr) globalMap = listToUniqMap $ zip globalRefs (map (mkFastString . ("h$$$global_"++) . show) [(1::Int)..]) expr' = identsE' (\i@(TxtI t) -> maybe i TxtI (lookupUniqMap globalMap t)) expr st = AssignStat (ValExpr (JVar (TxtI "dummy"))) expr' ===================================== compiler/GHC/StgToJS/Monad.hs ===================================== @@ -45,6 +45,8 @@ import qualified Data.Set as S import qualified Data.List as L import Data.Function +import GHC.Types.Unique.DSet + runG :: StgToJSConfig -> Module -> UniqFM Id CgStgExpr -> G a -> IO a runG config m unfloat action = State.evalStateT action (initState config m unfloat) @@ -153,9 +155,9 @@ setGlobalIdCache v = State.modify (\s -> s { gsGroup = (gsGroup s) { ggsGlobalId liftToGlobal :: JStat -> G [(Ident, Id)] liftToGlobal jst = do GlobalIdCache gidc <- getGlobalIdCache - let sids = S.filter (`M.member` gidc) (identsS jst) - cnt = M.fromListWith (+) (map (,(1::Integer)) $ S.toList sids) - sids' = L.sortBy (compare `on` (cnt M.!)) (nub' $ S.toList sids) + let sids = filterUniqDSet (`M.member` gidc) (identsS jst) + cnt = M.fromListWith (+) (map (,(1::Integer)) $ uniqDSetToList sids) + sids' = L.sortBy (compare `on` (cnt M.!)) (nub' $ uniqDSetToList sids) pure $ map (\s -> (s, snd $ gidc M.! s)) sids' nub' :: (Ord a, Eq a) => [a] -> [a] ===================================== compiler/GHC/Types/Unique/Map.hs ===================================== @@ -59,7 +59,7 @@ import Data.Maybe import Data.Data -- | Maps indexed by 'Uniquable' keys -newtype UniqMap k a = UniqMap (UniqFM k (k, a)) +newtype UniqMap k a = UniqMap { getUniqMap :: UniqFM k (k, a) } deriving (Data, Eq, Functor) type role UniqMap nominal representational View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b679d7965b40e43a8db532d71e423e27cfdd2690 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b679d7965b40e43a8db532d71e423e27cfdd2690 You're receiving 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 Sep 27 18:11:50 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 27 Sep 2022 14:11:50 -0400 Subject: [Git][ghc/ghc][master] Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <63333ce68ef92_2c9757514784793e4@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 22 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/simplCore/should_compile/T21261.hs - testsuite/tests/simplCore/should_compile/T21261.stderr - − testsuite/tests/simplCore/should_compile/T21261_pedantic.hs - − testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/stranal/should_compile/T18894.stderr - + testsuite/tests/stranal/should_run/T21717b.hs - + testsuite/tests/stranal/should_run/T21717b.stdout - testsuite/tests/stranal/should_run/all.T - testsuite/tests/stranal/sigs/T20746.stderr - testsuite/tests/stranal/sigs/T21081.stderr - testsuite/tests/stranal/sigs/T21119.stderr - + testsuite/tests/stranal/sigs/T21717.hs - + testsuite/tests/stranal/sigs/T21717.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -509,9 +509,6 @@ this transformation. So we try to limit it as much as possible: Of course both (1) and (2) are readily defeated by disguising the bottoms. -Another place where -fpedantic-bottoms comes up is during eta-reduction. -See Note [Eta reduction soundness], the bit about -fpedantic-bottoms. - 4. Note [Newtype arity] ~~~~~~~~~~~~~~~~~~~~~~~~ Non-recursive newtypes are transparent, and should not get in the way. @@ -2382,20 +2379,13 @@ case where `e` is trivial): `e = \x y. bot`. Could we relax to "*At least one call in the same trace* is with n args"? - (NB: Strictness analysis can only answer this relaxed question, not the - original formulation.) - Consider what happens for + No. Consider what happens for ``g2 c = c True `seq` c False 42`` Here, `g2` will call `c` with 2 arguments (if there is a call at all). But it is unsound to eta-reduce the arg in `g2 (\x y. e x y)` to `g2 e` when `e = \x. if x then bot else id`, because the latter will diverge when - the former would not. - - On the other hand, with `-fno-pedantic-bottoms` , we will have eta-expanded - the definition of `e` and then eta-reduction is sound - (see Note [Dealing with bottom]). - Consequence: We have to check that `-fpedantic-bottoms` is off; otherwise - eta-reduction based on demands is in fact unsound. + the former would not. Fortunately, the strictness analyser will report + "Not always called with two arguments" for `g2` and we won't eta-expand. See Note [Eta reduction based on evaluation context] for the implementation details. This criterion is tested extensively in T21261. @@ -2541,7 +2531,7 @@ Then this is how the pieces are put together: Because it's irrelevant! When we simplify an expression, we do so under the assumption that it is currently under evaluation.) This sub-demand literally says "Whenever this expression is evaluated, it - is also called with two arguments, potentially multiple times". + is called with at least two arguments, potentially multiple times". * Then the simplifier takes apart the lambda and simplifies the lambda group and then calls 'tryEtaReduce' when rebuilding the lambda, passing the ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1643,11 +1643,7 @@ rebuildLam env bndrs body cont mb_rhs = contIsRhs cont -- See Note [Eta reduction based on evaluation context] - eval_sd - | sePedanticBottoms env = topSubDmd - -- See Note [Eta reduction soundness], criterion (S) - -- the bit about -fpedantic-bottoms - | otherwise = contEvalContext cont + eval_sd = contEvalContext cont -- NB: cont is never ApplyToVal, because beta-reduction would -- have happened. So contEvalContext can panic on ApplyToVal. ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -598,26 +598,6 @@ multCard (Card a) (Card b) bit1 = (a .&. b) .&. 0b010 bitN = (a .|. b) .&. shiftL bit1 1 .&. 0b100 --- | Denotes '∪' on lower and '+' on upper bounds of 'Card'. -lubPlusCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -lubPlusCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .|. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = ((a .|. b) .|. shiftL (a .&. b) 1) .&. 0b100 - --- | Denotes '+' on lower and '∪' on upper bounds of 'Card'. -plusLubCard :: Card -> Card -> Card --- See Note [Algebraic specification for plusCard and multCard] -plusLubCard (Card a) (Card b) - = Card (bit0 .|. bit1 .|. bitN) - where - bit0 = (a .&. b) .&. 0b001 - bit1 = (a .|. b) .&. 0b010 - bitN = (a .|. b) .&. 0b100 - {- ************************************************************************ * * @@ -626,11 +606,11 @@ plusLubCard (Card a) (Card b) ************************************************************************ -} --- | A demand describes a /scaled evaluation context/, e.g. how many times --- and how deep the denoted thing is evaluated. +-- | A demand describes +-- +-- * How many times a variable is evaluated, via a 'Card'inality, and +-- * How deep its value was evaluated in turn, via a 'SubDemand'. -- --- The "how many" component is represented by a 'Card'inality. --- The "how deep" component is represented by a 'SubDemand'. -- Examples (using Note [Demand notation]): -- -- * 'seq' puts demand @1A@ on its first argument: It evaluates the argument @@ -674,8 +654,8 @@ viewDmdPair BotDmd = (C_10, botSubDmd) viewDmdPair AbsDmd = (C_00, botSubDmd) viewDmdPair (D n sd) = (n, sd) --- | @c :* sd@ is a demand that says \"evaluated @c@ times, and each time it --- was evaluated, it was at least as deep as @sd@\". +-- | @c :* sd@ is a demand that says \"evaluated @c@ times, and any trace in +-- which it is evaluated will evaluate at least as deep as @sd@\". -- -- Matching on this pattern synonym is a complete match. -- If the matched demand was 'AbsDmd', it will match as @C_00 :* seqSubDmd at . @@ -695,8 +675,9 @@ pattern n :* sd <- (viewDmdPair -> (n, sd)) where n :* sd = D n sd & assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) {-# COMPLETE (:*) #-} --- | A sub-demand describes an /evaluation context/, e.g. how deep the --- denoted thing is evaluated. See 'Demand' for examples. +-- | A sub-demand describes an /evaluation context/ (in the sense of an +-- operational semantics), e.g. how deep the denoted thing is going to be +-- evaluated. See 'Demand' for examples. -- -- See Note [SubDemand denotes at least one evaluation] for a more detailed -- description of what a sub-demand means. @@ -714,14 +695,17 @@ data SubDemand -- @Poly b n@ is semantically equivalent to @Prod b [n :* Poly b n, ...] -- or @Call n (Poly Boxed n)@. 'viewCall' and 'viewProd' do these rewrites. -- - -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === CL(L)@, - -- @B === P(B,B,...)@ and @B === CB(B)@, - -- @!A === !P(A,A,...)@ and @!A === !CA(B)@, + -- In Note [Demand notation]: @L === P(L,L,...)@ and @L === C(L)@, + -- @B === P(B,B,...)@ and @B === C(B)@, + -- @!A === !P(A,A,...)@ and @!A === C(A)@, -- and so on. -- -- We'll only see 'Poly' with 'C_10' (B), 'C_00' (A), 'C_0N' (L) and sometimes -- 'C_1N' (S) through 'plusSubDmd', never 'C_01' (M) or 'C_11' (1) (grep the -- source code). Hence 'CardNonOnce', which is closed under 'lub' and 'plus'. + -- + -- Why doesn't this constructor simply carry a 'Demand' instead of its fields? + -- See Note [Call SubDemand vs. evaluation Demand]. | Call !CardNonAbs !SubDemand -- ^ @Call n sd@ describes the evaluation context of @n@ function -- applications (with one argument), where the result of each call is @@ -803,7 +787,7 @@ viewProd _ _ -- equality @Call C_0N (Poly C_0N) === Poly C_0N@, simplifying to 'Poly' 'SubDemand's -- when possible. mkCall :: CardNonAbs -> SubDemand -> SubDemand -mkCall C_1N sd@(Poly Boxed C_1N) = sd +--mkCall C_1N sd@(Poly Boxed C_1N) = sd -- NO! #21085 strikes. See Note [mkCall and plusSubDmd] mkCall C_0N sd@(Poly Boxed C_0N) = sd mkCall n sd = assertPpr (isCardNonAbs n) (ppr n $$ ppr sd) $ Call n sd @@ -838,17 +822,6 @@ unboxDeeplyDmd BotDmd = BotDmd unboxDeeplyDmd dmd@(D n sd) | isStrict n = D n (unboxDeeplySubDmd sd) | otherwise = dmd -multSubDmd :: Card -> SubDemand -> SubDemand -multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod --- The following three equations don't have an impact on Demands, only on --- Boxity. They are needed so that we don't trigger the assertions in `:*` --- when called from `multDmd`. -multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` -multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` -multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality -multSubDmd n (Poly b m) = Poly b (multCard n m) -multSubDmd n (Call n' sd) = mkCall (multCard n n') sd -multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) multDmd :: Card -> Demand -> Demand multDmd C_11 dmd = dmd -- An optimisation @@ -866,170 +839,85 @@ multDmd n BotDmd = if isStrict n then BotDmd else AbsDmd -- See Note [SubDemand denotes at least one evaluation] for the strictifyCard multDmd n (D m sd) = multCard n m :* multSubDmd (strictifyCard n) sd -{- Note [Manual specialisation of lub*Dmd/plus*Dmd] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -As Note [SubDemand denotes at least one evaluation] points out, we need all 4 -different combinations of lub/plus demand operations on upper and lower bounds - lubDmd, plusDmd, lubPlusDmd, plusLubDmd -and the same for lubSubDmd, etc. In order to share as much code as possible -and for the programmer to see immediately how the operations differ, we have -one implementation of opDmd (and opSubDmd) that dispatches on a 'OpMode'. - -For good perf, we specialise this one implementation to the four different -modes. So ideally we'd write -``` -lubSubDmd = opSubDmd (Lub, Lub) -opSubDmd (l, u) = ... opSubDmd ... -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -But unfortunately, 'opSubDmd' will be picked as a loop-breaker and thus never -inline into 'lubSubDmd', so its body will never actually be specialised for -the op mode `(Lub, Lub)`. So instead we write -``` -lubSubDmd = opSubDmdInl (Lub, Lub) -opSubDmdInl (l, u) = ... opSubDmd ... -{-# INLINE opSubDmdInl #-} -opSubDmd = opSubDmdInl -{-# RULES "lubSubDmd" forall l r. opSubDmd (Lub, Lub) = lubSubDmd #-} -``` -Here, 'opSubDmdInl' will not be picked as the loop-breaker and thus inline into -'lubSubDmd' and 'opSubDmd'. Since the latter will never inline, we'll specialise -all call sites of 'opSubDmd' for the proper op mode. A nice trick! --} - -data LubOrPlus = Lub | Plus deriving Show -instance Outputable LubOrPlus where ppr = text . show - --- | Determines whether to use 'LubOrPlus' for lower bounds and upper bounds, --- respectively. See Note [Manual specialisation of lub*Dmd/plus*Dmd]. -type OpMode = (LubOrPlus, LubOrPlus) +multSubDmd :: Card -> SubDemand -> SubDemand +multSubDmd C_11 sd = sd -- An optimisation, for when sd is a deep Prod +-- The following three equations don't have an impact on Demands, only on +-- Boxity. They are needed so that we don't trigger the assertions in `:*` +-- when called from `multDmd`. +multSubDmd C_00 _ = seqSubDmd -- Otherwise `multSubDmd A L == A /= !A` +multSubDmd C_10 (Poly _ n) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise `multSubDmd B L == B /= !B` +multSubDmd C_10 (Call n _) = if isStrict n then botSubDmd else seqSubDmd -- Otherwise we'd call `mkCall` with absent cardinality +multSubDmd n (Poly b m) = Poly b (multCard n m) +multSubDmd n (Call n' sd) = mkCall (multCard n n') sd +multSubDmd n (Prod b ds) = mkProd b (strictMap (multDmd n) ds) --- | Denotes '∪' on 'SubDemand'. -lubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubSubDmd l r = opSubDmdInl (Lub, Lub) l r +lazifyIfStrict :: Card -> SubDemand -> SubDemand +lazifyIfStrict n sd = multSubDmd (glbCard C_01 n) sd -- | Denotes '∪' on 'Demand'. lubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubDmd l r = opDmdInl (Lub, Lub) l r +lubDmd BotDmd dmd2 = dmd2 +lubDmd dmd1 BotDmd = dmd1 +lubDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "lubDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + lubCard n1 n2 :* lubSubDmd sd1 sd2 --- | Denotes '+' on 'SubDemand'. -plusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusSubDmd l r = opSubDmdInl (Plus, Plus) l r +lubSubDmd :: SubDemand -> SubDemand -> SubDemand +-- Shortcuts for neutral and absorbing elements. +-- Below we assume that Boxed always wins. +lubSubDmd (Poly Unboxed C_10) sd = sd +lubSubDmd sd (Poly Unboxed C_10) = sd +lubSubDmd sd@(Poly Boxed C_0N) _ = sd +lubSubDmd _ sd@(Poly Boxed C_0N) = sd +-- Handle Prod +lubSubDmd (Prod b1 ds1) (Poly b2 n2) + | let !d = polyFieldDmd b2 n2 + = mkProd (lubBoxity b1 b2) (strictMap (lubDmd d) ds1) +lubSubDmd (Prod b1 ds1) (Prod b2 ds2) + | equalLength ds1 ds2 + = mkProd (lubBoxity b1 b2) (strictZipWith lubDmd ds1 ds2) +-- Handle Call +lubSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (lubCard n1 n2) (lubSubDmd sd1 sd2) +-- Handle Poly +lubSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (lubCard n1 n2) +-- Other Poly case by commutativity +lubSubDmd sd1 at Poly{} sd2 = lubSubDmd sd2 sd1 +-- Otherwise (Call `lub` Prod) return Top +lubSubDmd _ _ = topSubDmd -- | Denotes '+' on 'Demand'. plusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusDmd l r = opDmdInl (Plus, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -lubPlusSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusSubDmd l r = opSubDmdInl (Lub, Plus) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'Demand'. -lubPlusDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -lubPlusDmd l r = opDmdInl (Lub, Plus) l r - --- | Denotes '+' on lower bounds and '∪' on upper bounds on 'SubDemand'. -plusLubSubDmd :: SubDemand -> SubDemand -> SubDemand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubSubDmd l r = opSubDmdInl (Plus, Lub) l r - --- | Denotes '∪' on lower bounds and '+' on upper bounds on 'SubDemand'. -plusLubDmd :: Demand -> Demand -> Demand --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -plusLubDmd l r = opDmdInl (Plus, Lub) l r - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -{-# RULES "lubSubDmd" opSubDmd (Lub, Lub) = lubSubDmd #-} -{-# RULES "lubDmd" opDmd (Lub, Lub) = lubDmd #-} -{-# RULES "plusSubDmd" opSubDmd (Plus, Plus) = plusSubDmd #-} -{-# RULES "plusDmd" opDmd (Plus, Plus) = plusDmd #-} -{-# RULES "lubPlusSubDmd" opSubDmd (Lub, Plus) = lubPlusSubDmd #-} -{-# RULES "lubPlusDmd" opDmd (Lub, Plus) = lubPlusDmd #-} -{-# RULES "plusLubSubDmd" opSubDmd (Plus, Lub) = plusLubSubDmd #-} -{-# RULES "plusLubDmd" opDmd (Plus, Lub) = plusLubDmd #-} - --- --- And now the actual implementation that is to be specialised: --- +plusDmd AbsDmd dmd2 = dmd2 +plusDmd dmd1 AbsDmd = dmd1 +plusDmd (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "plusDmd" (\it -> ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ + -- Why lazify? See Note [SubDemand denotes at least one evaluation] + -- and also Note [Unrealised opportunity in plusDmd] which applies when both + -- n1 and n2 are lazy already + plusCard n1 n2 :* plusSubDmd (lazifyIfStrict n1 sd1) (lazifyIfStrict n2 sd2) -neutralCard :: OpMode -> Card -neutralCard (Lub, _) = C_10 -neutralCard (Plus, _) = C_00 -{-# INLINE neutralCard #-} - -absorbingCard :: OpMode -> Card -absorbingCard (Lub, _) = C_0N -absorbingCard (Plus, _) = C_1N -{-# INLINE absorbingCard #-} - -opCard :: OpMode -> Card -> Card -> Card -opCard (Lub, Lub) = lubCard -opCard (Lub, Plus) = lubPlusCard -opCard (Plus, Lub) = plusLubCard -opCard (Plus, Plus) = plusCard -{-# INLINE opCard #-} - -opDmdInl, opDmd :: OpMode -> Demand -> Demand -> Demand -opDmdInl m (n1 :* _) dmd2 | n1 == neutralCard m = dmd2 -opDmdInl m dmd1 (n2 :* _) | n2 == neutralCard m = dmd1 -opDmdInl m@(l,u) (n1 :* sd1) (n2 :* sd2) = -- pprTraceWith "opDmd" (\it -> ppr l <+> ppr u $$ ppr (n1:*sd1) $$ ppr (n2:*sd2) $$ ppr it) $ - opCard m n1 n2 :* case l of - Lub -> opSubDmd m sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, u) sd1 sd2 -- (D1) - (True, False) -> opSubDmd (Plus, u) sd1 (lazifySubDmd sd2) -- (D2) - (False, True) -> opSubDmd (Plus, u) (lazifySubDmd sd1) sd2 -- (D2) - (False, False) -> opSubDmd (Lub, u) sd1 sd2 -- (D3) - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opDmd = opDmdInl -{-# INLINE opDmdInl #-} -{-# NOINLINE opDmd #-} - -opSubDmdInl, opSubDmd :: OpMode -> SubDemand -> SubDemand -> SubDemand +plusSubDmd :: SubDemand -> SubDemand -> SubDemand -- Shortcuts for neutral and absorbing elements. -- Below we assume that Boxed always wins. -opSubDmdInl m (Poly Unboxed n) sd | n == neutralCard m = sd -opSubDmdInl m sd (Poly Unboxed n) | n == neutralCard m = sd -opSubDmdInl m sd@(Poly Boxed n) _ | n == absorbingCard m = sd -opSubDmdInl m _ sd@(Poly Boxed n) | n == absorbingCard m = sd +plusSubDmd (Poly Unboxed C_00) sd = sd +plusSubDmd sd (Poly Unboxed C_00) = sd +plusSubDmd sd@(Poly Boxed C_1N) _ = sd +plusSubDmd _ sd@(Poly Boxed C_1N) = sd -- Handle Prod -opSubDmdInl m (Prod b1 ds1) (Poly b2 n2) +plusSubDmd (Prod b1 ds1) (Poly b2 n2) | let !d = polyFieldDmd b2 n2 - = mkProd (lubBoxity b1 b2) (strictMap (opDmd m d) ds1) -opSubDmdInl m (Prod b1 ds1) (Prod b2 ds2) + = mkProd (lubBoxity b1 b2) (strictMap (plusDmd d) ds1) +plusSubDmd (Prod b1 ds1) (Prod b2 ds2) | equalLength ds1 ds2 - = mkProd (lubBoxity b1 b2) (strictZipWith (opDmd m) ds1 ds2) + = mkProd (lubBoxity b1 b2) (strictZipWith plusDmd ds1 ds2) -- Handle Call -opSubDmdInl m@(l, _) (Call n1 sd1) (viewCall -> Just (n2, sd2)) = - mkCall (opCard m n1 n2) $! case l of - Lub -> opSubDmd (Lub, Lub) sd1 sd2 - -- For Plus, there are four special cases due to strictness demands and - -- Note [SubDemand denotes at least one evaluation]. Usage is always lubbed: - Plus -> case (isStrict n1, isStrict n2) of - (True, True) -> opSubDmd (Plus, Lub) sd1 sd2 -- (C3) - (False, True) -> opSubDmd (Plus, Lub) (lazifySubDmd sd1) sd2 -- (C2) - (True, False) -> opSubDmd (Plus, Lub) sd1 (lazifySubDmd sd2) -- (C2) - (False, False) -> opSubDmd (Lub, Lub) sd1 sd2 -- (C1) +plusSubDmd (Call n1 sd1) (viewCall -> Just (n2, sd2)) = + mkCall (plusCard n1 n2) (lubSubDmd sd1 sd2) -- Handle Poly -opSubDmdInl m (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (opCard m n1 n2) +plusSubDmd (Poly b1 n1) (Poly b2 n2) = Poly (lubBoxity b1 b2) (plusCard n1 n2) -- Other Poly case by commutativity -opSubDmdInl m sd1 at Poly{} sd2 = opSubDmd m sd2 sd1 --- Otherwise (Call `op` Prod) return Top -opSubDmdInl _ _ _ = topSubDmd - --- See Note [Manual specialisation of lub*Dmd/plus*Dmd] -opSubDmd = opSubDmdInl -{-# INLINE opSubDmdInl #-} -{-# NOINLINE opSubDmd #-} +plusSubDmd sd1 at Poly{} sd2 = plusSubDmd sd2 sd1 +-- Otherwise (Call `plus` Prod) return Top +plusSubDmd _ _ = topSubDmd -- | Used to suppress pretty-printing of an uninformative demand isTopDmd :: Demand -> Bool @@ -1129,11 +1017,6 @@ strictifyDictDmd _ dmd = dmd lazifyDmd :: Demand -> Demand lazifyDmd = multDmd C_01 - --- | Make a 'SubDemand' lazy. -lazifySubDmd :: SubDemand -> SubDemand -lazifySubDmd = multSubDmd C_01 - -- | Wraps the 'SubDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCalledOnceDmd :: SubDemand -> SubDemand mkCalledOnceDmd sd = mkCall C_11 sd @@ -1166,7 +1049,7 @@ subDemandIfEvaluated (_ :* sd) = sd mkWorkerDemand :: Int -> Demand mkWorkerDemand n = C_01 :* go n where go 0 = topSubDmd - go n = Call C_01 $ go (n-1) + go n = mkCall C_01 $ go (n-1) argsOneShots :: DmdSig -> Arity -> [[OneShotInfo]] -- ^ See Note [Computing one-shot info] @@ -1242,22 +1125,24 @@ NB: The Premise only makes a difference for lower bounds/strictness. Upper bounds/usage are unaffected by adding or leaving out evaluations that never happen. -So if `x` was demanded with `LP(1L)`, so perhaps `` was - f1 x = (x `seq` case x of (a,b) -> a, True) -then `x` will be evaluated lazily, but any time `x` is evaluated, `e` is -evaluated with sub-demand `P(1L)`, e.g., the first field of `e` is evaluated -strictly, too. - -How does the additional strictness help? The long version is in #21081. +The Premise comes into play when we have lazy Demands. For example, if `x` was +demanded with `LP(SL,A)`, so perhaps the full expression was + let x = (e1, e2) in (x `seq` fun y `seq` case x of (a,b) -> a, True) +then `x` will be evaluated lazily, but in any trace in which `x` is evaluated, +the pair in its RHS will ultimately be evaluated deeply with sub-demand +`P(SL,A)`. That means that `e1` is ultimately evaluated strictly, even though +evaluation of the field does not directly follow the eval of `x` due to the +intermittent call `fun y`. + +How does the additional strictness help? The long version is the list of +examples at the end of this Note (as procured in #21081 and #18903). The short version is - * We get to take advantage of call-by-value/let-to-case in more situations. - See example "More let-to-case" below. + * We get to take advantage of call-by-value/let-to-case in more situations, + as for e1 above. See example "More let-to-case" below. * Note [Eta reduction based on evaluation context] applies in more situations. See example "More eta reduction" below. * We get to unbox more results, see example "More CPR" below. - * We prevent annoying issues with `Poly` equalities, #21085. In short, we'd get - `L + S = S = CS(S) < CS(L) = C(L+S)(LuS) = L + CS(S)` although `S = CS(S)`. It seems like we don't give up anything in return. Indeed that is the case: @@ -1271,47 +1156,26 @@ It seems like we don't give up anything in return. Indeed that is the case: well as when expanding absent 'Poly's to 'Call' sub-demands in 'viewCall'. Of course, we now have to maintain the Premise when we unpack and rebuild -SubDemands. For strict demands, we know that the Premise indeed always holds for +Demands. For strict demands, we know that the Premise indeed always holds for any program trace abstracted over, whereas we have to be careful for lazy demands. -That makes for a strange definition of `plusDmd`, where we use `plusSubDmd` -throughout for upper bounds (every eval returns the same, memoised heap object), -but what we do on lower bounds depends on the strictness of both arguments: - - D1 `plusSubDmd` on the nested SubDemands if both args are strict. - D2 `plusSubDmd` on the nested SubDemands if one of them is lazy, which we - *lazify* before (that's new), so that e.g. - `LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L)` - Multiplying with `M`/`C_01` is the "lazify" part here. - Example proving that point: - d2 :: - d2 x y = y `seq` (case x of (a,b) -> a, True) - -- What is demand on x in (d2 x x)? NOT SP(SL)!! - D3 `lubPlusSubDmd` on the nested SubDemands if both args are lazy. - This new operation combines `lubSubDmd` on lower bounds with `plusSubDmd` - on upper bounds. - Examples proving that point: - d3 :: - d3 x y = (case x of (a,b) -> a, y `seq` ()) - -- What is demand on x in `snd (d3 x x)`? - -- Not LP(SL)!! d3 might evaluate second argument but not first. - -- Lub lower bounds because we might evaluate one OR the other. - -Similarly, in the handling of Call SubDemands `Cn(sd)` in `plusSubDmd`, we use -`lub` for upper bounds (because every call returns a fresh heap object), but -what we do for lower bounds depends on whether the outer `n`s are strict: - - C1 `lubSubDmd` on the nested SubDemands if both args are lazy. - C2 `plusLubSubDmd` on the nested `sd`s if one of the `n`s is lazy. That one's - nested `sd` we *lazify*, so that e.g. - `CL(SL) + CS(L) = C(L+S)((M*SL)+L) = CS(L+L) = CS(L)` - `plusLubSubDmd` combines `plusSubDmd` on lower bounds with `lubSubDmd` on - upper bounds. - C3 `plusLubSubDmd` on the nested SubDemands if both args are strict. - -There are a couple of other examples in T21081. -Here is a selection of examples demonstrating the -usefulness of The Premise: + +In particular, when doing `plusDmd` we have to *lazify* the nested SubDemand +if the outer cardinality is lazy. E.g., + LP(SL) + SP(L) = (L+S)P((M*SL)+L) = SP(L+L) = SP(L) +Multiplying with `M`/`C_01` is the "lazify" part here and is implemented in +`lazifyIfStrict`. Example proving that point: + d2 :: + d2 x y = y `seq` (case x of (a,b) -> a, True) + -- What is the demand on x in (d2 x x)? NOT SP(SL)!! + +We used to apply the same reasoning to Call SubDemands `Cn(sd)` in `plusSubDmd`, +but that led to #21717, because different calls return different heap objects. +See Note [Call SubDemand vs. evaluation Demand]. + +There are a couple more examples that improve in T21081. +Here is a selection of those examples demonstrating the usefulness of The +Premise: * "More let-to-case" (from testcase T21081): ```hs @@ -1355,6 +1219,102 @@ usefulness of The Premise: pair. That in turn means that Nested CPR can unbox the result of the division even though it might throw. +Note [Unrealised opportunity in plusDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Recall the lazification of SubDemands happening in `plusDmd` as described in +Note [SubDemand denotes at least one evaluation]. + +We *could* do better when both Demands are lazy already. Example + (fun 1, fun 2) +Both args put Demand SCS(L) on `fun`. The lazy pair arg context lazifies +this to LCS(L), and it would be reasonable to report this Demand on `fun` for +the entire pair expression; after all, `fun` is called whenever it is evaluated. +But our definition of `plusDmd` will compute + LCS(L) + LCS(L) = (L+L)(M*CS(L) + M*CS(L)) = L(CL(L)) = L +Which is clearly less precise. +Doing better here could mean to `lub` when both demands are lazy, e.g., + LCS(L) + LCS(L) = (L+L)(CS(L) ⊔ CS(L)) = L(CS(L)) +Indeed that's what we did at one point between 9.4 and 9.6 after !7599, but it +means that we need a function `lubPlusSubDmd` that lubs on lower bounds but +plus'es upper bounds, implying maintenance challenges and complicated +explanations. + +Plus, NoFib says that this special case doesn't bring all that much +(geom. mean +0.0% counted instructions), so we don't bother anymore. + +Note [Call SubDemand vs. evaluation Demand] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Although both evaluation Demands and Call SubDemands carry a (Card,SubDemand) +pair, their interpretation is quite different. Example: + + f x = fst x * snd x + -- f :: , because 1P(1L,A)+1P(A,1L) = SP(1L,1L) + g x = fst (x 1) * snd (x 2) + -- g :: , because 1C1(P(1L,A))+1C1(P(A,1L)) = SCS(P(ML,ML)) + +The point about this example is that both demands have P(A,1L)/P(1L,A) as +sub-expressions, but when these sub-demands occur + + 1. under an evaluation demand, we combine with `plusSubDmd` + 2. whereas under a Call sub-demand, we combine with `lubSubDmd` + +And thus (1) yields a stricter demand on the pair components than (2). + +In #21717 we saw that we really need lub in (2), because otherwise we make an +unsound prediction in `g (\n -> if n == 1 then (1,1) else (bot,2))`; we'd say +that the `bot` expression is always evaluated, when it clearly is not. +Operationally, every call to `g` gives back a potentially distinct, +heap-allocated pair with potentially different contents, and we must `lubSubDmd` +over all such calls to approximate how any of those pairs might be used. + +That is in stark contrast to f's argument `x`: Operationally, every eval of +`x` must yield the same pair and `f` evaluates both components of that pair. +The theorem "every eval of `x` returns the same heap object" is a very strong +MUST-alias property and we capitalise on that by using `plusSubDmd` in (1). + +And indeed we *must* use `plusSubDmd` in (1) for sound upper bounds in an +analysis that assumes call-by-need (as opposed to the weaker call-by-name) for +let bindings. Consider + + h x = fst x * fst x + -- h :: + +And the expression `let a=1; p=(a,a)} in h p`. Here, *although* the RHS of `p` +is only evaluated once under call-by-need, `a` is still evaluated twice. +If we had used `lubSubDmd`, we'd see SP(1L,A) and the 1L unsoundly says "exactly +once". + +If the analysis had assumed call-by-name, it would be sound to say "a is used +once in p": p is used multiple times and hence so would a, as if p was a +function. So using `plusSubDmd` does not only yield better strictness, it is +also "holding up the other end of the bargain" of the call-by-need assumption +for upper bounds. + +(To SG's knowledge, the distinction between call-by-name and call-by-need does +not matter for strictness analysis/lower bounds, thus it would be sound to use +`lubSubDmd` all the time there.) + +Note [mkCall and plusSubDmd] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We never rewrite a strict, non-absent Call sub-demand like CS(S) to a +polymorphic sub-demand like S, otherwise #21085 strikes. Consider the +following inequality (would also for M and 1 instead of L and S, but we forbid +such Polys): + + L+S = S = CS(S) < CS(L) = CL(L)+CS(S) + +Note that L=CL(L). If we also had S=CS(S), we'd be in trouble: Now +`plusSubDmd` would no longer maintain the equality relation on sub-demands, +much less monotonicity. Bad! + +Clearly, `n <= Cn(n)` is unproblematic, as is `n >= Cn(n)` for any `n` +except 1 and S. But `CS(S) >= S` would mean trouble, because then we'd get +the problematic `CS(S) = S`. We have just established that `S < CS(S)`! +As such, the rewrite CS(S) to S is anti-monotone and we forbid it, first +and foremost in `mkCall` (which is the only place that rewrites Cn(n) to n). + +Crisis and #21085 averted! + Note [Computing one-shot info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a call @@ -2102,7 +2062,7 @@ If this same function is applied to one arg, all we can say is that it uses x with 1L, and its arg with demand 1P(L,L). Note [Understanding DmdType and DmdSig] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Demand types are sound approximations of an expression's semantics relative to the incoming demand we put the expression under. Consider the following expression: ===================================== testsuite/tests/arityanal/should_compile/Arity11.stderr ===================================== @@ -53,7 +53,7 @@ F11.fib1 = GHC.Num.Integer.IS 0# -- RHS size: {terms: 52, types: 26, coercions: 0, joins: 0/5} F11.$wfib [InlPrag=[2]] :: forall {t} {a}. (t -> t -> Bool) -> (Num t, Num a) => t -> a -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 150 60 0] 460 0}] F11.$wfib = \ (@t) (@a) (ww :: t -> t -> Bool) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> let { @@ -91,7 +91,7 @@ F11.$wfib fib [InlPrag=[2]] :: forall {t} {a}. (Eq t, Num t, Num a) => t -> a [GblId, Arity=4, - Str=<1P(SCS(C1(L)),A)>, + Str=<1P(SCS(C1(L)),A)>, 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= \ (@t) (@a) ($dEq [Occ=Once1!] :: Eq t) ($dNum [Occ=Once1] :: Num t) ($dNum1 [Occ=Once1] :: Num a) (eta [Occ=Once1] :: t) -> case $dEq of { GHC.Classes.C:Eq ww [Occ=Once1] _ [Occ=Dead] -> F11.$wfib @t @a ww $dNum $dNum1 eta }}] fib = \ (@t) (@a) ($dEq :: Eq t) ($dNum :: Num t) ($dNum1 :: Num a) (eta :: t) -> case $dEq of { GHC.Classes.C:Eq ww ww1 -> F11.$wfib @t @a ww $dNum $dNum1 eta } @@ -142,4 +142,7 @@ f11 :: (Integer, Integer) f11 = (F11.f4, F11.f1) +------ Local rules for imported ids -------- +"SPEC fib @Integer @Integer" forall ($dEq :: Eq Integer) ($dNum :: Num Integer) ($dNum1 :: Num Integer). fib @Integer @Integer $dEq $dNum $dNum1 = F11.f11_fib + ===================================== testsuite/tests/arityanal/should_compile/Arity14.stderr ===================================== @@ -14,7 +14,7 @@ F14.f2 = GHC.Num.Integer.IS 1# -- RHS size: {terms: 35, types: 23, coercions: 0, joins: 0/3} F14.$wf14 [InlPrag=[2]] :: forall {t}. (t -> t -> Bool) -> Num t => t -> t -> t -> t -[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] +[GblId, Arity=4, Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 90 0 0] 300 0}] F14.$wf14 = \ (@t) (ww :: t -> t -> Bool) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> let { @@ -41,7 +41,7 @@ F14.$wf14 f14 [InlPrag=[2]] :: forall {t}. (Ord t, Num t) => t -> t -> t -> t [GblId, Arity=4, - Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, + Str=<1P(A,A,SCS(C1(L)),A,A,A,A,A)>, 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= \ (@t) ($dOrd [Occ=Once1!] :: Ord t) ($dNum [Occ=Once1] :: Num t) (eta [Occ=Once1] :: t) (eta1 [Occ=Once1] :: t) -> case $dOrd of { GHC.Classes.C:Ord _ [Occ=Dead] _ [Occ=Dead] ww2 [Occ=Once1] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> F14.$wf14 @t ww2 $dNum eta eta1 }}] f14 = \ (@t) ($dOrd :: Ord t) ($dNum :: Num t) (eta :: t) (eta1 :: t) -> case $dOrd of { GHC.Classes.C:Ord ww ww1 ww2 ww3 ww4 ww5 ww6 ww7 -> F14.$wf14 @t ww2 $dNum eta eta1 } ===================================== testsuite/tests/arityanal/should_compile/Arity16.stderr ===================================== @@ -5,7 +5,7 @@ Result size of Tidy Core = {terms: 53, types: 71, coercions: 0, joins: 0/0} Rec { -- RHS size: {terms: 15, types: 15, coercions: 0, joins: 0/0} map2 [Occ=LoopBreaker] :: forall {t} {a}. (t -> a) -> [t] -> [a] -[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] map2 = \ (@t) (@a) (f :: t -> a) (ds :: [t]) -> case ds of { @@ -27,7 +27,7 @@ lvl1 = Control.Exception.Base.patError @GHC.Types.LiftedRep @() lvl Rec { -- RHS size: {terms: 31, types: 32, coercions: 0, joins: 0/0} zipWith2 [Occ=LoopBreaker] :: forall {t1} {t2} {a}. (t1 -> t2 -> a) -> [t1] -> [t2] -> [a] -[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] +[GblId, Arity=3, Str=<1L><1L>, Unf=OtherCon []] zipWith2 = \ (@t) (@t1) (@a) (f :: t -> t1 -> a) (ds :: [t]) (ds1 :: [t1]) -> case ds of { ===================================== testsuite/tests/simplCore/should_compile/T21261.hs ===================================== @@ -34,18 +34,26 @@ f5 c = Just (c 1 2 + c 3 4) yes2_lazy :: (Int -> Int -> Int) -> Maybe Int yes2_lazy c = f5 (\x y -> c x y) --- These last two here are disallowed in T21261_pedantic.hs, which activates --- -fpedantic-bottoms. It would be unsound to eta reduce these bindings with --- -fpedantic-bottoms, but without it's fine to eta reduce: +-- These last two here are tricky. It is unsound to eta reduce +-- the args to f6 and f7 because we could call both functions +-- at a c like `\x -> if x == 1 then undefined else id`. +-- Note that if we do so and *do* eta-reduce, we'll see a crash! +-- Whereas we *don't* see a crash if we keep the original, +-- eta-expanded arguments. +-- +-- This is issue is discussed in Note [Eta reduction soundness], condition (S). +-- +-- This is a variant of #21717 (and tested by T21717), where +-- prior to the fix we observed an unsound strictness signature. f6 :: (Int -> Int -> Int) -> Int f6 c = c 1 `seq` c 2 3 {-# NOINLINE f6 #-} -yes_non_pedantic :: (Int -> Int -> Int) -> Int -yes_non_pedantic c = f6 (\x y -> c x y) +no_tricky :: (Int -> Int -> Int) -> Int +no_tricky c = f6 (\x y -> c x y) f7 :: (Int -> Int -> Int) -> Maybe Int f7 c = Just (c 1 `seq` c 3 4) {-# NOINLINE f7 #-} -yes_non_pedantic_lazy :: (Int -> Int -> Int) -> Maybe Int -yes_non_pedantic_lazy c = f7 (\x y -> c x y) +no_tricky_lazy :: (Int -> Int -> Int) -> Maybe Int +no_tricky_lazy c = f7 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 166, types: 176, coercions: 0, joins: 0/0} + = {terms: 182, types: 191, coercions: 0, joins: 0/0} lvl = I# 3# @@ -29,13 +29,14 @@ no3 f6 = \ c -> case c lvl2 of { __DEFAULT -> c lvl3 lvl } -yes_non_pedantic = f6 +no_tricky = \ c -> f6 (\ x y -> c x y) $wf7 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl lvl1 } #) f7 = \ c -> case $wf7 c of { (# ww #) -> Just ww } -yes_non_pedantic_lazy = f7 +no_tricky_lazy + = \ c -> case $wf7 (\ x y -> c x y) of { (# ww #) -> Just ww } $wf5 = \ c -> ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.hs deleted ===================================== @@ -1,18 +0,0 @@ -{-# OPTIONS_GHC -fpedantic-bottoms #-} -- This flag must inhibit eta reduction based on demands - -module T21261_pedantic where - --- README: See T21261. These examples absolutely should not eta reduce with --- -fpedantic-bottoms. - -f1 :: (Int -> Int -> Int) -> Int -f1 c = c 1 `seq` c 2 3 -{-# NOINLINE f1 #-} -no2 :: (Int -> Int -> Int) -> Int -no2 c = f1 (\x y -> c x y) - -f2 :: (Int -> Int -> Int) -> Maybe Int -f2 c = Just (c 1 `seq` c 3 4) -{-# NOINLINE f2 #-} -no2_lazy :: (Int -> Int -> Int) -> Maybe Int -no2_lazy c = f2 (\x y -> c x y) ===================================== testsuite/tests/simplCore/should_compile/T21261_pedantic.stderr deleted ===================================== @@ -1,26 +0,0 @@ - -==================== Tidy Core ==================== -Result size of Tidy Core - = {terms: 59, types: 63, coercions: 0, joins: 0/0} - -lvl = I# 2# - -lvl1 = I# 3# - -lvl2 = I# 1# - -f1 = \ c -> case c lvl2 of { __DEFAULT -> c lvl lvl1 } - -no2 = \ c -> f1 (\ x y -> c x y) - -lvl3 = I# 4# - -$wf2 = \ c -> (# case c lvl2 of { __DEFAULT -> c lvl1 lvl3 } #) - -f2 = \ c -> case $wf2 c of { (# ww #) -> Just ww } - -no2_lazy - = \ c -> case $wf2 (\ x y -> c x y) of { (# ww #) -> Just ww } - - - ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -407,8 +407,7 @@ test('T21144', normal, compile, ['-O']) test('T20040', [ grep_errmsg(r'ifoldl\'') ], compile, ['-O -ddump-stg-final -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # Key here is that yes* become visibly trivial due to eta-reduction, while no* are not eta-reduced. -test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) -test('T21261_pedantic', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) +test('T21261', [ grep_errmsg(r'^(yes|no)') ], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) # We expect to see a SPEC rule for $cm test('T17966', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-spec']) ===================================== testsuite/tests/stranal/should_compile/T18894.stderr ===================================== @@ -147,7 +147,7 @@ lvl :: (Int, Int) lvl = (lvl, lvl) -- RHS size: {terms: 36, types: 10, coercions: 0, joins: 0/1} -g1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] :: Int -> (Int, Int) +g1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: Int -> (Int, Int) [LclId, Arity=1, Str=<1!P(1L)>, @@ -266,7 +266,7 @@ lvl = GHC.Types.I# 0# -- RHS size: {terms: 39, types: 17, coercions: 0, joins: 0/1} $wg2 [InlPrag=NOINLINE, Dmd=LCS(C1(!P(M!P(L),1!P(L))))] :: Int -> GHC.Prim.Int# -> (# Int, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=2, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -328,9 +328,9 @@ h2 } -- RHS size: {terms: 34, types: 14, coercions: 0, joins: 0/1} -$wg1 [InlPrag=NOINLINE, Dmd=LCS(!P(L,L))] +$wg1 [InlPrag=NOINLINE, Dmd=LCL(!P(L,L))] :: GHC.Prim.Int# -> (# GHC.Prim.Int#, Int #) -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, @@ -367,7 +367,7 @@ lvl = case $wg1 2# of { (# ww, ww #) -> (GHC.Types.I# ww, ww) } -- RHS size: {terms: 22, types: 16, coercions: 0, joins: 0/0} $wh1 [InlPrag=[2], Dmd=LCS(!P(L))] :: GHC.Prim.Int# -> Int -[LclId, +[LclId[StrictWorker([])], Arity=1, Str=<1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, ===================================== testsuite/tests/stranal/should_run/T21717b.hs ===================================== @@ -0,0 +1,19 @@ +import System.Environment +import GHC.Exts + +g :: (Int -> (Int, Int)) -> Int +-- Should *not* infer strictness SCS(P(SL,SL)) for h +-- Otherwise `main` could use CbV on the error exprs below +g h = fst (h 0) + snd (h 1) +{-# NOINLINE g #-} + +main = do + m <- length <$> getArgs + -- The point here is that we print "1". + -- That means we may *not* use CbV/let-to-case on err! + -- GHC.Exts.lazy so that we don't lambda lift and float out the + -- obviously bottoming RHS (where it is no longer used strictly). + let err = GHC.Exts.lazy $ error (show m) + let f n | even n = (n+m, err) + | otherwise = (err, n+m) + print $! g f ===================================== testsuite/tests/stranal/should_run/T21717b.stdout ===================================== @@ -0,0 +1 @@ +1 ===================================== testsuite/tests/stranal/should_run/all.T ===================================== @@ -27,3 +27,4 @@ test('T14290', normal, compile_and_run, ['']) test('T14285', normal, multimod_compile_and_run, ['T14285', '']) test('T17676', normal, compile_and_run, ['']) test('T19053', normal, compile_and_run, ['']) +test('T21717b', normal, compile_and_run, ['']) ===================================== testsuite/tests/stranal/sigs/T20746.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -Foo.f: +Foo.f: Foo.foogle: ===================================== testsuite/tests/stranal/sigs/T21081.stderr ===================================== @@ -4,7 +4,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: T21081.blurg2: T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: @@ -50,7 +50,7 @@ T21081.blah: <1!P(1L)> T21081.blurg: <1!P(SL)> T21081.blurg2: <1!P(SL)> T21081.call1: -T21081.call2: +T21081.call2: T21081.call3: T21081.call4: <1A> T21081.call5: ===================================== testsuite/tests/stranal/sigs/T21119.stderr ===================================== @@ -4,7 +4,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x @@ -24,7 +24,7 @@ T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L> -T21119.indexError: <1C1(S)><1!B>b +T21119.indexError: <1C1(L)><1!B>b T21119.throwIndexError: x ===================================== testsuite/tests/stranal/sigs/T21717.hs ===================================== @@ -0,0 +1,12 @@ +module T21717 (g) where + +-- This is the original reproducer from #21717. +-- See T21717b for a reproducer that exhibited a crash. + +f :: Bool -> (Int, Int) +f True = (42,error "m") +f False = (error "m",42) + +g :: (Bool -> (Int, Int)) -> Int +g h = fst (h True) + snd (h False) +{-# NOINLINE g #-} ===================================== testsuite/tests/stranal/sigs/T21717.stderr ===================================== @@ -0,0 +1,15 @@ + +==================== Strictness signatures ==================== +T21717.g: + + + +==================== Cpr signatures ==================== +T21717.g: 1 + + + +==================== Strictness signatures ==================== +T21717.g: + + ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Strictness signatures ==================== -T5075.f: +T5075.f: T5075.g: <1L> T5075.h: @@ -14,7 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> +T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)> T5075.g: <1L> T5075.h: <1!P(L)> ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -33,5 +33,6 @@ test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) +test('T21717', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeafdba5503b8d26a62dc7bc7078caef170d4154 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeafdba5503b8d26a62dc7bc7078caef170d4154 You're receiving 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 Sep 27 18:12:19 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 27 Sep 2022 14:12:19 -0400 Subject: [Git][ghc/ghc][master] implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) Message-ID: <63333d03e362a_2c975751400484963@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 30 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/TyThing.hs - compiler/Language/Haskell/Syntax/Decls.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/data_kinds.rst - + docs/users_guide/exts/type_data.rst - docs/users_guide/exts/types.rst - libraries/Cabal - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - testsuite/tests/driver/T4437.hs - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/parser/should_compile/T15323.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b1595c87f0c2406bb340c5e27a4a45dfcde0e2c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b1595c87f0c2406bb340c5e27a4a45dfcde0e2c You're receiving 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 Sep 27 19:32:38 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 15:32:38 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63334fd6f2593_2c97575148c494117@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 4e6af213 by Andreas Klebinger at 2022-09-27T21:31:36+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 14 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/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,206 @@ + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TupleSections #-} + +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} + +{- +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 + | 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 = [] +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r) = wordToIntRep r + in (op1, primRepToType r):[(intToMachineInt r,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)] +-- Sized to differently sized must go over 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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,75 @@ 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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 conversion +-- around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, fld_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_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 = + pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + let 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + r2 = typePrimRep1 ty2 + 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 +761,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 +776,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +931,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 +953,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 ) -------------------------------------------------------------------------------- ===================================== 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/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,4 @@ 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']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e6af213440a93d9300cc2544f428caf722d868b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e6af213440a93d9300cc2544f428caf722d868b You're receiving 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 Sep 27 20:42:54 2022 From: gitlab at gitlab.haskell.org (Dominik Peteler (@mmhat)) Date: Tue, 27 Sep 2022 16:42:54 -0400 Subject: [Git][ghc/ghc][wip/21611-move-corem] Applied suggestion: Description of Core Optimizer stages Message-ID: <6333604e1a2e8_2c9757514285058a4@gitlab.mail> Dominik Peteler pushed to branch wip/21611-move-corem at Glasgow Haskell Compiler / GHC Commits: a3e5360a by John Ericson at 2022-09-27T20:42:52+00:00 Applied suggestion: Description of Core Optimizer stages - - - - - 1 changed file: - compiler/GHC/Driver/Core/Opt.hs Changes: ===================================== compiler/GHC/Driver/Core/Opt.hs ===================================== @@ -129,8 +129,8 @@ Note [The architecture of the Core optimizer] Conceptually the Core optimizer consists of two stages: - 1. The planning stage. - 2. The execution stage. + 1. **The planning stage**: where we take the user-specified input (currently in `DynFlags`) and produce a domain-specific configuration for just this pipeline stage (a `[CoreToDo]` value). This configuration is the plan. + 2. **The execution stage**: where we we take a Core program (a `ModGuts`) and the configuration (a `[CoreToDo]`) and optimize that program according to the `[CoreToDo]` plan, producing a new `ModGuts`. This division is mirrored in the interface of the different optimizations. For each of those optimzations we have View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3e5360a3b9d45e1a9a0db0ba8dd1d1c902399b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3e5360a3b9d45e1a9a0db0ba8dd1d1c902399b3 You're receiving 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 Sep 27 21:45:42 2022 From: gitlab at gitlab.haskell.org (Dominik Peteler (@mmhat)) Date: Tue, 27 Sep 2022 17:45:42 -0400 Subject: [Git][ghc/ghc][wip/21611-move-corem] Extended Note "The architecture of the Core optimizer" Message-ID: <63336f06aaf73_2c975751414511369@gitlab.mail> Dominik Peteler pushed to branch wip/21611-move-corem at Glasgow Haskell Compiler / GHC Commits: c1c39536 by Dominik Peteler at 2022-09-27T23:45:29+02:00 Extended Note "The architecture of the Core optimizer" - - - - - 1 changed file: - compiler/GHC/Driver/Core/Opt.hs Changes: ===================================== compiler/GHC/Driver/Core/Opt.hs ===================================== @@ -129,8 +129,12 @@ Note [The architecture of the Core optimizer] Conceptually the Core optimizer consists of two stages: - 1. **The planning stage**: where we take the user-specified input (currently in `DynFlags`) and produce a domain-specific configuration for just this pipeline stage (a `[CoreToDo]` value). This configuration is the plan. - 2. **The execution stage**: where we we take a Core program (a `ModGuts`) and the configuration (a `[CoreToDo]`) and optimize that program according to the `[CoreToDo]` plan, producing a new `ModGuts`. + 1. **The planning stage**: where we take the user-specified input (currently in + `DynFlags`) and produce a domain-specific configuration for just this + pipeline stage (a `[CoreToDo]` value). This configuration is the plan. + 2. **The execution stage**: where we we take a Core program (a `ModGuts`) and + the configuration (a `[CoreToDo]`) and optimize that program according to + the `[CoreToDo]` plan, producing a new `ModGuts`. This division is mirrored in the interface of the different optimizations. For each of those optimzations we have @@ -151,19 +155,65 @@ question and derives the configuration for each pass from the session's state `GHC.Driver.Config.Core.Opt` as well. The `CoreToDo` type that is finally used to wrap this configuration value is a sum type enumerating all the optimizations available in GHC. - -The entrypoint of the second stage are the `optimizeCore*` functions found in -GHC.Driver.Core.Opt. These functions is part of the Application Layer and -utilize the `runCorePasses` function from `GHC.Core.Opt` which is the -counterpart of these functions in the Domain Layer. In other words, while the -`optimizeCore*` know about `HscEnv` and are therefore bound to a concrete -driver, `runCorePasses` is more independent as it is a component of its own. - -`runCorePasses` is essentially an interpreter for the `CoreToDo`s constructed in -the planning phase. It calls the entrypoints of the passes with their respective -configurations as arguments as well as some execution context like the unit -environment, the rules and the type family instance in scope, and most notably -the module we wish to compile (`ModGuts`). +As an example suppose we have a `DynFlags` value "dflags" with + gopt Opt_FullLaziness dflags == True + floatLamArgs dflags == Just 42 + +If we pass that dflags value to the `getCoreToDo` planning function we receive a +list like + [ ... + , CoreDoFloatOutwards FloatOutSwitches + { floatOutLambdas = Just 0 + , floatOutConstants = True + , floatOutOverSatApps = False + , floatToTopLevelOnly = False + } + , ... + , CoreDoFloatOutwards FloatOutSwitches + { floatOutLambdas = Just 42 + , floatOutConstants = True + , floatOutOverSatApps = True + , floatToTopLevelOnly = False + } + , ... + ] + +This plan contains two "instructions" to perform two FloatOut optimization +passes with the given configuration. Note that these configurations draw their +values from dflags and the planning function `getCoreToDo` alone and are +independent of the modules they might be applied to. + +The entrypoint of the second stage is the `runCorePasses` function found in +GHC.Core.Opt. It is essentially an interpreter for the `CoreToDo`s constructed +in the planning stage. It calls the entrypoints of the passes with their +respective configurations as arguments as well as some execution context like +the unit environment, the rules and the type family instance in scope, and most +notably the module we wish to compile (`ModGuts`). +Feeding the list with the two FloatOut configurations above to that function +would result in two calls of + ... + floatOutwards logger + (FloatOutSwitches { floatOutLambdas = Just 0, ... }) us binds + ... + floatOutwards logger + (FloatOutSwitches { floatOutLambdas = Just 42, ... }) us binds' + ... +where the Logger "logger" and the unique supply "us" are supplied by the +execution context of the interpreter and binds and binds' are the Core bindings +of the `ModGuts` being optimized. + +The Core Optimizer itself is invoked by calling one of the `optimizeCore*` +functions found in GHC.Driver.Core.Opt. These functions is part of the +Application Layer and utilize both the `getCoreToDo` function -- which is part +of the Application Layer as well -- and the `runCorePasses` function which is +part of the Domain Layer. Here, the terms "Application Layer" and "Domain Layer" +are terms borrowed from Domain Driven Design and its application in the context +of GHC is layed out in the "Modularizing GHC" paper +(https://hsyl20.fr/home/posts/2022-05-03-modularizing-ghc-paper.html). +In other words, while the `optimizeCore*` and `getCoreToDo` know about `HscEnv` +and `DynFlags` and are therefore bound to a concrete driver, `runCorePasses` is +more independent as it is a component of its own. As such it could be used by a +different driver that produces a plan in a completely different way. A similar split in functionality is done for the Core Linting: After each pass we may check the sanity of the resulting Core running a so-called EndPass check. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1c39536ffdd64bc55faf6abbea942cd31f7d188 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1c39536ffdd64bc55faf6abbea942cd31f7d188 You're receiving 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 Sep 27 21:52:17 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 27 Sep 2022 17:52:17 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix Message-ID: <63337091f0541_2c975753ffac51461c@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 583005ce by Matthew Pickering at 2022-09-27T22:41:09+01:00 fix - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -395,7 +395,7 @@ hadrian-multi: - root=$(pwd)/ghc - | mkdir tmp - tar -xf ../ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp pushd tmp/ghc-*/ ./configure --prefix=$root make install View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/583005ce216f14c4e1fd9e2ce3dc24e1cce68877 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/583005ce216f14c4e1fd9e2ce3dc24e1cce68877 You're receiving 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 Sep 27 22:48:52 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 18:48:52 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Add larger test for constructing/deconstructing unboxed sums Message-ID: <63337dd445821_2c97575146452649f@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 311eaf70 by Andreas Klebinger at 2022-09-28T00:47:44+02:00 Add larger test for constructing/deconstructing unboxed sums - - - - - 7 changed files: - compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Stg/Unarise.hs - + testsuite/tests/unboxedsums/GenManyUbxSums.hs - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-cmm - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-stg-final - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -1,9 +1,3 @@ - -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE TupleSections #-} - -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} - {- This module contains helpers to cast variables between different Int/WordReps in StgLand. @@ -18,6 +12,7 @@ import GHC.Prelude import GHC.Core.TyCon import GHC.Utils.Outputable import GHC.Utils.Panic +import GHC.Utils.Trace import GHC.Utils.Panic.Plain import GHC.Types.RepType import GHC.Core.Type @@ -46,9 +41,15 @@ We can use this list of primOps to construct a function of type -- | `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 +getCasts f t = + let r = getCasts' f t + in pprTrace "getCasts" (ppr (f,t,r)) r + + +getCasts' from_rep to_rep -- No-op - | to_rep == from_rep + | -- pprTrace "getCasts" (ppr (from_rep,to_rep)) $ + to_rep == from_rep = [] -- Float <-> Double | to_rep == FloatRep = @@ -93,8 +94,8 @@ wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] wordOrIntToAddrRep r | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] | primRepIsWord r = - let (op1,r) = wordToIntRep r - in (op1, primRepToType r):[(intToMachineInt r,intPrimTy), (IntToAddrOp,addrPrimTy)] + 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)] @@ -149,7 +150,7 @@ sizedWordToSizedWord r1 r2 sizedWordToSizedWord r WordRep = [(wordToMachineWord r,wordPrimTy)] -- Cast from Word# sizedWordToSizedWord WordRep r = [(wordFromMachineWord r, primRepToType r)] --- Sized to differently sized must go over machine word. +-- Conversion between different non-machine sizes must go via machine word. sizedWordToSizedWord r1 r2 = (wordToMachineWord r1,wordPrimTy) : [(wordFromMachineWord r2, primRepToType r2)] ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -708,12 +708,12 @@ mapSumIdBinders [id] args rhs rho0 -- 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 - -- ) $ + 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 typed_id_args), rhs_with_casts) else assert (typed_id_args `lengthIs` 1) @@ -725,8 +725,8 @@ mapSumIdBinders ids sum_args _rhs _ -- Convert the argument to the given type, and wrap the conversion -- around the given expression. castArgShadow :: (Id,Type) -> StgExpr -> StgExpr -castArgShadow (arg, fld_ty) (in_rhs) = - let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 fld_ty) +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 @@ -734,16 +734,21 @@ castArgShadow (arg, fld_ty) (in_rhs) = -- converted value. castArgRename :: StgArg -> Id -> StgExpr -> StgExpr castArgRename in_arg out_id in_rhs = - pprTrace "castArgRename" (ppr (in_arg,out_id)) $ - let ops = getCasts (typePrimRep1 $ stgArgType in_arg) $ typePrimRep1 (idType out_id) - in foldr (mkCast in_arg out_id) (in_rhs) ops + 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 scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + let r2 = typePrimRep1 ty2 + scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} - r2 = typePrimRep1 ty2 alt_ty = PrimAlt r2 in (StgCase scrut (setIdType out_id ty2) alt_ty [alt]) @@ -815,11 +820,11 @@ mkUbxSum dc ty_args args0 us tup_args = tag_arg : slot_args in - -- pprTrace "mkUbxSum" ( - -- text "ty_args (slots)" <+> ppr ty_args $$ - -- text "args0" <+> ppr args0 $$ - -- text "wrapper" <+> - -- (ppr $ wrapper $ StgLit $ LitChar '_') + pprTrace "mkUbxSum" ( + text "ty_args (slots)" <+> ppr ty_args $$ + text "args0" <+> ppr args0 $$ + text "wrapper" <+> + (ppr $ wrapper $ StgLit $ LitChar '_')) (tup_args, wrapper) ===================================== testsuite/tests/unboxedsums/GenManyUbxSums.hs ===================================== @@ -0,0 +1,102 @@ +#!/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 + +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 (# t1 | t2 #) and one (# t1 | t3). +-- So build all the combinations 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: +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | Addr# #) -> (# Addr# | Addr# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | Addr# #) +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 = 0 +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + "test" ++ show n ++ " =\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" + +-- Test all the tuples +mkTests n [] = "" +mkTests n (combo:combos) = + mkTest n combo ++ "\n" ++ mkTests (n+1) combos + + +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" + + -- Actually invoke all the tests + 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_Addr.debug.dump-cmm ===================================== @@ -0,0 +1,862 @@ + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810321346 UTC + +[section ""cstring" . $tc'Addr1_rYK_bytes" { + $tc'Addr1_rYK_bytes: + I8[] "'Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810616005 UTC + +[section ""cstring" . $tcAddr1_rYG_bytes" { + $tcAddr1_rYG_bytes: + I8[] "Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810861345 UTC + +[section ""cstring" . $trModule3_rYD_bytes" { + $trModule3_rYD_bytes: + I8[] "ManyUbxSums_Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.811117863 UTC + +[section ""cstring" . $trModule1_rYB_bytes" { + $trModule1_rYB_bytes: + I8[] "main" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.812887827 UTC + +[section ""cstring" . c125_str" { + c125_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:(15,28)-(17,17)|case" + }, + $c==_rYq_entry() { // [R3, R2] + { info_tbls: [(c11N, + label: block_c11N_info + rep: StackRep [False] + srt: Just Control.Exception.Base.patError_closure), + (c11Q, + label: $c==_rYq_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just Control.Exception.Base.patError_closure), + (c11T, + label: block_c11T_info + rep: StackRep [True] + srt: Just Control.Exception.Base.patError_closure)] + stack_info: arg_space: 8 + } + {offset + c11Q: // global + _s11k::P64 = R3; // CmmAssign + _s11j::P64 = R2; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c11U; else goto c11V; // CmmCondBranch + c11U: // global + R3 = _s11k::P64; // CmmAssign + R2 = _s11j::P64; // CmmAssign + R1 = $c==_rYq_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c11V: // global + I64[Sp - 16] = c11N; // CmmStore + R1 = _s11j::P64; // CmmAssign + P64[Sp - 8] = _s11k::P64; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto c11N; else goto c11O; // CmmCondBranch + c11O: // global + call (I64[R1])(R1) returns to c11N, args: 8, res: 8, upd: 8; // CmmCall + c11N: // global + _s11k::P64 = P64[Sp + 8]; // CmmAssign + _s11l::P64 = R1; // CmmAssign + _s11m::I64 = I64[_s11l::P64 + 7]; // CmmAssign + I64[Sp] = c11T; // CmmStore + R1 = _s11k::P64; // CmmAssign + I64[Sp + 8] = _s11m::I64; // CmmStore + if (R1 & 7 != 0) goto c11T; else goto c11X; // CmmCondBranch + c11X: // global + call (I64[R1])(R1) returns to c11T, args: 8, res: 8, upd: 8; // CmmCall + c11T: // global + _s11m::I64 = I64[Sp + 8]; // CmmAssign + _s11n::P64 = R1; // CmmAssign + _s11o::I64 = I64[_s11n::P64 + 7]; // CmmAssign + _c122::I64 = _s11m::I64 == _s11o::I64; // CmmAssign + _s11p::I64 = _c122::I64; // CmmAssign + if (_s11p::I64 != 0) goto u12a; else goto c128; // CmmCondBranch + u12a: // global + if (_s11p::I64 != 1) goto c127; else goto c129; // CmmCondBranch + c127: // global + R2 = c125_str; // CmmAssign + Sp = Sp + 16; // CmmAssign + call Control.Exception.Base.patError_info(R2) args: 8, res: 0, upd: 8; // CmmCall + c129: // global + R1 = GHC.Types.True_closure+2; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + c128: // global + R1 = GHC.Types.False_closure+1; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c==_rYq_closure" { + $c==_rYq_closure: + const $c==_rYq_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.817425012 UTC + +[$c/=_rYr_entry() { // [R3, R2] + { info_tbls: [(c12l, + label: block_c12l_info + rep: StackRep [] + srt: Nothing), + (c12r, + label: $c/=_rYr_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just $c==_rYq_closure)] + stack_info: arg_space: 8 + } + {offset + c12r: // global + _s11r::P64 = R3; // CmmAssign + _s11q::P64 = R2; // CmmAssign + if ((Sp + 8) - 16 < SpLim) (likely: False) goto c12s; else goto c12t; // CmmCondBranch + c12s: // global + R3 = _s11r::P64; // CmmAssign + R2 = _s11q::P64; // CmmAssign + R1 = $c/=_rYr_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c12t: // global + I64[Sp - 8] = c12l; // CmmStore + R3 = _s11r::P64; // CmmAssign + R2 = _s11q::P64; // CmmAssign + Sp = Sp - 8; // CmmAssign + call $c==_rYq_info(R3, + R2) returns to c12l, args: 8, res: 8, upd: 8; // CmmCall + c12l: // global + _s11s::P64 = R1; // CmmAssign + _c12q::P64 = _s11s::P64 & 7; // CmmAssign + if (_c12q::P64 != 1) goto c12p; else goto c12o; // CmmCondBranch + c12p: // global + R1 = GHC.Types.False_closure+1; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + c12o: // global + R1 = GHC.Types.True_closure+2; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c/=_rYr_closure" { + $c/=_rYr_closure: + const $c/=_rYr_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.819847978 UTC + +[section ""data" . ManyUbxSums_Addr.$fEqAddr_closure" { + ManyUbxSums_Addr.$fEqAddr_closure: + const GHC.Classes.C:Eq_con_info; + const $c==_rYq_closure+2; + const $c/=_rYr_closure+2; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.820914267 UTC + +[$cfromInteger_rYs_entry() { // [R2] + { info_tbls: [(c12K, + label: block_c12K_info + rep: StackRep [] + srt: Nothing), + (c12M, + label: $cfromInteger_rYs_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c12M: // global + _s11t::P64 = R2; // CmmAssign + if ((Sp + 8) - 16 < SpLim) (likely: False) goto c12T; else goto c12U; // CmmCondBranch + c12T: // global + R2 = _s11t::P64; // CmmAssign + R1 = $cfromInteger_rYs_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c12U: // global + // slowCall + I64[Sp - 8] = c12K; // CmmStore + R4 = _s11t::P64; // CmmAssign + R3 = GHC.Num.$fNumInt_closure; // CmmAssign + R2 = GHC.Real.$fIntegralInteger_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 8; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) returns to c12K, args: 8, res: 8, upd: 8; // CmmCall + c12K: // global + _s11u::P64 = R1; // CmmAssign + // slow_call for fromIntegral_closure with pat stg_ap_ppp + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c12X; else goto c12W; // CmmCondBranch + c12X: // global + HpAlloc = 16; // CmmAssign + R1 = _s11u::P64; // CmmAssign + call stg_gc_unpt_r1(R1) returns to c12K, args: 8, res: 8, upd: 8; // CmmCall + c12W: // global + _s11v::I64 = I64[_s11u::P64 + 7]; // CmmAssign + _c12P::I64 = _s11v::I64; // CmmAssign + _s11w::I64 = _c12P::I64; // CmmAssign + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _s11w::I64; // CmmStore + _c12S::P64 = Hp - 7; // CmmAssign + R1 = _c12S::P64; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $cfromInteger_rYs_closure" { + $cfromInteger_rYs_closure: + const $cfromInteger_rYs_info; + const GHC.Real.fromIntegral_closure; + const GHC.Num.$fNumInt_closure; + const GHC.Real.$fIntegralInteger_closure; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.824020462 UTC + +[section ""cstring" . c138_str" { + c138_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|signum" + }, + $csignum_rYt_entry() { // [R1] + { info_tbls: [(c139, + label: $csignum_rYt_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c139: // global + _rYt::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13a; else goto c13b; // CmmCondBranch + c13a: // global + R1 = _rYt::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13b: // global + (_c135::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYt::P64); // CmmUnsafeForeignCall + if (_c135::I64 == 0) goto c137; else goto c136; // CmmCondBranch + c137: // global + call (I64[_rYt::P64])() args: 8, res: 0, upd: 8; // CmmCall + c136: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c135::I64; // CmmStore + R2 = c138_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $csignum_rYt_closure" { + $csignum_rYt_closure: + const $csignum_rYt_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.826774229 UTC + +[section ""cstring" . c13o_str" { + c13o_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|abs" + }, + $cabs_rYu_entry() { // [R1] + { info_tbls: [(c13p, + label: $cabs_rYu_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13p: // global + _rYu::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13q; else goto c13r; // CmmCondBranch + c13q: // global + R1 = _rYu::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13r: // global + (_c13l::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYu::P64); // CmmUnsafeForeignCall + if (_c13l::I64 == 0) goto c13n; else goto c13m; // CmmCondBranch + c13n: // global + call (I64[_rYu::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13m: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13l::I64; // CmmStore + R2 = c13o_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cabs_rYu_closure" { + $cabs_rYu_closure: + const $cabs_rYu_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.829072883 UTC + +[section ""cstring" . c13E_str" { + c13E_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|*" + }, + $c*_rYv_entry() { // [R1] + { info_tbls: [(c13F, + label: $c*_rYv_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13F: // global + _rYv::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13G; else goto c13H; // CmmCondBranch + c13G: // global + R1 = _rYv::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13H: // global + (_c13B::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYv::P64); // CmmUnsafeForeignCall + if (_c13B::I64 == 0) goto c13D; else goto c13C; // CmmCondBranch + c13D: // global + call (I64[_rYv::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13C: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13B::I64; // CmmStore + R2 = c13E_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $c*_rYv_closure" { + $c*_rYv_closure: + const $c*_rYv_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.831813755 UTC + +[section ""cstring" . c13U_str" { + c13U_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|+" + }, + $c+_rYw_entry() { // [R1] + { info_tbls: [(c13V, + label: $c+_rYw_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13V: // global + _rYw::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13W; else goto c13X; // CmmCondBranch + c13W: // global + R1 = _rYw::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13X: // global + (_c13R::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYw::P64); // CmmUnsafeForeignCall + if (_c13R::I64 == 0) goto c13T; else goto c13S; // CmmCondBranch + c13T: // global + call (I64[_rYw::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13S: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13R::I64; // CmmStore + R2 = c13U_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $c+_rYw_closure" { + $c+_rYw_closure: + const $c+_rYw_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.834378646 UTC + +[$c-_rYx_entry() { // [R3, R2] + { info_tbls: [(c148, + label: $c-_rYx_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just $c+_rYw_closure)] + stack_info: arg_space: 8 + } + {offset + c148: // global + _s11y::P64 = R3; // CmmAssign + _s11x::P64 = R2; // CmmAssign + goto c14a; // CmmBranch + c14a: // global + // slowCall + R1 = $c+_rYw_closure; // CmmAssign + call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c-_rYx_closure" { + $c-_rYx_closure: + const $c-_rYx_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.835499478 UTC + +[$cnegate_rYy_entry() { // [R2] + { info_tbls: [(c14i, + label: $cnegate_rYy_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Just $c+_rYw_closure)] + stack_info: arg_space: 8 + } + {offset + c14i: // global + _s11z::P64 = R2; // CmmAssign + goto c14k; // CmmBranch + c14k: // global + // slowCall + R1 = $c+_rYw_closure; // CmmAssign + call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $cnegate_rYy_closure" { + $cnegate_rYy_closure: + const $cnegate_rYy_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.836410662 UTC + +[section ""data" . ManyUbxSums_Addr.$fNumAddr_closure" { + ManyUbxSums_Addr.$fNumAddr_closure: + const GHC.Num.C:Num_con_info; + const $c+_rYw_closure; + const $c-_rYx_closure+2; + const $c*_rYv_closure; + const $cnegate_rYy_closure+1; + const $cabs_rYu_closure; + const $csignum_rYt_closure; + const $cfromInteger_rYs_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.83761474 UTC + +[sat_s11A_entry() { // [R1] + { info_tbls: [(c14v, + label: sat_s11A_info + rep: HeapRep static { Thunk } + srt: Just GHC.Enum.$fBoundedWord_closure)] + stack_info: arg_space: 8 + } + {offset + c14v: // global + _s11A::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c14w; else goto c14x; // CmmCondBranch + c14w: // global + R1 = _s11A::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c14x: // global + (_c14s::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _s11A::P64); // CmmUnsafeForeignCall + if (_c14s::I64 == 0) goto c14u; else goto c14t; // CmmCondBranch + c14u: // global + call (I64[_s11A::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14t: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14s::I64; // CmmStore + R2 = GHC.Enum.$fBoundedWord_closure; // CmmAssign + Sp = Sp - 16; // CmmAssign + call GHC.Enum.maxBound_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . sat_s11A_closure" { + sat_s11A_closure: + const sat_s11A_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.839820084 UTC + +[section ""data" . _u14M_srt" { + _u14M_srt: + const stg_SRT_4_info; + const GHC.Real.fromIntegral_closure; + const ManyUbxSums_Addr.$fNumAddr_closure; + const GHC.Real.$fIntegralWord_closure; + const sat_s11A_closure; + const 0; + }, + $cmaxBound_rYz_entry() { // [R1] + { info_tbls: [(c14J, + label: $cmaxBound_rYz_info + rep: HeapRep static { Thunk } + srt: Just _u14M_srt)] + stack_info: arg_space: 8 + } + {offset + c14J: // global + _rYz::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c14K; else goto c14L; // CmmCondBranch + c14K: // global + R1 = _rYz::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c14L: // global + (_c14G::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYz::P64); // CmmUnsafeForeignCall + if (_c14G::I64 == 0) goto c14I; else goto c14H; // CmmCondBranch + c14I: // global + call (I64[_rYz::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14H: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14G::I64; // CmmStore + // slowCall + R4 = sat_s11A_closure; // CmmAssign + R3 = ManyUbxSums_Addr.$fNumAddr_closure+1; // CmmAssign + R2 = GHC.Real.$fIntegralWord_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 16; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cmaxBound_rYz_closure" { + $cmaxBound_rYz_closure: + const $cmaxBound_rYz_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.842334183 UTC + +[section ""data" . sat_s11B_closure" { + sat_s11B_closure: + const GHC.Num.Integer.IS_con_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.843430423 UTC + +[$cminBound_rYA_entry() { // [R1] + { info_tbls: [(c150, + label: block_c150_info + rep: StackRep [] + srt: Nothing), + (c152, + label: $cminBound_rYA_info + rep: HeapRep static { Thunk } + srt: Just $cfromInteger_rYs_closure)] + stack_info: arg_space: 8 + } + {offset + c152: // global + _rYA::P64 = R1; // CmmAssign + if ((Sp + 8) - 32 < SpLim) (likely: False) goto c159; else goto c15a; // CmmCondBranch + c159: // global + R1 = _rYA::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c15a: // global + (_c14X::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYA::P64); // CmmUnsafeForeignCall + if (_c14X::I64 == 0) goto c14Z; else goto c14Y; // CmmCondBranch + c14Z: // global + call (I64[_rYA::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14Y: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14X::I64; // CmmStore + // slowCall + I64[Sp - 24] = c150; // CmmStore + R4 = sat_s11B_closure+1; // CmmAssign + R3 = GHC.Num.$fNumInt_closure; // CmmAssign + R2 = GHC.Real.$fIntegralInteger_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 24; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) returns to c150, args: 8, res: 8, upd: 24; // CmmCall + c150: // global + _s11C::P64 = R1; // CmmAssign + // slow_call for fromIntegral_closure with pat stg_ap_ppp + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c15d; else goto c15c; // CmmCondBranch + c15d: // global + HpAlloc = 16; // CmmAssign + R1 = _s11C::P64; // CmmAssign + call stg_gc_unpt_r1(R1) returns to c150, args: 8, res: 8, upd: 24; // CmmCall + c15c: // global + _s11D::I64 = I64[_s11C::P64 + 7]; // CmmAssign + _c155::I64 = _s11D::I64; // CmmAssign + _s11E::I64 = _c155::I64; // CmmAssign + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _s11E::I64; // CmmStore + _c158::P64 = Hp - 7; // CmmAssign + R1 = _c158::P64; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cminBound_rYA_closure" { + $cminBound_rYA_closure: + const $cminBound_rYA_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.846850897 UTC + +[section ""data" . ManyUbxSums_Addr.$fBoundedAddr_closure" { + ManyUbxSums_Addr.$fBoundedAddr_closure: + const GHC.Enum.C:Bounded_con_info; + const $cminBound_rYA_closure; + const $cmaxBound_rYz_closure; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847227811 UTC + +[section ""data" . $trModule2_rYC_closure" { + $trModule2_rYC_closure: + const GHC.Types.TrNameS_con_info; + const $trModule1_rYB_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847546537 UTC + +[section ""data" . $trModule4_rYE_closure" { + $trModule4_rYE_closure: + const GHC.Types.TrNameS_con_info; + const $trModule3_rYD_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847875476 UTC + +[section ""data" . ManyUbxSums_Addr.$trModule_closure" { + ManyUbxSums_Addr.$trModule_closure: + const GHC.Types.Module_con_info; + const $trModule2_rYC_closure+1; + const $trModule4_rYE_closure+1; + const 3; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.848609602 UTC + +[section ""data" . $krep_rYF_closure" { + $krep_rYF_closure: + const GHC.Types.KindRepTyConApp_con_info; + const GHC.Types.$tcAddr#_closure; + const GHC.Types.[]_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.8489625 UTC + +[section ""data" . $tcAddr2_rYH_closure" { + $tcAddr2_rYH_closure: + const GHC.Types.TrNameS_con_info; + const $tcAddr1_rYG_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.849319124 UTC + +[section ""data" . ManyUbxSums_Addr.$tcAddr_closure" { + ManyUbxSums_Addr.$tcAddr_closure: + const GHC.Types.TyCon_con_info; + const ManyUbxSums_Addr.$trModule_closure+1; + const $tcAddr2_rYH_closure+1; + const GHC.Types.krep$*_closure; + const 4790135393693416043; + const 4509054882010932911; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.849776569 UTC + +[section ""data" . $krep1_rYI_closure" { + $krep1_rYI_closure: + const GHC.Types.KindRepTyConApp_con_info; + const ManyUbxSums_Addr.$tcAddr_closure+1; + const GHC.Types.[]_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850145038 UTC + +[section ""data" . $krep2_rYJ_closure" { + $krep2_rYJ_closure: + const GHC.Types.KindRepFun_con_info; + const $krep_rYF_closure+1; + const $krep1_rYI_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850499273 UTC + +[section ""data" . $tc'Addr2_rYL_closure" { + $tc'Addr2_rYL_closure: + const GHC.Types.TrNameS_con_info; + const $tc'Addr1_rYK_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850843839 UTC + +[section ""data" . ManyUbxSums_Addr.$tc'Addr_closure" { + ManyUbxSums_Addr.$tc'Addr_closure: + const GHC.Types.TyCon_con_info; + const ManyUbxSums_Addr.$trModule_closure+1; + const $tc'Addr2_rYL_closure+1; + const $krep2_rYJ_closure+4; + const 15766329447734056695; + const 3176921173291726962; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.851681093 UTC + +[ManyUbxSums_Addr.Addr_entry() { // [R2] + { info_tbls: [(c15z, + label: ManyUbxSums_Addr.Addr_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 4} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c15z: // global + _B0::I64 = R2; // CmmAssign + goto c15B; // CmmBranch + c15B: // global + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c15D; else goto c15C; // CmmCondBranch + c15D: // global + HpAlloc = 16; // CmmAssign + goto c15A; // CmmBranch + c15A: // global + R2 = _B0::I64; // CmmAssign + R1 = ManyUbxSums_Addr.Addr_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c15C: // global + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _B0::I64; // CmmStore + _c15y::P64 = Hp - 7; // CmmAssign + R1 = _c15y::P64; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . ManyUbxSums_Addr.Addr_closure" { + ManyUbxSums_Addr.Addr_closure: + const ManyUbxSums_Addr.Addr_info; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.853732429 UTC + +[ManyUbxSums_Addr.Addr_con_entry() { // [] + { info_tbls: [(c15H, + label: ManyUbxSums_Addr.Addr_con_info + rep: HeapRep 1 nonptrs { + Con {tag: 0 descr:"main:ManyUbxSums_Addr.Addr"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c15H: // global + R1 = R1 + 1; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }] + ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-stg-final ===================================== @@ -0,0 +1,214 @@ + +==================== Final STG: ==================== +2022-09-27 22:20:23.80547185 UTC + +$tc'Addr1_rYK :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "'Addr"#; + +$tcAddr1_rYG :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "Addr"#; + +$trModule3_rYD :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "ManyUbxSums_Addr"#; + +$trModule1_rYB :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "main"#; + +$c==_rYq + :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr -> GHC.Types.Bool +[GblId, Arity=2, Unf=OtherCon []] = + {} \r [ds_s11j ds1_s11k] + case ds_s11j of { + ManyUbxSums_Addr.Addr x_s11m [Occ=Once1] -> + case ds1_s11k of { + ManyUbxSums_Addr.Addr y_s11o [Occ=Once1] -> + case eqAddr# [x_s11m:AddrRep y_s11o:AddrRep] of { + __DEFAULT -> + Control.Exception.Base.patError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:(15,28)-(17,17)|case"#:AddrRep; + 0# -> GHC.Types.False []; + 1# -> GHC.Types.True []; + }; + }; + }; + +$c/=_rYr + :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr -> GHC.Types.Bool +[GblId, Arity=2, Unf=OtherCon []] = + {} \r [x_s11q y_s11r] + case $c==_rYq x_s11q:LiftedRep y_s11r:LiftedRep of { + GHC.Types.False -> GHC.Types.True []; + GHC.Types.True -> GHC.Types.False []; + }; + +ManyUbxSums_Addr.$fEqAddr [InlPrag=CONLIKE] + :: GHC.Classes.Eq ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Classes.C:Eq! [$c==_rYq:LiftedRep $c/=_rYr:LiftedRep]; + +$cfromInteger_rYs + :: GHC.Num.Integer.Integer -> ManyUbxSums_Addr.Addr +[GblId, Arity=1, Unf=OtherCon []] = + {} \r [x_s11t] + case + GHC.Real.fromIntegral + GHC.Real.$fIntegralInteger:LiftedRep + GHC.Num.$fNumInt:LiftedRep + x_s11t:LiftedRep + of + { + GHC.Types.I# x1_s11v [Occ=Once1] -> + case int2Addr# [x1_s11v:IntRep] of sat_s11w [Occ=Once1] { + __DEFAULT -> ManyUbxSums_Addr.Addr [sat_s11w:AddrRep]; + }; + }; + +$csignum_rYt :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|signum"#:AddrRep; + +$cabs_rYu :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|abs"#:AddrRep; + +$c*_rYv + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|*"#:AddrRep; + +$c+_rYw + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|+"#:AddrRep; + +$c-_rYx + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Arity=2, Str=b, Cpr=b, Unf=OtherCon []] = + {} \r [x_s11x y_s11y] $c+_rYw; + +$cnegate_rYy :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] = + {} \r [x_s11z] $c+_rYw; + +ManyUbxSums_Addr.$fNumAddr [InlPrag=CONLIKE] + :: GHC.Num.Num ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Num.C:Num! [$c+_rYw:LiftedRep + $c-_rYx:LiftedRep + $c*_rYv:LiftedRep + $cnegate_rYy:LiftedRep + $cabs_rYu:LiftedRep + $csignum_rYt:LiftedRep + $cfromInteger_rYs:LiftedRep]; + +sat_s11A :: GHC.Types.Word +[LclId] = + {} \u [] GHC.Enum.maxBound GHC.Enum.$fBoundedWord:LiftedRep; + +$cmaxBound_rYz :: ManyUbxSums_Addr.Addr +[GblId] = + {} \u [] + GHC.Real.fromIntegral + GHC.Real.$fIntegralWord:LiftedRep + ManyUbxSums_Addr.$fNumAddr:LiftedRep + sat_s11A:LiftedRep; + +sat_s11B :: GHC.Num.Integer.Integer +[LclId] = + GHC.Num.Integer.IS! [0#:IntRep]; + +$cminBound_rYA :: ManyUbxSums_Addr.Addr +[GblId] = + {} \u [] + case + GHC.Real.fromIntegral + GHC.Real.$fIntegralInteger:LiftedRep + GHC.Num.$fNumInt:LiftedRep + sat_s11B:LiftedRep + of + { + GHC.Types.I# x1_s11D [Occ=Once1] -> + case int2Addr# [x1_s11D:IntRep] of sat_s11E [Occ=Once1] { + __DEFAULT -> ManyUbxSums_Addr.Addr [sat_s11E:AddrRep]; + }; + }; + +ManyUbxSums_Addr.$fBoundedAddr [InlPrag=CONLIKE] + :: GHC.Enum.Bounded ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Enum.C:Bounded! [$cminBound_rYA:LiftedRep + $cmaxBound_rYz:LiftedRep]; + +$trModule2_rYC :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$trModule1_rYB:AddrRep]; + +$trModule4_rYE :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$trModule3_rYD:AddrRep]; + +ManyUbxSums_Addr.$trModule :: GHC.Types.Module +[GblId, Unf=OtherCon []] = + GHC.Types.Module! [$trModule2_rYC:LiftedRep + $trModule4_rYE:LiftedRep]; + +$krep_rYF :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepTyConApp! [GHC.Types.$tcAddr#:LiftedRep + GHC.Types.[]:LiftedRep]; + +$tcAddr2_rYH :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$tcAddr1_rYG:AddrRep]; + +ManyUbxSums_Addr.$tcAddr :: GHC.Types.TyCon +[GblId, Unf=OtherCon []] = + GHC.Types.TyCon! [4790135393693416043##64:Word64Rep + 4509054882010932911##64:Word64Rep + ManyUbxSums_Addr.$trModule:LiftedRep + $tcAddr2_rYH:LiftedRep + 0#:IntRep + GHC.Types.krep$*:LiftedRep]; + +$krep1_rYI :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepTyConApp! [ManyUbxSums_Addr.$tcAddr:LiftedRep + GHC.Types.[]:LiftedRep]; + +$krep2_rYJ :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepFun! [$krep_rYF:LiftedRep $krep1_rYI:LiftedRep]; + +$tc'Addr2_rYL :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$tc'Addr1_rYK:AddrRep]; + +ManyUbxSums_Addr.$tc'Addr :: GHC.Types.TyCon +[GblId, Unf=OtherCon []] = + GHC.Types.TyCon! [15766329447734056695##64:Word64Rep + 3176921173291726962##64:Word64Rep + ManyUbxSums_Addr.$trModule:LiftedRep + $tc'Addr2_rYL:LiftedRep + 0#:IntRep + $krep2_rYJ:LiftedRep]; + +ManyUbxSums_Addr.Addr [InlPrag=CONLIKE] + :: GHC.Prim.Addr# %1 -> ManyUbxSums_Addr.Addr +[GblId[DataCon], Arity=1, Caf=NoCafRefs, Unf=OtherCon []] = + {} \r [eta_B0] ManyUbxSums_Addr.Addr [eta_B0:AddrRep]; + ===================================== 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/all.T ===================================== @@ -36,3 +36,11 @@ test('T20858b', [extra_files(['T20858.hs']) , ghci_script, ['T20858b.script']) test('T20859', normal, compile, ['']) test('T22208', normal, compile, ['-dstg-lint -dcmm-lint']) +test('ManyUbxSums', + [ pre_cmd('./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/311eaf70357337ad6348ac47eaf2a3e2bc449374 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/311eaf70357337ad6348ac47eaf2a3e2bc449374 You're receiving 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 Sep 27 22:49:21 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 18:49:21 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63337df15cf86_2c975753ffac52704d@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 4b781b91 by Andreas Klebinger at 2022-09-28T00:48:03+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 18 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_Addr.debug.dump-cmm - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-stg-final - + 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,207 @@ +{- +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.Trace +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 f t = + let r = getCasts' f t + in pprTrace "getCasts" (ppr (f,t,r)) r + + +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 = [] +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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 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 +766,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 +781,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +936,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 +958,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 ) -------------------------------------------------------------------------------- ===================================== 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,102 @@ +#!/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 + +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 (# t1 | t2 #) and one (# t1 | t3). +-- So build all the combinations 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: +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | Addr# #) -> (# Addr# | Addr# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | Addr# #) +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 = 0 +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + "test" ++ show n ++ " =\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" + +-- Test all the tuples +mkTests n [] = "" +mkTests n (combo:combos) = + mkTest n combo ++ "\n" ++ mkTests (n+1) combos + + +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" + + -- Actually invoke all the tests + 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_Addr.debug.dump-cmm ===================================== @@ -0,0 +1,862 @@ + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810321346 UTC + +[section ""cstring" . $tc'Addr1_rYK_bytes" { + $tc'Addr1_rYK_bytes: + I8[] "'Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810616005 UTC + +[section ""cstring" . $tcAddr1_rYG_bytes" { + $tcAddr1_rYG_bytes: + I8[] "Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810861345 UTC + +[section ""cstring" . $trModule3_rYD_bytes" { + $trModule3_rYD_bytes: + I8[] "ManyUbxSums_Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.811117863 UTC + +[section ""cstring" . $trModule1_rYB_bytes" { + $trModule1_rYB_bytes: + I8[] "main" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.812887827 UTC + +[section ""cstring" . c125_str" { + c125_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:(15,28)-(17,17)|case" + }, + $c==_rYq_entry() { // [R3, R2] + { info_tbls: [(c11N, + label: block_c11N_info + rep: StackRep [False] + srt: Just Control.Exception.Base.patError_closure), + (c11Q, + label: $c==_rYq_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just Control.Exception.Base.patError_closure), + (c11T, + label: block_c11T_info + rep: StackRep [True] + srt: Just Control.Exception.Base.patError_closure)] + stack_info: arg_space: 8 + } + {offset + c11Q: // global + _s11k::P64 = R3; // CmmAssign + _s11j::P64 = R2; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c11U; else goto c11V; // CmmCondBranch + c11U: // global + R3 = _s11k::P64; // CmmAssign + R2 = _s11j::P64; // CmmAssign + R1 = $c==_rYq_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c11V: // global + I64[Sp - 16] = c11N; // CmmStore + R1 = _s11j::P64; // CmmAssign + P64[Sp - 8] = _s11k::P64; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto c11N; else goto c11O; // CmmCondBranch + c11O: // global + call (I64[R1])(R1) returns to c11N, args: 8, res: 8, upd: 8; // CmmCall + c11N: // global + _s11k::P64 = P64[Sp + 8]; // CmmAssign + _s11l::P64 = R1; // CmmAssign + _s11m::I64 = I64[_s11l::P64 + 7]; // CmmAssign + I64[Sp] = c11T; // CmmStore + R1 = _s11k::P64; // CmmAssign + I64[Sp + 8] = _s11m::I64; // CmmStore + if (R1 & 7 != 0) goto c11T; else goto c11X; // CmmCondBranch + c11X: // global + call (I64[R1])(R1) returns to c11T, args: 8, res: 8, upd: 8; // CmmCall + c11T: // global + _s11m::I64 = I64[Sp + 8]; // CmmAssign + _s11n::P64 = R1; // CmmAssign + _s11o::I64 = I64[_s11n::P64 + 7]; // CmmAssign + _c122::I64 = _s11m::I64 == _s11o::I64; // CmmAssign + _s11p::I64 = _c122::I64; // CmmAssign + if (_s11p::I64 != 0) goto u12a; else goto c128; // CmmCondBranch + u12a: // global + if (_s11p::I64 != 1) goto c127; else goto c129; // CmmCondBranch + c127: // global + R2 = c125_str; // CmmAssign + Sp = Sp + 16; // CmmAssign + call Control.Exception.Base.patError_info(R2) args: 8, res: 0, upd: 8; // CmmCall + c129: // global + R1 = GHC.Types.True_closure+2; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + c128: // global + R1 = GHC.Types.False_closure+1; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c==_rYq_closure" { + $c==_rYq_closure: + const $c==_rYq_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.817425012 UTC + +[$c/=_rYr_entry() { // [R3, R2] + { info_tbls: [(c12l, + label: block_c12l_info + rep: StackRep [] + srt: Nothing), + (c12r, + label: $c/=_rYr_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just $c==_rYq_closure)] + stack_info: arg_space: 8 + } + {offset + c12r: // global + _s11r::P64 = R3; // CmmAssign + _s11q::P64 = R2; // CmmAssign + if ((Sp + 8) - 16 < SpLim) (likely: False) goto c12s; else goto c12t; // CmmCondBranch + c12s: // global + R3 = _s11r::P64; // CmmAssign + R2 = _s11q::P64; // CmmAssign + R1 = $c/=_rYr_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c12t: // global + I64[Sp - 8] = c12l; // CmmStore + R3 = _s11r::P64; // CmmAssign + R2 = _s11q::P64; // CmmAssign + Sp = Sp - 8; // CmmAssign + call $c==_rYq_info(R3, + R2) returns to c12l, args: 8, res: 8, upd: 8; // CmmCall + c12l: // global + _s11s::P64 = R1; // CmmAssign + _c12q::P64 = _s11s::P64 & 7; // CmmAssign + if (_c12q::P64 != 1) goto c12p; else goto c12o; // CmmCondBranch + c12p: // global + R1 = GHC.Types.False_closure+1; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + c12o: // global + R1 = GHC.Types.True_closure+2; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c/=_rYr_closure" { + $c/=_rYr_closure: + const $c/=_rYr_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.819847978 UTC + +[section ""data" . ManyUbxSums_Addr.$fEqAddr_closure" { + ManyUbxSums_Addr.$fEqAddr_closure: + const GHC.Classes.C:Eq_con_info; + const $c==_rYq_closure+2; + const $c/=_rYr_closure+2; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.820914267 UTC + +[$cfromInteger_rYs_entry() { // [R2] + { info_tbls: [(c12K, + label: block_c12K_info + rep: StackRep [] + srt: Nothing), + (c12M, + label: $cfromInteger_rYs_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c12M: // global + _s11t::P64 = R2; // CmmAssign + if ((Sp + 8) - 16 < SpLim) (likely: False) goto c12T; else goto c12U; // CmmCondBranch + c12T: // global + R2 = _s11t::P64; // CmmAssign + R1 = $cfromInteger_rYs_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c12U: // global + // slowCall + I64[Sp - 8] = c12K; // CmmStore + R4 = _s11t::P64; // CmmAssign + R3 = GHC.Num.$fNumInt_closure; // CmmAssign + R2 = GHC.Real.$fIntegralInteger_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 8; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) returns to c12K, args: 8, res: 8, upd: 8; // CmmCall + c12K: // global + _s11u::P64 = R1; // CmmAssign + // slow_call for fromIntegral_closure with pat stg_ap_ppp + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c12X; else goto c12W; // CmmCondBranch + c12X: // global + HpAlloc = 16; // CmmAssign + R1 = _s11u::P64; // CmmAssign + call stg_gc_unpt_r1(R1) returns to c12K, args: 8, res: 8, upd: 8; // CmmCall + c12W: // global + _s11v::I64 = I64[_s11u::P64 + 7]; // CmmAssign + _c12P::I64 = _s11v::I64; // CmmAssign + _s11w::I64 = _c12P::I64; // CmmAssign + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _s11w::I64; // CmmStore + _c12S::P64 = Hp - 7; // CmmAssign + R1 = _c12S::P64; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $cfromInteger_rYs_closure" { + $cfromInteger_rYs_closure: + const $cfromInteger_rYs_info; + const GHC.Real.fromIntegral_closure; + const GHC.Num.$fNumInt_closure; + const GHC.Real.$fIntegralInteger_closure; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.824020462 UTC + +[section ""cstring" . c138_str" { + c138_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|signum" + }, + $csignum_rYt_entry() { // [R1] + { info_tbls: [(c139, + label: $csignum_rYt_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c139: // global + _rYt::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13a; else goto c13b; // CmmCondBranch + c13a: // global + R1 = _rYt::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13b: // global + (_c135::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYt::P64); // CmmUnsafeForeignCall + if (_c135::I64 == 0) goto c137; else goto c136; // CmmCondBranch + c137: // global + call (I64[_rYt::P64])() args: 8, res: 0, upd: 8; // CmmCall + c136: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c135::I64; // CmmStore + R2 = c138_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $csignum_rYt_closure" { + $csignum_rYt_closure: + const $csignum_rYt_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.826774229 UTC + +[section ""cstring" . c13o_str" { + c13o_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|abs" + }, + $cabs_rYu_entry() { // [R1] + { info_tbls: [(c13p, + label: $cabs_rYu_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13p: // global + _rYu::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13q; else goto c13r; // CmmCondBranch + c13q: // global + R1 = _rYu::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13r: // global + (_c13l::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYu::P64); // CmmUnsafeForeignCall + if (_c13l::I64 == 0) goto c13n; else goto c13m; // CmmCondBranch + c13n: // global + call (I64[_rYu::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13m: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13l::I64; // CmmStore + R2 = c13o_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cabs_rYu_closure" { + $cabs_rYu_closure: + const $cabs_rYu_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.829072883 UTC + +[section ""cstring" . c13E_str" { + c13E_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|*" + }, + $c*_rYv_entry() { // [R1] + { info_tbls: [(c13F, + label: $c*_rYv_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13F: // global + _rYv::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13G; else goto c13H; // CmmCondBranch + c13G: // global + R1 = _rYv::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13H: // global + (_c13B::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYv::P64); // CmmUnsafeForeignCall + if (_c13B::I64 == 0) goto c13D; else goto c13C; // CmmCondBranch + c13D: // global + call (I64[_rYv::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13C: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13B::I64; // CmmStore + R2 = c13E_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $c*_rYv_closure" { + $c*_rYv_closure: + const $c*_rYv_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.831813755 UTC + +[section ""cstring" . c13U_str" { + c13U_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|+" + }, + $c+_rYw_entry() { // [R1] + { info_tbls: [(c13V, + label: $c+_rYw_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13V: // global + _rYw::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13W; else goto c13X; // CmmCondBranch + c13W: // global + R1 = _rYw::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13X: // global + (_c13R::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYw::P64); // CmmUnsafeForeignCall + if (_c13R::I64 == 0) goto c13T; else goto c13S; // CmmCondBranch + c13T: // global + call (I64[_rYw::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13S: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13R::I64; // CmmStore + R2 = c13U_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $c+_rYw_closure" { + $c+_rYw_closure: + const $c+_rYw_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.834378646 UTC + +[$c-_rYx_entry() { // [R3, R2] + { info_tbls: [(c148, + label: $c-_rYx_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just $c+_rYw_closure)] + stack_info: arg_space: 8 + } + {offset + c148: // global + _s11y::P64 = R3; // CmmAssign + _s11x::P64 = R2; // CmmAssign + goto c14a; // CmmBranch + c14a: // global + // slowCall + R1 = $c+_rYw_closure; // CmmAssign + call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c-_rYx_closure" { + $c-_rYx_closure: + const $c-_rYx_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.835499478 UTC + +[$cnegate_rYy_entry() { // [R2] + { info_tbls: [(c14i, + label: $cnegate_rYy_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Just $c+_rYw_closure)] + stack_info: arg_space: 8 + } + {offset + c14i: // global + _s11z::P64 = R2; // CmmAssign + goto c14k; // CmmBranch + c14k: // global + // slowCall + R1 = $c+_rYw_closure; // CmmAssign + call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $cnegate_rYy_closure" { + $cnegate_rYy_closure: + const $cnegate_rYy_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.836410662 UTC + +[section ""data" . ManyUbxSums_Addr.$fNumAddr_closure" { + ManyUbxSums_Addr.$fNumAddr_closure: + const GHC.Num.C:Num_con_info; + const $c+_rYw_closure; + const $c-_rYx_closure+2; + const $c*_rYv_closure; + const $cnegate_rYy_closure+1; + const $cabs_rYu_closure; + const $csignum_rYt_closure; + const $cfromInteger_rYs_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.83761474 UTC + +[sat_s11A_entry() { // [R1] + { info_tbls: [(c14v, + label: sat_s11A_info + rep: HeapRep static { Thunk } + srt: Just GHC.Enum.$fBoundedWord_closure)] + stack_info: arg_space: 8 + } + {offset + c14v: // global + _s11A::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c14w; else goto c14x; // CmmCondBranch + c14w: // global + R1 = _s11A::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c14x: // global + (_c14s::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _s11A::P64); // CmmUnsafeForeignCall + if (_c14s::I64 == 0) goto c14u; else goto c14t; // CmmCondBranch + c14u: // global + call (I64[_s11A::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14t: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14s::I64; // CmmStore + R2 = GHC.Enum.$fBoundedWord_closure; // CmmAssign + Sp = Sp - 16; // CmmAssign + call GHC.Enum.maxBound_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . sat_s11A_closure" { + sat_s11A_closure: + const sat_s11A_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.839820084 UTC + +[section ""data" . _u14M_srt" { + _u14M_srt: + const stg_SRT_4_info; + const GHC.Real.fromIntegral_closure; + const ManyUbxSums_Addr.$fNumAddr_closure; + const GHC.Real.$fIntegralWord_closure; + const sat_s11A_closure; + const 0; + }, + $cmaxBound_rYz_entry() { // [R1] + { info_tbls: [(c14J, + label: $cmaxBound_rYz_info + rep: HeapRep static { Thunk } + srt: Just _u14M_srt)] + stack_info: arg_space: 8 + } + {offset + c14J: // global + _rYz::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c14K; else goto c14L; // CmmCondBranch + c14K: // global + R1 = _rYz::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c14L: // global + (_c14G::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYz::P64); // CmmUnsafeForeignCall + if (_c14G::I64 == 0) goto c14I; else goto c14H; // CmmCondBranch + c14I: // global + call (I64[_rYz::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14H: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14G::I64; // CmmStore + // slowCall + R4 = sat_s11A_closure; // CmmAssign + R3 = ManyUbxSums_Addr.$fNumAddr_closure+1; // CmmAssign + R2 = GHC.Real.$fIntegralWord_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 16; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cmaxBound_rYz_closure" { + $cmaxBound_rYz_closure: + const $cmaxBound_rYz_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.842334183 UTC + +[section ""data" . sat_s11B_closure" { + sat_s11B_closure: + const GHC.Num.Integer.IS_con_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.843430423 UTC + +[$cminBound_rYA_entry() { // [R1] + { info_tbls: [(c150, + label: block_c150_info + rep: StackRep [] + srt: Nothing), + (c152, + label: $cminBound_rYA_info + rep: HeapRep static { Thunk } + srt: Just $cfromInteger_rYs_closure)] + stack_info: arg_space: 8 + } + {offset + c152: // global + _rYA::P64 = R1; // CmmAssign + if ((Sp + 8) - 32 < SpLim) (likely: False) goto c159; else goto c15a; // CmmCondBranch + c159: // global + R1 = _rYA::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c15a: // global + (_c14X::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYA::P64); // CmmUnsafeForeignCall + if (_c14X::I64 == 0) goto c14Z; else goto c14Y; // CmmCondBranch + c14Z: // global + call (I64[_rYA::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14Y: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14X::I64; // CmmStore + // slowCall + I64[Sp - 24] = c150; // CmmStore + R4 = sat_s11B_closure+1; // CmmAssign + R3 = GHC.Num.$fNumInt_closure; // CmmAssign + R2 = GHC.Real.$fIntegralInteger_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 24; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) returns to c150, args: 8, res: 8, upd: 24; // CmmCall + c150: // global + _s11C::P64 = R1; // CmmAssign + // slow_call for fromIntegral_closure with pat stg_ap_ppp + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c15d; else goto c15c; // CmmCondBranch + c15d: // global + HpAlloc = 16; // CmmAssign + R1 = _s11C::P64; // CmmAssign + call stg_gc_unpt_r1(R1) returns to c150, args: 8, res: 8, upd: 24; // CmmCall + c15c: // global + _s11D::I64 = I64[_s11C::P64 + 7]; // CmmAssign + _c155::I64 = _s11D::I64; // CmmAssign + _s11E::I64 = _c155::I64; // CmmAssign + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _s11E::I64; // CmmStore + _c158::P64 = Hp - 7; // CmmAssign + R1 = _c158::P64; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cminBound_rYA_closure" { + $cminBound_rYA_closure: + const $cminBound_rYA_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.846850897 UTC + +[section ""data" . ManyUbxSums_Addr.$fBoundedAddr_closure" { + ManyUbxSums_Addr.$fBoundedAddr_closure: + const GHC.Enum.C:Bounded_con_info; + const $cminBound_rYA_closure; + const $cmaxBound_rYz_closure; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847227811 UTC + +[section ""data" . $trModule2_rYC_closure" { + $trModule2_rYC_closure: + const GHC.Types.TrNameS_con_info; + const $trModule1_rYB_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847546537 UTC + +[section ""data" . $trModule4_rYE_closure" { + $trModule4_rYE_closure: + const GHC.Types.TrNameS_con_info; + const $trModule3_rYD_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847875476 UTC + +[section ""data" . ManyUbxSums_Addr.$trModule_closure" { + ManyUbxSums_Addr.$trModule_closure: + const GHC.Types.Module_con_info; + const $trModule2_rYC_closure+1; + const $trModule4_rYE_closure+1; + const 3; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.848609602 UTC + +[section ""data" . $krep_rYF_closure" { + $krep_rYF_closure: + const GHC.Types.KindRepTyConApp_con_info; + const GHC.Types.$tcAddr#_closure; + const GHC.Types.[]_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.8489625 UTC + +[section ""data" . $tcAddr2_rYH_closure" { + $tcAddr2_rYH_closure: + const GHC.Types.TrNameS_con_info; + const $tcAddr1_rYG_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.849319124 UTC + +[section ""data" . ManyUbxSums_Addr.$tcAddr_closure" { + ManyUbxSums_Addr.$tcAddr_closure: + const GHC.Types.TyCon_con_info; + const ManyUbxSums_Addr.$trModule_closure+1; + const $tcAddr2_rYH_closure+1; + const GHC.Types.krep$*_closure; + const 4790135393693416043; + const 4509054882010932911; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.849776569 UTC + +[section ""data" . $krep1_rYI_closure" { + $krep1_rYI_closure: + const GHC.Types.KindRepTyConApp_con_info; + const ManyUbxSums_Addr.$tcAddr_closure+1; + const GHC.Types.[]_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850145038 UTC + +[section ""data" . $krep2_rYJ_closure" { + $krep2_rYJ_closure: + const GHC.Types.KindRepFun_con_info; + const $krep_rYF_closure+1; + const $krep1_rYI_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850499273 UTC + +[section ""data" . $tc'Addr2_rYL_closure" { + $tc'Addr2_rYL_closure: + const GHC.Types.TrNameS_con_info; + const $tc'Addr1_rYK_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850843839 UTC + +[section ""data" . ManyUbxSums_Addr.$tc'Addr_closure" { + ManyUbxSums_Addr.$tc'Addr_closure: + const GHC.Types.TyCon_con_info; + const ManyUbxSums_Addr.$trModule_closure+1; + const $tc'Addr2_rYL_closure+1; + const $krep2_rYJ_closure+4; + const 15766329447734056695; + const 3176921173291726962; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.851681093 UTC + +[ManyUbxSums_Addr.Addr_entry() { // [R2] + { info_tbls: [(c15z, + label: ManyUbxSums_Addr.Addr_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 4} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c15z: // global + _B0::I64 = R2; // CmmAssign + goto c15B; // CmmBranch + c15B: // global + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c15D; else goto c15C; // CmmCondBranch + c15D: // global + HpAlloc = 16; // CmmAssign + goto c15A; // CmmBranch + c15A: // global + R2 = _B0::I64; // CmmAssign + R1 = ManyUbxSums_Addr.Addr_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c15C: // global + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _B0::I64; // CmmStore + _c15y::P64 = Hp - 7; // CmmAssign + R1 = _c15y::P64; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . ManyUbxSums_Addr.Addr_closure" { + ManyUbxSums_Addr.Addr_closure: + const ManyUbxSums_Addr.Addr_info; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.853732429 UTC + +[ManyUbxSums_Addr.Addr_con_entry() { // [] + { info_tbls: [(c15H, + label: ManyUbxSums_Addr.Addr_con_info + rep: HeapRep 1 nonptrs { + Con {tag: 0 descr:"main:ManyUbxSums_Addr.Addr"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c15H: // global + R1 = R1 + 1; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }] + ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-stg-final ===================================== @@ -0,0 +1,214 @@ + +==================== Final STG: ==================== +2022-09-27 22:20:23.80547185 UTC + +$tc'Addr1_rYK :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "'Addr"#; + +$tcAddr1_rYG :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "Addr"#; + +$trModule3_rYD :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "ManyUbxSums_Addr"#; + +$trModule1_rYB :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "main"#; + +$c==_rYq + :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr -> GHC.Types.Bool +[GblId, Arity=2, Unf=OtherCon []] = + {} \r [ds_s11j ds1_s11k] + case ds_s11j of { + ManyUbxSums_Addr.Addr x_s11m [Occ=Once1] -> + case ds1_s11k of { + ManyUbxSums_Addr.Addr y_s11o [Occ=Once1] -> + case eqAddr# [x_s11m:AddrRep y_s11o:AddrRep] of { + __DEFAULT -> + Control.Exception.Base.patError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:(15,28)-(17,17)|case"#:AddrRep; + 0# -> GHC.Types.False []; + 1# -> GHC.Types.True []; + }; + }; + }; + +$c/=_rYr + :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr -> GHC.Types.Bool +[GblId, Arity=2, Unf=OtherCon []] = + {} \r [x_s11q y_s11r] + case $c==_rYq x_s11q:LiftedRep y_s11r:LiftedRep of { + GHC.Types.False -> GHC.Types.True []; + GHC.Types.True -> GHC.Types.False []; + }; + +ManyUbxSums_Addr.$fEqAddr [InlPrag=CONLIKE] + :: GHC.Classes.Eq ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Classes.C:Eq! [$c==_rYq:LiftedRep $c/=_rYr:LiftedRep]; + +$cfromInteger_rYs + :: GHC.Num.Integer.Integer -> ManyUbxSums_Addr.Addr +[GblId, Arity=1, Unf=OtherCon []] = + {} \r [x_s11t] + case + GHC.Real.fromIntegral + GHC.Real.$fIntegralInteger:LiftedRep + GHC.Num.$fNumInt:LiftedRep + x_s11t:LiftedRep + of + { + GHC.Types.I# x1_s11v [Occ=Once1] -> + case int2Addr# [x1_s11v:IntRep] of sat_s11w [Occ=Once1] { + __DEFAULT -> ManyUbxSums_Addr.Addr [sat_s11w:AddrRep]; + }; + }; + +$csignum_rYt :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|signum"#:AddrRep; + +$cabs_rYu :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|abs"#:AddrRep; + +$c*_rYv + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|*"#:AddrRep; + +$c+_rYw + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|+"#:AddrRep; + +$c-_rYx + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Arity=2, Str=b, Cpr=b, Unf=OtherCon []] = + {} \r [x_s11x y_s11y] $c+_rYw; + +$cnegate_rYy :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] = + {} \r [x_s11z] $c+_rYw; + +ManyUbxSums_Addr.$fNumAddr [InlPrag=CONLIKE] + :: GHC.Num.Num ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Num.C:Num! [$c+_rYw:LiftedRep + $c-_rYx:LiftedRep + $c*_rYv:LiftedRep + $cnegate_rYy:LiftedRep + $cabs_rYu:LiftedRep + $csignum_rYt:LiftedRep + $cfromInteger_rYs:LiftedRep]; + +sat_s11A :: GHC.Types.Word +[LclId] = + {} \u [] GHC.Enum.maxBound GHC.Enum.$fBoundedWord:LiftedRep; + +$cmaxBound_rYz :: ManyUbxSums_Addr.Addr +[GblId] = + {} \u [] + GHC.Real.fromIntegral + GHC.Real.$fIntegralWord:LiftedRep + ManyUbxSums_Addr.$fNumAddr:LiftedRep + sat_s11A:LiftedRep; + +sat_s11B :: GHC.Num.Integer.Integer +[LclId] = + GHC.Num.Integer.IS! [0#:IntRep]; + +$cminBound_rYA :: ManyUbxSums_Addr.Addr +[GblId] = + {} \u [] + case + GHC.Real.fromIntegral + GHC.Real.$fIntegralInteger:LiftedRep + GHC.Num.$fNumInt:LiftedRep + sat_s11B:LiftedRep + of + { + GHC.Types.I# x1_s11D [Occ=Once1] -> + case int2Addr# [x1_s11D:IntRep] of sat_s11E [Occ=Once1] { + __DEFAULT -> ManyUbxSums_Addr.Addr [sat_s11E:AddrRep]; + }; + }; + +ManyUbxSums_Addr.$fBoundedAddr [InlPrag=CONLIKE] + :: GHC.Enum.Bounded ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Enum.C:Bounded! [$cminBound_rYA:LiftedRep + $cmaxBound_rYz:LiftedRep]; + +$trModule2_rYC :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$trModule1_rYB:AddrRep]; + +$trModule4_rYE :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$trModule3_rYD:AddrRep]; + +ManyUbxSums_Addr.$trModule :: GHC.Types.Module +[GblId, Unf=OtherCon []] = + GHC.Types.Module! [$trModule2_rYC:LiftedRep + $trModule4_rYE:LiftedRep]; + +$krep_rYF :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepTyConApp! [GHC.Types.$tcAddr#:LiftedRep + GHC.Types.[]:LiftedRep]; + +$tcAddr2_rYH :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$tcAddr1_rYG:AddrRep]; + +ManyUbxSums_Addr.$tcAddr :: GHC.Types.TyCon +[GblId, Unf=OtherCon []] = + GHC.Types.TyCon! [4790135393693416043##64:Word64Rep + 4509054882010932911##64:Word64Rep + ManyUbxSums_Addr.$trModule:LiftedRep + $tcAddr2_rYH:LiftedRep + 0#:IntRep + GHC.Types.krep$*:LiftedRep]; + +$krep1_rYI :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepTyConApp! [ManyUbxSums_Addr.$tcAddr:LiftedRep + GHC.Types.[]:LiftedRep]; + +$krep2_rYJ :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepFun! [$krep_rYF:LiftedRep $krep1_rYI:LiftedRep]; + +$tc'Addr2_rYL :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$tc'Addr1_rYK:AddrRep]; + +ManyUbxSums_Addr.$tc'Addr :: GHC.Types.TyCon +[GblId, Unf=OtherCon []] = + GHC.Types.TyCon! [15766329447734056695##64:Word64Rep + 3176921173291726962##64:Word64Rep + ManyUbxSums_Addr.$trModule:LiftedRep + $tc'Addr2_rYL:LiftedRep + 0#:IntRep + $krep2_rYJ:LiftedRep]; + +ManyUbxSums_Addr.Addr [InlPrag=CONLIKE] + :: GHC.Prim.Addr# %1 -> ManyUbxSums_Addr.Addr +[GblId[DataCon], Arity=1, Caf=NoCafRefs, Unf=OtherCon []] = + {} \r [eta_B0] ManyUbxSums_Addr.Addr [eta_B0:AddrRep]; + ===================================== 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('./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/4b781b91bb38872b2dc38afc4ca38a6f458e606a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b781b91bb38872b2dc38afc4ca38a6f458e606a You're receiving 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 Sep 27 22:51:08 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 18:51:08 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63337e5c9048e_2c9757dfd405274c3@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 0a9a65b4 by Andreas Klebinger at 2022-09-28T00:49:44+02:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 19 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.debug.dump-cmm - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-stg-final - + 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,207 @@ +{- +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.Trace +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 f t = + let r = getCasts' f t + in pprTrace "getCasts" (ppr (f,t,r)) r + + +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 = [] +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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 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 +766,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 +781,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +936,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 +958,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 ) -------------------------------------------------------------------------------- ===================================== 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,102 @@ +#!/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 + +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 (# t1 | t2 #) and one (# t1 | t3). +-- So build all the combinations 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: +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | Addr# #) -> (# Addr# | Addr# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | Addr# #) +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 = 0 +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + "test" ++ show n ++ " =\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" + +-- Test all the tuples +mkTests n [] = "" +mkTests n (combo:combos) = + mkTest n combo ++ "\n" ++ mkTests (n+1) combos + + +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" + + -- Actually invoke all the tests + 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,1331 @@ +test0 True +test1 True +test2 True +test3 True +test4 True +test5 True +test6 True +test7 True +test8 True +test9 True +test10 True +test11 True +test12 True +test13 True +test14 True +test15 True +test16 True +test17 True +test18 True +test19 True +test20 True +test21 True +test22 True +test23 True +test24 True +test25 True +test26 True +test27 True +test28 True +test29 True +test30 True +test31 True +test32 True +test33 True +test34 True +test35 True +test36 True +test37 True +test38 True +test39 True +test40 True +test41 True +test42 True +test43 True +test44 True +test45 True +test46 True +test47 True +test48 True +test49 True +test50 True +test51 True +test52 True +test53 True +test54 True +test55 True +test56 True +test57 True +test58 True +test59 True +test60 True +test61 True +test62 True +test63 True +test64 True +test65 True +test66 True +test67 True +test68 True +test69 True +test70 True +test71 True +test72 True +test73 True +test74 True +test75 True +test76 True +test77 True +test78 True +test79 True +test80 True +test81 True +test82 True +test83 True +test84 True +test85 True +test86 True +test87 True +test88 True +test89 True +test90 True +test91 True +test92 True +test93 True +test94 True +test95 True +test96 True +test97 True +test98 True +test99 True +test100 True +test101 True +test102 True +test103 True +test104 True +test105 True +test106 True +test107 True +test108 True +test109 True +test110 True +test111 True +test112 True +test113 True +test114 True +test115 True +test116 True +test117 True +test118 True +test119 True +test120 True +test121 True +test122 True +test123 True +test124 True +test125 True +test126 True +test127 True +test128 True +test129 True +test130 True +test131 True +test132 True +test133 True +test134 True +test135 True +test136 True +test137 True +test138 True +test139 True +test140 True +test141 True +test142 True +test143 True +test144 True +test145 True +test146 True +test147 True +test148 True +test149 True +test150 True +test151 True +test152 True +test153 True +test154 True +test155 True +test156 True +test157 True +test158 True +test159 True +test160 True +test161 True +test162 True +test163 True +test164 True +test165 True +test166 True +test167 True +test168 True +test169 True +test170 True +test171 True +test172 True +test173 True +test174 True +test175 True +test176 True +test177 True +test178 True +test179 True +test180 True +test181 True +test182 True +test183 True +test184 True +test185 True +test186 True +test187 True +test188 True +test189 True +test190 True +test191 True +test192 True +test193 True +test194 True +test195 True +test196 True +test197 True +test198 True +test199 True +test200 True +test201 True +test202 True +test203 True +test204 True +test205 True +test206 True +test207 True +test208 True +test209 True +test210 True +test211 True +test212 True +test213 True +test214 True +test215 True +test216 True +test217 True +test218 True +test219 True +test220 True +test221 True +test222 True +test223 True +test224 True +test225 True +test226 True +test227 True +test228 True +test229 True +test230 True +test231 True +test232 True +test233 True +test234 True +test235 True +test236 True +test237 True +test238 True +test239 True +test240 True +test241 True +test242 True +test243 True +test244 True +test245 True +test246 True +test247 True +test248 True +test249 True +test250 True +test251 True +test252 True +test253 True +test254 True +test255 True +test256 True +test257 True +test258 True +test259 True +test260 True +test261 True +test262 True +test263 True +test264 True +test265 True +test266 True +test267 True +test268 True +test269 True +test270 True +test271 True +test272 True +test273 True +test274 True +test275 True +test276 True +test277 True +test278 True +test279 True +test280 True +test281 True +test282 True +test283 True +test284 True +test285 True +test286 True +test287 True +test288 True +test289 True +test290 True +test291 True +test292 True +test293 True +test294 True +test295 True +test296 True +test297 True +test298 True +test299 True +test300 True +test301 True +test302 True +test303 True +test304 True +test305 True +test306 True +test307 True +test308 True +test309 True +test310 True +test311 True +test312 True +test313 True +test314 True +test315 True +test316 True +test317 True +test318 True +test319 True +test320 True +test321 True +test322 True +test323 True +test324 True +test325 True +test326 True +test327 True +test328 True +test329 True +test330 True +test331 True +test332 True +test333 True +test334 True +test335 True +test336 True +test337 True +test338 True +test339 True +test340 True +test341 True +test342 True +test343 True +test344 True +test345 True +test346 True +test347 True +test348 True +test349 True +test350 True +test351 True +test352 True +test353 True +test354 True +test355 True +test356 True +test357 True +test358 True +test359 True +test360 True +test361 True +test362 True +test363 True +test364 True +test365 True +test366 True +test367 True +test368 True +test369 True +test370 True +test371 True +test372 True +test373 True +test374 True +test375 True +test376 True +test377 True +test378 True +test379 True +test380 True +test381 True +test382 True +test383 True +test384 True +test385 True +test386 True +test387 True +test388 True +test389 True +test390 True +test391 True +test392 True +test393 True +test394 True +test395 True +test396 True +test397 True +test398 True +test399 True +test400 True +test401 True +test402 True +test403 True +test404 True +test405 True +test406 True +test407 True +test408 True +test409 True +test410 True +test411 True +test412 True +test413 True +test414 True +test415 True +test416 True +test417 True +test418 True +test419 True +test420 True +test421 True +test422 True +test423 True +test424 True +test425 True +test426 True +test427 True +test428 True +test429 True +test430 True +test431 True +test432 True +test433 True +test434 True +test435 True +test436 True +test437 True +test438 True +test439 True +test440 True +test441 True +test442 True +test443 True +test444 True +test445 True +test446 True +test447 True +test448 True +test449 True +test450 True +test451 True +test452 True +test453 True +test454 True +test455 True +test456 True +test457 True +test458 True +test459 True +test460 True +test461 True +test462 True +test463 True +test464 True +test465 True +test466 True +test467 True +test468 True +test469 True +test470 True +test471 True +test472 True +test473 True +test474 True +test475 True +test476 True +test477 True +test478 True +test479 True +test480 True +test481 True +test482 True +test483 True +test484 True +test485 True +test486 True +test487 True +test488 True +test489 True +test490 True +test491 True +test492 True +test493 True +test494 True +test495 True +test496 True +test497 True +test498 True +test499 True +test500 True +test501 True +test502 True +test503 True +test504 True +test505 True +test506 True +test507 True +test508 True +test509 True +test510 True +test511 True +test512 True +test513 True +test514 True +test515 True +test516 True +test517 True +test518 True +test519 True +test520 True +test521 True +test522 True +test523 True +test524 True +test525 True +test526 True +test527 True +test528 True +test529 True +test530 True +test531 True +test532 True +test533 True +test534 True +test535 True +test536 True +test537 True +test538 True +test539 True +test540 True +test541 True +test542 True +test543 True +test544 True +test545 True +test546 True +test547 True +test548 True +test549 True +test550 True +test551 True +test552 True +test553 True +test554 True +test555 True +test556 True +test557 True +test558 True +test559 True +test560 True +test561 True +test562 True +test563 True +test564 True +test565 True +test566 True +test567 True +test568 True +test569 True +test570 True +test571 True +test572 True +test573 True +test574 True +test575 True +test576 True +test577 True +test578 True +test579 True +test580 True +test581 True +test582 True +test583 True +test584 True +test585 True +test586 True +test587 True +test588 True +test589 True +test590 True +test591 True +test592 True +test593 True +test594 True +test595 True +test596 True +test597 True +test598 True +test599 True +test600 True +test601 True +test602 True +test603 True +test604 True +test605 True +test606 True +test607 True +test608 True +test609 True +test610 True +test611 True +test612 True +test613 True +test614 True +test615 True +test616 True +test617 True +test618 True +test619 True +test620 True +test621 True +test622 True +test623 True +test624 True +test625 True +test626 True +test627 True +test628 True +test629 True +test630 True +test631 True +test632 True +test633 True +test634 True +test635 True +test636 True +test637 True +test638 True +test639 True +test640 True +test641 True +test642 True +test643 True +test644 True +test645 True +test646 True +test647 True +test648 True +test649 True +test650 True +test651 True +test652 True +test653 True +test654 True +test655 True +test656 True +test657 True +test658 True +test659 True +test660 True +test661 True +test662 True +test663 True +test664 True +test665 True +test666 True +test667 True +test668 True +test669 True +test670 True +test671 True +test672 True +test673 True +test674 True +test675 True +test676 True +test677 True +test678 True +test679 True +test680 True +test681 True +test682 True +test683 True +test684 True +test685 True +test686 True +test687 True +test688 True +test689 True +test690 True +test691 True +test692 True +test693 True +test694 True +test695 True +test696 True +test697 True +test698 True +test699 True +test700 True +test701 True +test702 True +test703 True +test704 True +test705 True +test706 True +test707 True +test708 True +test709 True +test710 True +test711 True +test712 True +test713 True +test714 True +test715 True +test716 True +test717 True +test718 True +test719 True +test720 True +test721 True +test722 True +test723 True +test724 True +test725 True +test726 True +test727 True +test728 True +test729 True +test730 True +test731 True +test732 True +test733 True +test734 True +test735 True +test736 True +test737 True +test738 True +test739 True +test740 True +test741 True +test742 True +test743 True +test744 True +test745 True +test746 True +test747 True +test748 True +test749 True +test750 True +test751 True +test752 True +test753 True +test754 True +test755 True +test756 True +test757 True +test758 True +test759 True +test760 True +test761 True +test762 True +test763 True +test764 True +test765 True +test766 True +test767 True +test768 True +test769 True +test770 True +test771 True +test772 True +test773 True +test774 True +test775 True +test776 True +test777 True +test778 True +test779 True +test780 True +test781 True +test782 True +test783 True +test784 True +test785 True +test786 True +test787 True +test788 True +test789 True +test790 True +test791 True +test792 True +test793 True +test794 True +test795 True +test796 True +test797 True +test798 True +test799 True +test800 True +test801 True +test802 True +test803 True +test804 True +test805 True +test806 True +test807 True +test808 True +test809 True +test810 True +test811 True +test812 True +test813 True +test814 True +test815 True +test816 True +test817 True +test818 True +test819 True +test820 True +test821 True +test822 True +test823 True +test824 True +test825 True +test826 True +test827 True +test828 True +test829 True +test830 True +test831 True +test832 True +test833 True +test834 True +test835 True +test836 True +test837 True +test838 True +test839 True +test840 True +test841 True +test842 True +test843 True +test844 True +test845 True +test846 True +test847 True +test848 True +test849 True +test850 True +test851 True +test852 True +test853 True +test854 True +test855 True +test856 True +test857 True +test858 True +test859 True +test860 True +test861 True +test862 True +test863 True +test864 True +test865 True +test866 True +test867 True +test868 True +test869 True +test870 True +test871 True +test872 True +test873 True +test874 True +test875 True +test876 True +test877 True +test878 True +test879 True +test880 True +test881 True +test882 True +test883 True +test884 True +test885 True +test886 True +test887 True +test888 True +test889 True +test890 True +test891 True +test892 True +test893 True +test894 True +test895 True +test896 True +test897 True +test898 True +test899 True +test900 True +test901 True +test902 True +test903 True +test904 True +test905 True +test906 True +test907 True +test908 True +test909 True +test910 True +test911 True +test912 True +test913 True +test914 True +test915 True +test916 True +test917 True +test918 True +test919 True +test920 True +test921 True +test922 True +test923 True +test924 True +test925 True +test926 True +test927 True +test928 True +test929 True +test930 True +test931 True +test932 True +test933 True +test934 True +test935 True +test936 True +test937 True +test938 True +test939 True +test940 True +test941 True +test942 True +test943 True +test944 True +test945 True +test946 True +test947 True +test948 True +test949 True +test950 True +test951 True +test952 True +test953 True +test954 True +test955 True +test956 True +test957 True +test958 True +test959 True +test960 True +test961 True +test962 True +test963 True +test964 True +test965 True +test966 True +test967 True +test968 True +test969 True +test970 True +test971 True +test972 True +test973 True +test974 True +test975 True +test976 True +test977 True +test978 True +test979 True +test980 True +test981 True +test982 True +test983 True +test984 True +test985 True +test986 True +test987 True +test988 True +test989 True +test990 True +test991 True +test992 True +test993 True +test994 True +test995 True +test996 True +test997 True +test998 True +test999 True +test1000 True +test1001 True +test1002 True +test1003 True +test1004 True +test1005 True +test1006 True +test1007 True +test1008 True +test1009 True +test1010 True +test1011 True +test1012 True +test1013 True +test1014 True +test1015 True +test1016 True +test1017 True +test1018 True +test1019 True +test1020 True +test1021 True +test1022 True +test1023 True +test1024 True +test1025 True +test1026 True +test1027 True +test1028 True +test1029 True +test1030 True +test1031 True +test1032 True +test1033 True +test1034 True +test1035 True +test1036 True +test1037 True +test1038 True +test1039 True +test1040 True +test1041 True +test1042 True +test1043 True +test1044 True +test1045 True +test1046 True +test1047 True +test1048 True +test1049 True +test1050 True +test1051 True +test1052 True +test1053 True +test1054 True +test1055 True +test1056 True +test1057 True +test1058 True +test1059 True +test1060 True +test1061 True +test1062 True +test1063 True +test1064 True +test1065 True +test1066 True +test1067 True +test1068 True +test1069 True +test1070 True +test1071 True +test1072 True +test1073 True +test1074 True +test1075 True +test1076 True +test1077 True +test1078 True +test1079 True +test1080 True +test1081 True +test1082 True +test1083 True +test1084 True +test1085 True +test1086 True +test1087 True +test1088 True +test1089 True +test1090 True +test1091 True +test1092 True +test1093 True +test1094 True +test1095 True +test1096 True +test1097 True +test1098 True +test1099 True +test1100 True +test1101 True +test1102 True +test1103 True +test1104 True +test1105 True +test1106 True +test1107 True +test1108 True +test1109 True +test1110 True +test1111 True +test1112 True +test1113 True +test1114 True +test1115 True +test1116 True +test1117 True +test1118 True +test1119 True +test1120 True +test1121 True +test1122 True +test1123 True +test1124 True +test1125 True +test1126 True +test1127 True +test1128 True +test1129 True +test1130 True +test1131 True +test1132 True +test1133 True +test1134 True +test1135 True +test1136 True +test1137 True +test1138 True +test1139 True +test1140 True +test1141 True +test1142 True +test1143 True +test1144 True +test1145 True +test1146 True +test1147 True +test1148 True +test1149 True +test1150 True +test1151 True +test1152 True +test1153 True +test1154 True +test1155 True +test1156 True +test1157 True +test1158 True +test1159 True +test1160 True +test1161 True +test1162 True +test1163 True +test1164 True +test1165 True +test1166 True +test1167 True +test1168 True +test1169 True +test1170 True +test1171 True +test1172 True +test1173 True +test1174 True +test1175 True +test1176 True +test1177 True +test1178 True +test1179 True +test1180 True +test1181 True +test1182 True +test1183 True +test1184 True +test1185 True +test1186 True +test1187 True +test1188 True +test1189 True +test1190 True +test1191 True +test1192 True +test1193 True +test1194 True +test1195 True +test1196 True +test1197 True +test1198 True +test1199 True +test1200 True +test1201 True +test1202 True +test1203 True +test1204 True +test1205 True +test1206 True +test1207 True +test1208 True +test1209 True +test1210 True +test1211 True +test1212 True +test1213 True +test1214 True +test1215 True +test1216 True +test1217 True +test1218 True +test1219 True +test1220 True +test1221 True +test1222 True +test1223 True +test1224 True +test1225 True +test1226 True +test1227 True +test1228 True +test1229 True +test1230 True +test1231 True +test1232 True +test1233 True +test1234 True +test1235 True +test1236 True +test1237 True +test1238 True +test1239 True +test1240 True +test1241 True +test1242 True +test1243 True +test1244 True +test1245 True +test1246 True +test1247 True +test1248 True +test1249 True +test1250 True +test1251 True +test1252 True +test1253 True +test1254 True +test1255 True +test1256 True +test1257 True +test1258 True +test1259 True +test1260 True +test1261 True +test1262 True +test1263 True +test1264 True +test1265 True +test1266 True +test1267 True +test1268 True +test1269 True +test1270 True +test1271 True +test1272 True +test1273 True +test1274 True +test1275 True +test1276 True +test1277 True +test1278 True +test1279 True +test1280 True +test1281 True +test1282 True +test1283 True +test1284 True +test1285 True +test1286 True +test1287 True +test1288 True +test1289 True +test1290 True +test1291 True +test1292 True +test1293 True +test1294 True +test1295 True +test1296 True +test1297 True +test1298 True +test1299 True +test1300 True +test1301 True +test1302 True +test1303 True +test1304 True +test1305 True +test1306 True +test1307 True +test1308 True +test1309 True +test1310 True +test1311 True +test1312 True +test1313 True +test1314 True +test1315 True +test1316 True +test1317 True +test1318 True +test1319 True +test1320 True +test1321 True +test1322 True +test1323 True +test1324 True +test1325 True +test1326 True +test1327 True +test1328 True +test1329 True +test1330 True ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-cmm ===================================== @@ -0,0 +1,862 @@ + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810321346 UTC + +[section ""cstring" . $tc'Addr1_rYK_bytes" { + $tc'Addr1_rYK_bytes: + I8[] "'Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810616005 UTC + +[section ""cstring" . $tcAddr1_rYG_bytes" { + $tcAddr1_rYG_bytes: + I8[] "Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.810861345 UTC + +[section ""cstring" . $trModule3_rYD_bytes" { + $trModule3_rYD_bytes: + I8[] "ManyUbxSums_Addr" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.811117863 UTC + +[section ""cstring" . $trModule1_rYB_bytes" { + $trModule1_rYB_bytes: + I8[] "main" + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.812887827 UTC + +[section ""cstring" . c125_str" { + c125_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:(15,28)-(17,17)|case" + }, + $c==_rYq_entry() { // [R3, R2] + { info_tbls: [(c11N, + label: block_c11N_info + rep: StackRep [False] + srt: Just Control.Exception.Base.patError_closure), + (c11Q, + label: $c==_rYq_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just Control.Exception.Base.patError_closure), + (c11T, + label: block_c11T_info + rep: StackRep [True] + srt: Just Control.Exception.Base.patError_closure)] + stack_info: arg_space: 8 + } + {offset + c11Q: // global + _s11k::P64 = R3; // CmmAssign + _s11j::P64 = R2; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c11U; else goto c11V; // CmmCondBranch + c11U: // global + R3 = _s11k::P64; // CmmAssign + R2 = _s11j::P64; // CmmAssign + R1 = $c==_rYq_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c11V: // global + I64[Sp - 16] = c11N; // CmmStore + R1 = _s11j::P64; // CmmAssign + P64[Sp - 8] = _s11k::P64; // CmmStore + Sp = Sp - 16; // CmmAssign + if (R1 & 7 != 0) goto c11N; else goto c11O; // CmmCondBranch + c11O: // global + call (I64[R1])(R1) returns to c11N, args: 8, res: 8, upd: 8; // CmmCall + c11N: // global + _s11k::P64 = P64[Sp + 8]; // CmmAssign + _s11l::P64 = R1; // CmmAssign + _s11m::I64 = I64[_s11l::P64 + 7]; // CmmAssign + I64[Sp] = c11T; // CmmStore + R1 = _s11k::P64; // CmmAssign + I64[Sp + 8] = _s11m::I64; // CmmStore + if (R1 & 7 != 0) goto c11T; else goto c11X; // CmmCondBranch + c11X: // global + call (I64[R1])(R1) returns to c11T, args: 8, res: 8, upd: 8; // CmmCall + c11T: // global + _s11m::I64 = I64[Sp + 8]; // CmmAssign + _s11n::P64 = R1; // CmmAssign + _s11o::I64 = I64[_s11n::P64 + 7]; // CmmAssign + _c122::I64 = _s11m::I64 == _s11o::I64; // CmmAssign + _s11p::I64 = _c122::I64; // CmmAssign + if (_s11p::I64 != 0) goto u12a; else goto c128; // CmmCondBranch + u12a: // global + if (_s11p::I64 != 1) goto c127; else goto c129; // CmmCondBranch + c127: // global + R2 = c125_str; // CmmAssign + Sp = Sp + 16; // CmmAssign + call Control.Exception.Base.patError_info(R2) args: 8, res: 0, upd: 8; // CmmCall + c129: // global + R1 = GHC.Types.True_closure+2; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + c128: // global + R1 = GHC.Types.False_closure+1; // CmmAssign + Sp = Sp + 16; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c==_rYq_closure" { + $c==_rYq_closure: + const $c==_rYq_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.817425012 UTC + +[$c/=_rYr_entry() { // [R3, R2] + { info_tbls: [(c12l, + label: block_c12l_info + rep: StackRep [] + srt: Nothing), + (c12r, + label: $c/=_rYr_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just $c==_rYq_closure)] + stack_info: arg_space: 8 + } + {offset + c12r: // global + _s11r::P64 = R3; // CmmAssign + _s11q::P64 = R2; // CmmAssign + if ((Sp + 8) - 16 < SpLim) (likely: False) goto c12s; else goto c12t; // CmmCondBranch + c12s: // global + R3 = _s11r::P64; // CmmAssign + R2 = _s11q::P64; // CmmAssign + R1 = $c/=_rYr_closure; // CmmAssign + call (stg_gc_fun)(R3, R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c12t: // global + I64[Sp - 8] = c12l; // CmmStore + R3 = _s11r::P64; // CmmAssign + R2 = _s11q::P64; // CmmAssign + Sp = Sp - 8; // CmmAssign + call $c==_rYq_info(R3, + R2) returns to c12l, args: 8, res: 8, upd: 8; // CmmCall + c12l: // global + _s11s::P64 = R1; // CmmAssign + _c12q::P64 = _s11s::P64 & 7; // CmmAssign + if (_c12q::P64 != 1) goto c12p; else goto c12o; // CmmCondBranch + c12p: // global + R1 = GHC.Types.False_closure+1; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + c12o: // global + R1 = GHC.Types.True_closure+2; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c/=_rYr_closure" { + $c/=_rYr_closure: + const $c/=_rYr_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.819847978 UTC + +[section ""data" . ManyUbxSums_Addr.$fEqAddr_closure" { + ManyUbxSums_Addr.$fEqAddr_closure: + const GHC.Classes.C:Eq_con_info; + const $c==_rYq_closure+2; + const $c/=_rYr_closure+2; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.820914267 UTC + +[$cfromInteger_rYs_entry() { // [R2] + { info_tbls: [(c12K, + label: block_c12K_info + rep: StackRep [] + srt: Nothing), + (c12M, + label: $cfromInteger_rYs_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c12M: // global + _s11t::P64 = R2; // CmmAssign + if ((Sp + 8) - 16 < SpLim) (likely: False) goto c12T; else goto c12U; // CmmCondBranch + c12T: // global + R2 = _s11t::P64; // CmmAssign + R1 = $cfromInteger_rYs_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c12U: // global + // slowCall + I64[Sp - 8] = c12K; // CmmStore + R4 = _s11t::P64; // CmmAssign + R3 = GHC.Num.$fNumInt_closure; // CmmAssign + R2 = GHC.Real.$fIntegralInteger_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 8; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) returns to c12K, args: 8, res: 8, upd: 8; // CmmCall + c12K: // global + _s11u::P64 = R1; // CmmAssign + // slow_call for fromIntegral_closure with pat stg_ap_ppp + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c12X; else goto c12W; // CmmCondBranch + c12X: // global + HpAlloc = 16; // CmmAssign + R1 = _s11u::P64; // CmmAssign + call stg_gc_unpt_r1(R1) returns to c12K, args: 8, res: 8, upd: 8; // CmmCall + c12W: // global + _s11v::I64 = I64[_s11u::P64 + 7]; // CmmAssign + _c12P::I64 = _s11v::I64; // CmmAssign + _s11w::I64 = _c12P::I64; // CmmAssign + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _s11w::I64; // CmmStore + _c12S::P64 = Hp - 7; // CmmAssign + R1 = _c12S::P64; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $cfromInteger_rYs_closure" { + $cfromInteger_rYs_closure: + const $cfromInteger_rYs_info; + const GHC.Real.fromIntegral_closure; + const GHC.Num.$fNumInt_closure; + const GHC.Real.$fIntegralInteger_closure; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.824020462 UTC + +[section ""cstring" . c138_str" { + c138_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|signum" + }, + $csignum_rYt_entry() { // [R1] + { info_tbls: [(c139, + label: $csignum_rYt_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c139: // global + _rYt::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13a; else goto c13b; // CmmCondBranch + c13a: // global + R1 = _rYt::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13b: // global + (_c135::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYt::P64); // CmmUnsafeForeignCall + if (_c135::I64 == 0) goto c137; else goto c136; // CmmCondBranch + c137: // global + call (I64[_rYt::P64])() args: 8, res: 0, upd: 8; // CmmCall + c136: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c135::I64; // CmmStore + R2 = c138_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $csignum_rYt_closure" { + $csignum_rYt_closure: + const $csignum_rYt_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.826774229 UTC + +[section ""cstring" . c13o_str" { + c13o_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|abs" + }, + $cabs_rYu_entry() { // [R1] + { info_tbls: [(c13p, + label: $cabs_rYu_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13p: // global + _rYu::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13q; else goto c13r; // CmmCondBranch + c13q: // global + R1 = _rYu::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13r: // global + (_c13l::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYu::P64); // CmmUnsafeForeignCall + if (_c13l::I64 == 0) goto c13n; else goto c13m; // CmmCondBranch + c13n: // global + call (I64[_rYu::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13m: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13l::I64; // CmmStore + R2 = c13o_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cabs_rYu_closure" { + $cabs_rYu_closure: + const $cabs_rYu_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.829072883 UTC + +[section ""cstring" . c13E_str" { + c13E_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|*" + }, + $c*_rYv_entry() { // [R1] + { info_tbls: [(c13F, + label: $c*_rYv_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13F: // global + _rYv::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13G; else goto c13H; // CmmCondBranch + c13G: // global + R1 = _rYv::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13H: // global + (_c13B::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYv::P64); // CmmUnsafeForeignCall + if (_c13B::I64 == 0) goto c13D; else goto c13C; // CmmCondBranch + c13D: // global + call (I64[_rYv::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13C: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13B::I64; // CmmStore + R2 = c13E_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $c*_rYv_closure" { + $c*_rYv_closure: + const $c*_rYv_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.831813755 UTC + +[section ""cstring" . c13U_str" { + c13U_str: + I8[] "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|+" + }, + $c+_rYw_entry() { // [R1] + { info_tbls: [(c13V, + label: $c+_rYw_info + rep: HeapRep static { Thunk } + srt: Just Control.Exception.Base.noMethodBindingError_closure)] + stack_info: arg_space: 8 + } + {offset + c13V: // global + _rYw::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c13W; else goto c13X; // CmmCondBranch + c13W: // global + R1 = _rYw::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c13X: // global + (_c13R::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYw::P64); // CmmUnsafeForeignCall + if (_c13R::I64 == 0) goto c13T; else goto c13S; // CmmCondBranch + c13T: // global + call (I64[_rYw::P64])() args: 8, res: 0, upd: 8; // CmmCall + c13S: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c13R::I64; // CmmStore + R2 = c13U_str; // CmmAssign + Sp = Sp - 16; // CmmAssign + call Control.Exception.Base.noMethodBindingError_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $c+_rYw_closure" { + $c+_rYw_closure: + const $c+_rYw_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.834378646 UTC + +[$c-_rYx_entry() { // [R3, R2] + { info_tbls: [(c148, + label: $c-_rYx_info + rep: HeapRep static { Fun {arity: 2 fun_type: ArgSpec 15} } + srt: Just $c+_rYw_closure)] + stack_info: arg_space: 8 + } + {offset + c148: // global + _s11y::P64 = R3; // CmmAssign + _s11x::P64 = R2; // CmmAssign + goto c14a; // CmmBranch + c14a: // global + // slowCall + R1 = $c+_rYw_closure; // CmmAssign + call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $c-_rYx_closure" { + $c-_rYx_closure: + const $c-_rYx_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.835499478 UTC + +[$cnegate_rYy_entry() { // [R2] + { info_tbls: [(c14i, + label: $cnegate_rYy_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 5} } + srt: Just $c+_rYw_closure)] + stack_info: arg_space: 8 + } + {offset + c14i: // global + _s11z::P64 = R2; // CmmAssign + goto c14k; // CmmBranch + c14k: // global + // slowCall + R1 = $c+_rYw_closure; // CmmAssign + call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . $cnegate_rYy_closure" { + $cnegate_rYy_closure: + const $cnegate_rYy_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.836410662 UTC + +[section ""data" . ManyUbxSums_Addr.$fNumAddr_closure" { + ManyUbxSums_Addr.$fNumAddr_closure: + const GHC.Num.C:Num_con_info; + const $c+_rYw_closure; + const $c-_rYx_closure+2; + const $c*_rYv_closure; + const $cnegate_rYy_closure+1; + const $cabs_rYu_closure; + const $csignum_rYt_closure; + const $cfromInteger_rYs_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.83761474 UTC + +[sat_s11A_entry() { // [R1] + { info_tbls: [(c14v, + label: sat_s11A_info + rep: HeapRep static { Thunk } + srt: Just GHC.Enum.$fBoundedWord_closure)] + stack_info: arg_space: 8 + } + {offset + c14v: // global + _s11A::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c14w; else goto c14x; // CmmCondBranch + c14w: // global + R1 = _s11A::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c14x: // global + (_c14s::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _s11A::P64); // CmmUnsafeForeignCall + if (_c14s::I64 == 0) goto c14u; else goto c14t; // CmmCondBranch + c14u: // global + call (I64[_s11A::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14t: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14s::I64; // CmmStore + R2 = GHC.Enum.$fBoundedWord_closure; // CmmAssign + Sp = Sp - 16; // CmmAssign + call GHC.Enum.maxBound_info(R2) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . sat_s11A_closure" { + sat_s11A_closure: + const sat_s11A_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.839820084 UTC + +[section ""data" . _u14M_srt" { + _u14M_srt: + const stg_SRT_4_info; + const GHC.Real.fromIntegral_closure; + const ManyUbxSums_Addr.$fNumAddr_closure; + const GHC.Real.$fIntegralWord_closure; + const sat_s11A_closure; + const 0; + }, + $cmaxBound_rYz_entry() { // [R1] + { info_tbls: [(c14J, + label: $cmaxBound_rYz_info + rep: HeapRep static { Thunk } + srt: Just _u14M_srt)] + stack_info: arg_space: 8 + } + {offset + c14J: // global + _rYz::P64 = R1; // CmmAssign + if ((Sp + 8) - 24 < SpLim) (likely: False) goto c14K; else goto c14L; // CmmCondBranch + c14K: // global + R1 = _rYz::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c14L: // global + (_c14G::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYz::P64); // CmmUnsafeForeignCall + if (_c14G::I64 == 0) goto c14I; else goto c14H; // CmmCondBranch + c14I: // global + call (I64[_rYz::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14H: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14G::I64; // CmmStore + // slowCall + R4 = sat_s11A_closure; // CmmAssign + R3 = ManyUbxSums_Addr.$fNumAddr_closure+1; // CmmAssign + R2 = GHC.Real.$fIntegralWord_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 16; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cmaxBound_rYz_closure" { + $cmaxBound_rYz_closure: + const $cmaxBound_rYz_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.842334183 UTC + +[section ""data" . sat_s11B_closure" { + sat_s11B_closure: + const GHC.Num.Integer.IS_con_info; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.843430423 UTC + +[$cminBound_rYA_entry() { // [R1] + { info_tbls: [(c150, + label: block_c150_info + rep: StackRep [] + srt: Nothing), + (c152, + label: $cminBound_rYA_info + rep: HeapRep static { Thunk } + srt: Just $cfromInteger_rYs_closure)] + stack_info: arg_space: 8 + } + {offset + c152: // global + _rYA::P64 = R1; // CmmAssign + if ((Sp + 8) - 32 < SpLim) (likely: False) goto c159; else goto c15a; // CmmCondBranch + c159: // global + R1 = _rYA::P64; // CmmAssign + call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; // CmmCall + c15a: // global + (_c14X::I64) = call "ccall" arg hints: [PtrHint, + PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rYA::P64); // CmmUnsafeForeignCall + if (_c14X::I64 == 0) goto c14Z; else goto c14Y; // CmmCondBranch + c14Z: // global + call (I64[_rYA::P64])() args: 8, res: 0, upd: 8; // CmmCall + c14Y: // global + I64[Sp - 16] = stg_bh_upd_frame_info; // CmmStore + I64[Sp - 8] = _c14X::I64; // CmmStore + // slowCall + I64[Sp - 24] = c150; // CmmStore + R4 = sat_s11B_closure+1; // CmmAssign + R3 = GHC.Num.$fNumInt_closure; // CmmAssign + R2 = GHC.Real.$fIntegralInteger_closure; // CmmAssign + R1 = GHC.Real.fromIntegral_closure; // CmmAssign + Sp = Sp - 24; // CmmAssign + call stg_ap_ppp_fast(R4, + R3, + R2, + R1) returns to c150, args: 8, res: 8, upd: 24; // CmmCall + c150: // global + _s11C::P64 = R1; // CmmAssign + // slow_call for fromIntegral_closure with pat stg_ap_ppp + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c15d; else goto c15c; // CmmCondBranch + c15d: // global + HpAlloc = 16; // CmmAssign + R1 = _s11C::P64; // CmmAssign + call stg_gc_unpt_r1(R1) returns to c150, args: 8, res: 8, upd: 24; // CmmCall + c15c: // global + _s11D::I64 = I64[_s11C::P64 + 7]; // CmmAssign + _c155::I64 = _s11D::I64; // CmmAssign + _s11E::I64 = _c155::I64; // CmmAssign + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _s11E::I64; // CmmStore + _c158::P64 = Hp - 7; // CmmAssign + R1 = _c158::P64; // CmmAssign + Sp = Sp + 8; // CmmAssign + call (P64[Sp])(R1) args: 24, res: 0, upd: 24; // CmmCall + } + }, + section ""data" . $cminBound_rYA_closure" { + $cminBound_rYA_closure: + const $cminBound_rYA_info; + const 0; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.846850897 UTC + +[section ""data" . ManyUbxSums_Addr.$fBoundedAddr_closure" { + ManyUbxSums_Addr.$fBoundedAddr_closure: + const GHC.Enum.C:Bounded_con_info; + const $cminBound_rYA_closure; + const $cmaxBound_rYz_closure; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847227811 UTC + +[section ""data" . $trModule2_rYC_closure" { + $trModule2_rYC_closure: + const GHC.Types.TrNameS_con_info; + const $trModule1_rYB_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847546537 UTC + +[section ""data" . $trModule4_rYE_closure" { + $trModule4_rYE_closure: + const GHC.Types.TrNameS_con_info; + const $trModule3_rYD_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.847875476 UTC + +[section ""data" . ManyUbxSums_Addr.$trModule_closure" { + ManyUbxSums_Addr.$trModule_closure: + const GHC.Types.Module_con_info; + const $trModule2_rYC_closure+1; + const $trModule4_rYE_closure+1; + const 3; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.848609602 UTC + +[section ""data" . $krep_rYF_closure" { + $krep_rYF_closure: + const GHC.Types.KindRepTyConApp_con_info; + const GHC.Types.$tcAddr#_closure; + const GHC.Types.[]_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.8489625 UTC + +[section ""data" . $tcAddr2_rYH_closure" { + $tcAddr2_rYH_closure: + const GHC.Types.TrNameS_con_info; + const $tcAddr1_rYG_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.849319124 UTC + +[section ""data" . ManyUbxSums_Addr.$tcAddr_closure" { + ManyUbxSums_Addr.$tcAddr_closure: + const GHC.Types.TyCon_con_info; + const ManyUbxSums_Addr.$trModule_closure+1; + const $tcAddr2_rYH_closure+1; + const GHC.Types.krep$*_closure; + const 4790135393693416043; + const 4509054882010932911; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.849776569 UTC + +[section ""data" . $krep1_rYI_closure" { + $krep1_rYI_closure: + const GHC.Types.KindRepTyConApp_con_info; + const ManyUbxSums_Addr.$tcAddr_closure+1; + const GHC.Types.[]_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850145038 UTC + +[section ""data" . $krep2_rYJ_closure" { + $krep2_rYJ_closure: + const GHC.Types.KindRepFun_con_info; + const $krep_rYF_closure+1; + const $krep1_rYI_closure+1; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850499273 UTC + +[section ""data" . $tc'Addr2_rYL_closure" { + $tc'Addr2_rYL_closure: + const GHC.Types.TrNameS_con_info; + const $tc'Addr1_rYK_bytes; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.850843839 UTC + +[section ""data" . ManyUbxSums_Addr.$tc'Addr_closure" { + ManyUbxSums_Addr.$tc'Addr_closure: + const GHC.Types.TyCon_con_info; + const ManyUbxSums_Addr.$trModule_closure+1; + const $tc'Addr2_rYL_closure+1; + const $krep2_rYJ_closure+4; + const 15766329447734056695; + const 3176921173291726962; + const 0; + const 0; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.851681093 UTC + +[ManyUbxSums_Addr.Addr_entry() { // [R2] + { info_tbls: [(c15z, + label: ManyUbxSums_Addr.Addr_info + rep: HeapRep static { Fun {arity: 1 fun_type: ArgSpec 4} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c15z: // global + _B0::I64 = R2; // CmmAssign + goto c15B; // CmmBranch + c15B: // global + Hp = Hp + 16; // CmmAssign + if (Hp > HpLim) (likely: False) goto c15D; else goto c15C; // CmmCondBranch + c15D: // global + HpAlloc = 16; // CmmAssign + goto c15A; // CmmBranch + c15A: // global + R2 = _B0::I64; // CmmAssign + R1 = ManyUbxSums_Addr.Addr_closure; // CmmAssign + call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8; // CmmCall + c15C: // global + // allocHeapClosure + I64[Hp - 8] = ManyUbxSums_Addr.Addr_con_info; // CmmStore + I64[Hp] = _B0::I64; // CmmStore + _c15y::P64 = Hp - 7; // CmmAssign + R1 = _c15y::P64; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }, + section ""data" . ManyUbxSums_Addr.Addr_closure" { + ManyUbxSums_Addr.Addr_closure: + const ManyUbxSums_Addr.Addr_info; + }] + + +==================== Output Cmm ==================== +2022-09-27 22:20:23.853732429 UTC + +[ManyUbxSums_Addr.Addr_con_entry() { // [] + { info_tbls: [(c15H, + label: ManyUbxSums_Addr.Addr_con_info + rep: HeapRep 1 nonptrs { + Con {tag: 0 descr:"main:ManyUbxSums_Addr.Addr"} } + srt: Nothing)] + stack_info: arg_space: 8 + } + {offset + c15H: // global + R1 = R1 + 1; // CmmAssign + call (P64[Sp])(R1) args: 8, res: 0, upd: 8; // CmmCall + } + }] + ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.debug.dump-stg-final ===================================== @@ -0,0 +1,214 @@ + +==================== Final STG: ==================== +2022-09-27 22:20:23.80547185 UTC + +$tc'Addr1_rYK :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "'Addr"#; + +$tcAddr1_rYG :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "Addr"#; + +$trModule3_rYD :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "ManyUbxSums_Addr"#; + +$trModule1_rYB :: GHC.Prim.Addr# +[GblId, Unf=OtherCon []] = + "main"#; + +$c==_rYq + :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr -> GHC.Types.Bool +[GblId, Arity=2, Unf=OtherCon []] = + {} \r [ds_s11j ds1_s11k] + case ds_s11j of { + ManyUbxSums_Addr.Addr x_s11m [Occ=Once1] -> + case ds1_s11k of { + ManyUbxSums_Addr.Addr y_s11o [Occ=Once1] -> + case eqAddr# [x_s11m:AddrRep y_s11o:AddrRep] of { + __DEFAULT -> + Control.Exception.Base.patError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:(15,28)-(17,17)|case"#:AddrRep; + 0# -> GHC.Types.False []; + 1# -> GHC.Types.True []; + }; + }; + }; + +$c/=_rYr + :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr -> GHC.Types.Bool +[GblId, Arity=2, Unf=OtherCon []] = + {} \r [x_s11q y_s11r] + case $c==_rYq x_s11q:LiftedRep y_s11r:LiftedRep of { + GHC.Types.False -> GHC.Types.True []; + GHC.Types.True -> GHC.Types.False []; + }; + +ManyUbxSums_Addr.$fEqAddr [InlPrag=CONLIKE] + :: GHC.Classes.Eq ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Classes.C:Eq! [$c==_rYq:LiftedRep $c/=_rYr:LiftedRep]; + +$cfromInteger_rYs + :: GHC.Num.Integer.Integer -> ManyUbxSums_Addr.Addr +[GblId, Arity=1, Unf=OtherCon []] = + {} \r [x_s11t] + case + GHC.Real.fromIntegral + GHC.Real.$fIntegralInteger:LiftedRep + GHC.Num.$fNumInt:LiftedRep + x_s11t:LiftedRep + of + { + GHC.Types.I# x1_s11v [Occ=Once1] -> + case int2Addr# [x1_s11v:IntRep] of sat_s11w [Occ=Once1] { + __DEFAULT -> ManyUbxSums_Addr.Addr [sat_s11w:AddrRep]; + }; + }; + +$csignum_rYt :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|signum"#:AddrRep; + +$cabs_rYu :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|abs"#:AddrRep; + +$c*_rYv + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|*"#:AddrRep; + +$c+_rYw + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Str=b, Cpr=b] = + {} \u [] + Control.Exception.Base.noMethodBindingError + "testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs:19:10-17|+"#:AddrRep; + +$c-_rYx + :: ManyUbxSums_Addr.Addr + -> ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Arity=2, Str=b, Cpr=b, Unf=OtherCon []] = + {} \r [x_s11x y_s11y] $c+_rYw; + +$cnegate_rYy :: ManyUbxSums_Addr.Addr -> ManyUbxSums_Addr.Addr +[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] = + {} \r [x_s11z] $c+_rYw; + +ManyUbxSums_Addr.$fNumAddr [InlPrag=CONLIKE] + :: GHC.Num.Num ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Num.C:Num! [$c+_rYw:LiftedRep + $c-_rYx:LiftedRep + $c*_rYv:LiftedRep + $cnegate_rYy:LiftedRep + $cabs_rYu:LiftedRep + $csignum_rYt:LiftedRep + $cfromInteger_rYs:LiftedRep]; + +sat_s11A :: GHC.Types.Word +[LclId] = + {} \u [] GHC.Enum.maxBound GHC.Enum.$fBoundedWord:LiftedRep; + +$cmaxBound_rYz :: ManyUbxSums_Addr.Addr +[GblId] = + {} \u [] + GHC.Real.fromIntegral + GHC.Real.$fIntegralWord:LiftedRep + ManyUbxSums_Addr.$fNumAddr:LiftedRep + sat_s11A:LiftedRep; + +sat_s11B :: GHC.Num.Integer.Integer +[LclId] = + GHC.Num.Integer.IS! [0#:IntRep]; + +$cminBound_rYA :: ManyUbxSums_Addr.Addr +[GblId] = + {} \u [] + case + GHC.Real.fromIntegral + GHC.Real.$fIntegralInteger:LiftedRep + GHC.Num.$fNumInt:LiftedRep + sat_s11B:LiftedRep + of + { + GHC.Types.I# x1_s11D [Occ=Once1] -> + case int2Addr# [x1_s11D:IntRep] of sat_s11E [Occ=Once1] { + __DEFAULT -> ManyUbxSums_Addr.Addr [sat_s11E:AddrRep]; + }; + }; + +ManyUbxSums_Addr.$fBoundedAddr [InlPrag=CONLIKE] + :: GHC.Enum.Bounded ManyUbxSums_Addr.Addr +[GblId[DFunId], Unf=OtherCon []] = + GHC.Enum.C:Bounded! [$cminBound_rYA:LiftedRep + $cmaxBound_rYz:LiftedRep]; + +$trModule2_rYC :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$trModule1_rYB:AddrRep]; + +$trModule4_rYE :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$trModule3_rYD:AddrRep]; + +ManyUbxSums_Addr.$trModule :: GHC.Types.Module +[GblId, Unf=OtherCon []] = + GHC.Types.Module! [$trModule2_rYC:LiftedRep + $trModule4_rYE:LiftedRep]; + +$krep_rYF :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepTyConApp! [GHC.Types.$tcAddr#:LiftedRep + GHC.Types.[]:LiftedRep]; + +$tcAddr2_rYH :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$tcAddr1_rYG:AddrRep]; + +ManyUbxSums_Addr.$tcAddr :: GHC.Types.TyCon +[GblId, Unf=OtherCon []] = + GHC.Types.TyCon! [4790135393693416043##64:Word64Rep + 4509054882010932911##64:Word64Rep + ManyUbxSums_Addr.$trModule:LiftedRep + $tcAddr2_rYH:LiftedRep + 0#:IntRep + GHC.Types.krep$*:LiftedRep]; + +$krep1_rYI :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepTyConApp! [ManyUbxSums_Addr.$tcAddr:LiftedRep + GHC.Types.[]:LiftedRep]; + +$krep2_rYJ :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] = + GHC.Types.KindRepFun! [$krep_rYF:LiftedRep $krep1_rYI:LiftedRep]; + +$tc'Addr2_rYL :: GHC.Types.TrName +[GblId, Unf=OtherCon []] = + GHC.Types.TrNameS! [$tc'Addr1_rYK:AddrRep]; + +ManyUbxSums_Addr.$tc'Addr :: GHC.Types.TyCon +[GblId, Unf=OtherCon []] = + GHC.Types.TyCon! [15766329447734056695##64:Word64Rep + 3176921173291726962##64:Word64Rep + ManyUbxSums_Addr.$trModule:LiftedRep + $tc'Addr2_rYL:LiftedRep + 0#:IntRep + $krep2_rYJ:LiftedRep]; + +ManyUbxSums_Addr.Addr [InlPrag=CONLIKE] + :: GHC.Prim.Addr# %1 -> ManyUbxSums_Addr.Addr +[GblId[DataCon], Arity=1, Caf=NoCafRefs, Unf=OtherCon []] = + {} \r [eta_B0] ManyUbxSums_Addr.Addr [eta_B0:AddrRep]; + ===================================== 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('./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/0a9a65b494907f8ebebeef57107051237b88862a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a9a65b494907f8ebebeef57107051237b88862a You're receiving 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 Sep 27 22:53:12 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 18:53:12 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63337ed831586_2c97575140052768e@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: aac14f19 by Andreas Klebinger at 2022-09-28T00:52:01+02: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,207 @@ +{- +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.Trace +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 f t = + let r = getCasts' f t + in pprTrace "getCasts" (ppr (f,t,r)) r + + +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 = [] +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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,11 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Utils.Trace +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +344,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 +360,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 +408,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 +421,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 +432,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 unariseUbxSumTupleArgs 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 +450,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 unariseUbxSumTupleArgs 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 +487,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +528,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 +631,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 +678,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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 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 +766,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 +781,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +936,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 +958,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 ) -------------------------------------------------------------------------------- ===================================== 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,102 @@ +#!/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 + +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 (# t1 | t2 #) and one (# t1 | t3). +-- So build all the combinations 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: +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | Addr# #) -> (# Addr# | Addr# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | Addr# #) +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 = 0 +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + "test" ++ show n ++ " =\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" + +-- Test all the tuples +mkTests n [] = "" +mkTests n (combo:combos) = + mkTest n combo ++ "\n" ++ mkTests (n+1) combos + + +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" + + -- Actually invoke all the tests + 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,1331 @@ +test0 True +test1 True +test2 True +test3 True +test4 True +test5 True +test6 True +test7 True +test8 True +test9 True +test10 True +test11 True +test12 True +test13 True +test14 True +test15 True +test16 True +test17 True +test18 True +test19 True +test20 True +test21 True +test22 True +test23 True +test24 True +test25 True +test26 True +test27 True +test28 True +test29 True +test30 True +test31 True +test32 True +test33 True +test34 True +test35 True +test36 True +test37 True +test38 True +test39 True +test40 True +test41 True +test42 True +test43 True +test44 True +test45 True +test46 True +test47 True +test48 True +test49 True +test50 True +test51 True +test52 True +test53 True +test54 True +test55 True +test56 True +test57 True +test58 True +test59 True +test60 True +test61 True +test62 True +test63 True +test64 True +test65 True +test66 True +test67 True +test68 True +test69 True +test70 True +test71 True +test72 True +test73 True +test74 True +test75 True +test76 True +test77 True +test78 True +test79 True +test80 True +test81 True +test82 True +test83 True +test84 True +test85 True +test86 True +test87 True +test88 True +test89 True +test90 True +test91 True +test92 True +test93 True +test94 True +test95 True +test96 True +test97 True +test98 True +test99 True +test100 True +test101 True +test102 True +test103 True +test104 True +test105 True +test106 True +test107 True +test108 True +test109 True +test110 True +test111 True +test112 True +test113 True +test114 True +test115 True +test116 True +test117 True +test118 True +test119 True +test120 True +test121 True +test122 True +test123 True +test124 True +test125 True +test126 True +test127 True +test128 True +test129 True +test130 True +test131 True +test132 True +test133 True +test134 True +test135 True +test136 True +test137 True +test138 True +test139 True +test140 True +test141 True +test142 True +test143 True +test144 True +test145 True +test146 True +test147 True +test148 True +test149 True +test150 True +test151 True +test152 True +test153 True +test154 True +test155 True +test156 True +test157 True +test158 True +test159 True +test160 True +test161 True +test162 True +test163 True +test164 True +test165 True +test166 True +test167 True +test168 True +test169 True +test170 True +test171 True +test172 True +test173 True +test174 True +test175 True +test176 True +test177 True +test178 True +test179 True +test180 True +test181 True +test182 True +test183 True +test184 True +test185 True +test186 True +test187 True +test188 True +test189 True +test190 True +test191 True +test192 True +test193 True +test194 True +test195 True +test196 True +test197 True +test198 True +test199 True +test200 True +test201 True +test202 True +test203 True +test204 True +test205 True +test206 True +test207 True +test208 True +test209 True +test210 True +test211 True +test212 True +test213 True +test214 True +test215 True +test216 True +test217 True +test218 True +test219 True +test220 True +test221 True +test222 True +test223 True +test224 True +test225 True +test226 True +test227 True +test228 True +test229 True +test230 True +test231 True +test232 True +test233 True +test234 True +test235 True +test236 True +test237 True +test238 True +test239 True +test240 True +test241 True +test242 True +test243 True +test244 True +test245 True +test246 True +test247 True +test248 True +test249 True +test250 True +test251 True +test252 True +test253 True +test254 True +test255 True +test256 True +test257 True +test258 True +test259 True +test260 True +test261 True +test262 True +test263 True +test264 True +test265 True +test266 True +test267 True +test268 True +test269 True +test270 True +test271 True +test272 True +test273 True +test274 True +test275 True +test276 True +test277 True +test278 True +test279 True +test280 True +test281 True +test282 True +test283 True +test284 True +test285 True +test286 True +test287 True +test288 True +test289 True +test290 True +test291 True +test292 True +test293 True +test294 True +test295 True +test296 True +test297 True +test298 True +test299 True +test300 True +test301 True +test302 True +test303 True +test304 True +test305 True +test306 True +test307 True +test308 True +test309 True +test310 True +test311 True +test312 True +test313 True +test314 True +test315 True +test316 True +test317 True +test318 True +test319 True +test320 True +test321 True +test322 True +test323 True +test324 True +test325 True +test326 True +test327 True +test328 True +test329 True +test330 True +test331 True +test332 True +test333 True +test334 True +test335 True +test336 True +test337 True +test338 True +test339 True +test340 True +test341 True +test342 True +test343 True +test344 True +test345 True +test346 True +test347 True +test348 True +test349 True +test350 True +test351 True +test352 True +test353 True +test354 True +test355 True +test356 True +test357 True +test358 True +test359 True +test360 True +test361 True +test362 True +test363 True +test364 True +test365 True +test366 True +test367 True +test368 True +test369 True +test370 True +test371 True +test372 True +test373 True +test374 True +test375 True +test376 True +test377 True +test378 True +test379 True +test380 True +test381 True +test382 True +test383 True +test384 True +test385 True +test386 True +test387 True +test388 True +test389 True +test390 True +test391 True +test392 True +test393 True +test394 True +test395 True +test396 True +test397 True +test398 True +test399 True +test400 True +test401 True +test402 True +test403 True +test404 True +test405 True +test406 True +test407 True +test408 True +test409 True +test410 True +test411 True +test412 True +test413 True +test414 True +test415 True +test416 True +test417 True +test418 True +test419 True +test420 True +test421 True +test422 True +test423 True +test424 True +test425 True +test426 True +test427 True +test428 True +test429 True +test430 True +test431 True +test432 True +test433 True +test434 True +test435 True +test436 True +test437 True +test438 True +test439 True +test440 True +test441 True +test442 True +test443 True +test444 True +test445 True +test446 True +test447 True +test448 True +test449 True +test450 True +test451 True +test452 True +test453 True +test454 True +test455 True +test456 True +test457 True +test458 True +test459 True +test460 True +test461 True +test462 True +test463 True +test464 True +test465 True +test466 True +test467 True +test468 True +test469 True +test470 True +test471 True +test472 True +test473 True +test474 True +test475 True +test476 True +test477 True +test478 True +test479 True +test480 True +test481 True +test482 True +test483 True +test484 True +test485 True +test486 True +test487 True +test488 True +test489 True +test490 True +test491 True +test492 True +test493 True +test494 True +test495 True +test496 True +test497 True +test498 True +test499 True +test500 True +test501 True +test502 True +test503 True +test504 True +test505 True +test506 True +test507 True +test508 True +test509 True +test510 True +test511 True +test512 True +test513 True +test514 True +test515 True +test516 True +test517 True +test518 True +test519 True +test520 True +test521 True +test522 True +test523 True +test524 True +test525 True +test526 True +test527 True +test528 True +test529 True +test530 True +test531 True +test532 True +test533 True +test534 True +test535 True +test536 True +test537 True +test538 True +test539 True +test540 True +test541 True +test542 True +test543 True +test544 True +test545 True +test546 True +test547 True +test548 True +test549 True +test550 True +test551 True +test552 True +test553 True +test554 True +test555 True +test556 True +test557 True +test558 True +test559 True +test560 True +test561 True +test562 True +test563 True +test564 True +test565 True +test566 True +test567 True +test568 True +test569 True +test570 True +test571 True +test572 True +test573 True +test574 True +test575 True +test576 True +test577 True +test578 True +test579 True +test580 True +test581 True +test582 True +test583 True +test584 True +test585 True +test586 True +test587 True +test588 True +test589 True +test590 True +test591 True +test592 True +test593 True +test594 True +test595 True +test596 True +test597 True +test598 True +test599 True +test600 True +test601 True +test602 True +test603 True +test604 True +test605 True +test606 True +test607 True +test608 True +test609 True +test610 True +test611 True +test612 True +test613 True +test614 True +test615 True +test616 True +test617 True +test618 True +test619 True +test620 True +test621 True +test622 True +test623 True +test624 True +test625 True +test626 True +test627 True +test628 True +test629 True +test630 True +test631 True +test632 True +test633 True +test634 True +test635 True +test636 True +test637 True +test638 True +test639 True +test640 True +test641 True +test642 True +test643 True +test644 True +test645 True +test646 True +test647 True +test648 True +test649 True +test650 True +test651 True +test652 True +test653 True +test654 True +test655 True +test656 True +test657 True +test658 True +test659 True +test660 True +test661 True +test662 True +test663 True +test664 True +test665 True +test666 True +test667 True +test668 True +test669 True +test670 True +test671 True +test672 True +test673 True +test674 True +test675 True +test676 True +test677 True +test678 True +test679 True +test680 True +test681 True +test682 True +test683 True +test684 True +test685 True +test686 True +test687 True +test688 True +test689 True +test690 True +test691 True +test692 True +test693 True +test694 True +test695 True +test696 True +test697 True +test698 True +test699 True +test700 True +test701 True +test702 True +test703 True +test704 True +test705 True +test706 True +test707 True +test708 True +test709 True +test710 True +test711 True +test712 True +test713 True +test714 True +test715 True +test716 True +test717 True +test718 True +test719 True +test720 True +test721 True +test722 True +test723 True +test724 True +test725 True +test726 True +test727 True +test728 True +test729 True +test730 True +test731 True +test732 True +test733 True +test734 True +test735 True +test736 True +test737 True +test738 True +test739 True +test740 True +test741 True +test742 True +test743 True +test744 True +test745 True +test746 True +test747 True +test748 True +test749 True +test750 True +test751 True +test752 True +test753 True +test754 True +test755 True +test756 True +test757 True +test758 True +test759 True +test760 True +test761 True +test762 True +test763 True +test764 True +test765 True +test766 True +test767 True +test768 True +test769 True +test770 True +test771 True +test772 True +test773 True +test774 True +test775 True +test776 True +test777 True +test778 True +test779 True +test780 True +test781 True +test782 True +test783 True +test784 True +test785 True +test786 True +test787 True +test788 True +test789 True +test790 True +test791 True +test792 True +test793 True +test794 True +test795 True +test796 True +test797 True +test798 True +test799 True +test800 True +test801 True +test802 True +test803 True +test804 True +test805 True +test806 True +test807 True +test808 True +test809 True +test810 True +test811 True +test812 True +test813 True +test814 True +test815 True +test816 True +test817 True +test818 True +test819 True +test820 True +test821 True +test822 True +test823 True +test824 True +test825 True +test826 True +test827 True +test828 True +test829 True +test830 True +test831 True +test832 True +test833 True +test834 True +test835 True +test836 True +test837 True +test838 True +test839 True +test840 True +test841 True +test842 True +test843 True +test844 True +test845 True +test846 True +test847 True +test848 True +test849 True +test850 True +test851 True +test852 True +test853 True +test854 True +test855 True +test856 True +test857 True +test858 True +test859 True +test860 True +test861 True +test862 True +test863 True +test864 True +test865 True +test866 True +test867 True +test868 True +test869 True +test870 True +test871 True +test872 True +test873 True +test874 True +test875 True +test876 True +test877 True +test878 True +test879 True +test880 True +test881 True +test882 True +test883 True +test884 True +test885 True +test886 True +test887 True +test888 True +test889 True +test890 True +test891 True +test892 True +test893 True +test894 True +test895 True +test896 True +test897 True +test898 True +test899 True +test900 True +test901 True +test902 True +test903 True +test904 True +test905 True +test906 True +test907 True +test908 True +test909 True +test910 True +test911 True +test912 True +test913 True +test914 True +test915 True +test916 True +test917 True +test918 True +test919 True +test920 True +test921 True +test922 True +test923 True +test924 True +test925 True +test926 True +test927 True +test928 True +test929 True +test930 True +test931 True +test932 True +test933 True +test934 True +test935 True +test936 True +test937 True +test938 True +test939 True +test940 True +test941 True +test942 True +test943 True +test944 True +test945 True +test946 True +test947 True +test948 True +test949 True +test950 True +test951 True +test952 True +test953 True +test954 True +test955 True +test956 True +test957 True +test958 True +test959 True +test960 True +test961 True +test962 True +test963 True +test964 True +test965 True +test966 True +test967 True +test968 True +test969 True +test970 True +test971 True +test972 True +test973 True +test974 True +test975 True +test976 True +test977 True +test978 True +test979 True +test980 True +test981 True +test982 True +test983 True +test984 True +test985 True +test986 True +test987 True +test988 True +test989 True +test990 True +test991 True +test992 True +test993 True +test994 True +test995 True +test996 True +test997 True +test998 True +test999 True +test1000 True +test1001 True +test1002 True +test1003 True +test1004 True +test1005 True +test1006 True +test1007 True +test1008 True +test1009 True +test1010 True +test1011 True +test1012 True +test1013 True +test1014 True +test1015 True +test1016 True +test1017 True +test1018 True +test1019 True +test1020 True +test1021 True +test1022 True +test1023 True +test1024 True +test1025 True +test1026 True +test1027 True +test1028 True +test1029 True +test1030 True +test1031 True +test1032 True +test1033 True +test1034 True +test1035 True +test1036 True +test1037 True +test1038 True +test1039 True +test1040 True +test1041 True +test1042 True +test1043 True +test1044 True +test1045 True +test1046 True +test1047 True +test1048 True +test1049 True +test1050 True +test1051 True +test1052 True +test1053 True +test1054 True +test1055 True +test1056 True +test1057 True +test1058 True +test1059 True +test1060 True +test1061 True +test1062 True +test1063 True +test1064 True +test1065 True +test1066 True +test1067 True +test1068 True +test1069 True +test1070 True +test1071 True +test1072 True +test1073 True +test1074 True +test1075 True +test1076 True +test1077 True +test1078 True +test1079 True +test1080 True +test1081 True +test1082 True +test1083 True +test1084 True +test1085 True +test1086 True +test1087 True +test1088 True +test1089 True +test1090 True +test1091 True +test1092 True +test1093 True +test1094 True +test1095 True +test1096 True +test1097 True +test1098 True +test1099 True +test1100 True +test1101 True +test1102 True +test1103 True +test1104 True +test1105 True +test1106 True +test1107 True +test1108 True +test1109 True +test1110 True +test1111 True +test1112 True +test1113 True +test1114 True +test1115 True +test1116 True +test1117 True +test1118 True +test1119 True +test1120 True +test1121 True +test1122 True +test1123 True +test1124 True +test1125 True +test1126 True +test1127 True +test1128 True +test1129 True +test1130 True +test1131 True +test1132 True +test1133 True +test1134 True +test1135 True +test1136 True +test1137 True +test1138 True +test1139 True +test1140 True +test1141 True +test1142 True +test1143 True +test1144 True +test1145 True +test1146 True +test1147 True +test1148 True +test1149 True +test1150 True +test1151 True +test1152 True +test1153 True +test1154 True +test1155 True +test1156 True +test1157 True +test1158 True +test1159 True +test1160 True +test1161 True +test1162 True +test1163 True +test1164 True +test1165 True +test1166 True +test1167 True +test1168 True +test1169 True +test1170 True +test1171 True +test1172 True +test1173 True +test1174 True +test1175 True +test1176 True +test1177 True +test1178 True +test1179 True +test1180 True +test1181 True +test1182 True +test1183 True +test1184 True +test1185 True +test1186 True +test1187 True +test1188 True +test1189 True +test1190 True +test1191 True +test1192 True +test1193 True +test1194 True +test1195 True +test1196 True +test1197 True +test1198 True +test1199 True +test1200 True +test1201 True +test1202 True +test1203 True +test1204 True +test1205 True +test1206 True +test1207 True +test1208 True +test1209 True +test1210 True +test1211 True +test1212 True +test1213 True +test1214 True +test1215 True +test1216 True +test1217 True +test1218 True +test1219 True +test1220 True +test1221 True +test1222 True +test1223 True +test1224 True +test1225 True +test1226 True +test1227 True +test1228 True +test1229 True +test1230 True +test1231 True +test1232 True +test1233 True +test1234 True +test1235 True +test1236 True +test1237 True +test1238 True +test1239 True +test1240 True +test1241 True +test1242 True +test1243 True +test1244 True +test1245 True +test1246 True +test1247 True +test1248 True +test1249 True +test1250 True +test1251 True +test1252 True +test1253 True +test1254 True +test1255 True +test1256 True +test1257 True +test1258 True +test1259 True +test1260 True +test1261 True +test1262 True +test1263 True +test1264 True +test1265 True +test1266 True +test1267 True +test1268 True +test1269 True +test1270 True +test1271 True +test1272 True +test1273 True +test1274 True +test1275 True +test1276 True +test1277 True +test1278 True +test1279 True +test1280 True +test1281 True +test1282 True +test1283 True +test1284 True +test1285 True +test1286 True +test1287 True +test1288 True +test1289 True +test1290 True +test1291 True +test1292 True +test1293 True +test1294 True +test1295 True +test1296 True +test1297 True +test1298 True +test1299 True +test1300 True +test1301 True +test1302 True +test1303 True +test1304 True +test1305 True +test1306 True +test1307 True +test1308 True +test1309 True +test1310 True +test1311 True +test1312 True +test1313 True +test1314 True +test1315 True +test1316 True +test1317 True +test1318 True +test1319 True +test1320 True +test1321 True +test1322 True +test1323 True +test1324 True +test1325 True +test1326 True +test1327 True +test1328 True +test1329 True +test1330 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('./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/aac14f1952bf2f5573c2144ae35720b2dd164448 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aac14f1952bf2f5573c2144ae35720b2dd164448 You're receiving 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 Sep 27 22:55:38 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 27 Sep 2022 18:55:38 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63337f6ab4721_2c9757dfd405299f7@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: b1eefe1e by Andreas Klebinger at 2022-09-28T00:54:13+02: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,201 @@ +{- +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 that 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` +in order to get to a variable of rep `to_rep`. + +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' -> +-} + +-- | `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 = [] +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,39 @@ 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. +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. + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +291,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 +314,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 +343,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 +359,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 +407,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 +420,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 +431,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 unariseUbxSumTupleArgs 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 +449,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 unariseUbxSumTupleArgs 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 +486,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 +unariseUbxSumTupleArgs :: 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 +unariseUbxSumTupleArgs 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 "unariseUbxSumTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +527,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 +630,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 +677,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 + + -- 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 + + -- rep-based types for the field binders + 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 + -- See Note [Casting slot arguments] + -- 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 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 +765,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 +780,51 @@ 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 + -- cast_ops = getCasts (typePrimRep1 $ idType arg_id) (slotPrimRep slot_ty) + 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 (arg,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 +935,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 +957,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 ) -------------------------------------------------------------------------------- ===================================== 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,102 @@ +#!/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 + +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 (# t1 | t2 #) and one (# t1 | t3). +-- So build all the combinations 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: +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | Addr# #) -> (# Addr# | Addr# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | Addr# #) +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 = 0 +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + "test" ++ show n ++ " =\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" + +-- Test all the tuples +mkTests n [] = "" +mkTests n (combo:combos) = + mkTest n combo ++ "\n" ++ mkTests (n+1) combos + + +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" + + -- Actually invoke all the tests + 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,1331 @@ +test0 True +test1 True +test2 True +test3 True +test4 True +test5 True +test6 True +test7 True +test8 True +test9 True +test10 True +test11 True +test12 True +test13 True +test14 True +test15 True +test16 True +test17 True +test18 True +test19 True +test20 True +test21 True +test22 True +test23 True +test24 True +test25 True +test26 True +test27 True +test28 True +test29 True +test30 True +test31 True +test32 True +test33 True +test34 True +test35 True +test36 True +test37 True +test38 True +test39 True +test40 True +test41 True +test42 True +test43 True +test44 True +test45 True +test46 True +test47 True +test48 True +test49 True +test50 True +test51 True +test52 True +test53 True +test54 True +test55 True +test56 True +test57 True +test58 True +test59 True +test60 True +test61 True +test62 True +test63 True +test64 True +test65 True +test66 True +test67 True +test68 True +test69 True +test70 True +test71 True +test72 True +test73 True +test74 True +test75 True +test76 True +test77 True +test78 True +test79 True +test80 True +test81 True +test82 True +test83 True +test84 True +test85 True +test86 True +test87 True +test88 True +test89 True +test90 True +test91 True +test92 True +test93 True +test94 True +test95 True +test96 True +test97 True +test98 True +test99 True +test100 True +test101 True +test102 True +test103 True +test104 True +test105 True +test106 True +test107 True +test108 True +test109 True +test110 True +test111 True +test112 True +test113 True +test114 True +test115 True +test116 True +test117 True +test118 True +test119 True +test120 True +test121 True +test122 True +test123 True +test124 True +test125 True +test126 True +test127 True +test128 True +test129 True +test130 True +test131 True +test132 True +test133 True +test134 True +test135 True +test136 True +test137 True +test138 True +test139 True +test140 True +test141 True +test142 True +test143 True +test144 True +test145 True +test146 True +test147 True +test148 True +test149 True +test150 True +test151 True +test152 True +test153 True +test154 True +test155 True +test156 True +test157 True +test158 True +test159 True +test160 True +test161 True +test162 True +test163 True +test164 True +test165 True +test166 True +test167 True +test168 True +test169 True +test170 True +test171 True +test172 True +test173 True +test174 True +test175 True +test176 True +test177 True +test178 True +test179 True +test180 True +test181 True +test182 True +test183 True +test184 True +test185 True +test186 True +test187 True +test188 True +test189 True +test190 True +test191 True +test192 True +test193 True +test194 True +test195 True +test196 True +test197 True +test198 True +test199 True +test200 True +test201 True +test202 True +test203 True +test204 True +test205 True +test206 True +test207 True +test208 True +test209 True +test210 True +test211 True +test212 True +test213 True +test214 True +test215 True +test216 True +test217 True +test218 True +test219 True +test220 True +test221 True +test222 True +test223 True +test224 True +test225 True +test226 True +test227 True +test228 True +test229 True +test230 True +test231 True +test232 True +test233 True +test234 True +test235 True +test236 True +test237 True +test238 True +test239 True +test240 True +test241 True +test242 True +test243 True +test244 True +test245 True +test246 True +test247 True +test248 True +test249 True +test250 True +test251 True +test252 True +test253 True +test254 True +test255 True +test256 True +test257 True +test258 True +test259 True +test260 True +test261 True +test262 True +test263 True +test264 True +test265 True +test266 True +test267 True +test268 True +test269 True +test270 True +test271 True +test272 True +test273 True +test274 True +test275 True +test276 True +test277 True +test278 True +test279 True +test280 True +test281 True +test282 True +test283 True +test284 True +test285 True +test286 True +test287 True +test288 True +test289 True +test290 True +test291 True +test292 True +test293 True +test294 True +test295 True +test296 True +test297 True +test298 True +test299 True +test300 True +test301 True +test302 True +test303 True +test304 True +test305 True +test306 True +test307 True +test308 True +test309 True +test310 True +test311 True +test312 True +test313 True +test314 True +test315 True +test316 True +test317 True +test318 True +test319 True +test320 True +test321 True +test322 True +test323 True +test324 True +test325 True +test326 True +test327 True +test328 True +test329 True +test330 True +test331 True +test332 True +test333 True +test334 True +test335 True +test336 True +test337 True +test338 True +test339 True +test340 True +test341 True +test342 True +test343 True +test344 True +test345 True +test346 True +test347 True +test348 True +test349 True +test350 True +test351 True +test352 True +test353 True +test354 True +test355 True +test356 True +test357 True +test358 True +test359 True +test360 True +test361 True +test362 True +test363 True +test364 True +test365 True +test366 True +test367 True +test368 True +test369 True +test370 True +test371 True +test372 True +test373 True +test374 True +test375 True +test376 True +test377 True +test378 True +test379 True +test380 True +test381 True +test382 True +test383 True +test384 True +test385 True +test386 True +test387 True +test388 True +test389 True +test390 True +test391 True +test392 True +test393 True +test394 True +test395 True +test396 True +test397 True +test398 True +test399 True +test400 True +test401 True +test402 True +test403 True +test404 True +test405 True +test406 True +test407 True +test408 True +test409 True +test410 True +test411 True +test412 True +test413 True +test414 True +test415 True +test416 True +test417 True +test418 True +test419 True +test420 True +test421 True +test422 True +test423 True +test424 True +test425 True +test426 True +test427 True +test428 True +test429 True +test430 True +test431 True +test432 True +test433 True +test434 True +test435 True +test436 True +test437 True +test438 True +test439 True +test440 True +test441 True +test442 True +test443 True +test444 True +test445 True +test446 True +test447 True +test448 True +test449 True +test450 True +test451 True +test452 True +test453 True +test454 True +test455 True +test456 True +test457 True +test458 True +test459 True +test460 True +test461 True +test462 True +test463 True +test464 True +test465 True +test466 True +test467 True +test468 True +test469 True +test470 True +test471 True +test472 True +test473 True +test474 True +test475 True +test476 True +test477 True +test478 True +test479 True +test480 True +test481 True +test482 True +test483 True +test484 True +test485 True +test486 True +test487 True +test488 True +test489 True +test490 True +test491 True +test492 True +test493 True +test494 True +test495 True +test496 True +test497 True +test498 True +test499 True +test500 True +test501 True +test502 True +test503 True +test504 True +test505 True +test506 True +test507 True +test508 True +test509 True +test510 True +test511 True +test512 True +test513 True +test514 True +test515 True +test516 True +test517 True +test518 True +test519 True +test520 True +test521 True +test522 True +test523 True +test524 True +test525 True +test526 True +test527 True +test528 True +test529 True +test530 True +test531 True +test532 True +test533 True +test534 True +test535 True +test536 True +test537 True +test538 True +test539 True +test540 True +test541 True +test542 True +test543 True +test544 True +test545 True +test546 True +test547 True +test548 True +test549 True +test550 True +test551 True +test552 True +test553 True +test554 True +test555 True +test556 True +test557 True +test558 True +test559 True +test560 True +test561 True +test562 True +test563 True +test564 True +test565 True +test566 True +test567 True +test568 True +test569 True +test570 True +test571 True +test572 True +test573 True +test574 True +test575 True +test576 True +test577 True +test578 True +test579 True +test580 True +test581 True +test582 True +test583 True +test584 True +test585 True +test586 True +test587 True +test588 True +test589 True +test590 True +test591 True +test592 True +test593 True +test594 True +test595 True +test596 True +test597 True +test598 True +test599 True +test600 True +test601 True +test602 True +test603 True +test604 True +test605 True +test606 True +test607 True +test608 True +test609 True +test610 True +test611 True +test612 True +test613 True +test614 True +test615 True +test616 True +test617 True +test618 True +test619 True +test620 True +test621 True +test622 True +test623 True +test624 True +test625 True +test626 True +test627 True +test628 True +test629 True +test630 True +test631 True +test632 True +test633 True +test634 True +test635 True +test636 True +test637 True +test638 True +test639 True +test640 True +test641 True +test642 True +test643 True +test644 True +test645 True +test646 True +test647 True +test648 True +test649 True +test650 True +test651 True +test652 True +test653 True +test654 True +test655 True +test656 True +test657 True +test658 True +test659 True +test660 True +test661 True +test662 True +test663 True +test664 True +test665 True +test666 True +test667 True +test668 True +test669 True +test670 True +test671 True +test672 True +test673 True +test674 True +test675 True +test676 True +test677 True +test678 True +test679 True +test680 True +test681 True +test682 True +test683 True +test684 True +test685 True +test686 True +test687 True +test688 True +test689 True +test690 True +test691 True +test692 True +test693 True +test694 True +test695 True +test696 True +test697 True +test698 True +test699 True +test700 True +test701 True +test702 True +test703 True +test704 True +test705 True +test706 True +test707 True +test708 True +test709 True +test710 True +test711 True +test712 True +test713 True +test714 True +test715 True +test716 True +test717 True +test718 True +test719 True +test720 True +test721 True +test722 True +test723 True +test724 True +test725 True +test726 True +test727 True +test728 True +test729 True +test730 True +test731 True +test732 True +test733 True +test734 True +test735 True +test736 True +test737 True +test738 True +test739 True +test740 True +test741 True +test742 True +test743 True +test744 True +test745 True +test746 True +test747 True +test748 True +test749 True +test750 True +test751 True +test752 True +test753 True +test754 True +test755 True +test756 True +test757 True +test758 True +test759 True +test760 True +test761 True +test762 True +test763 True +test764 True +test765 True +test766 True +test767 True +test768 True +test769 True +test770 True +test771 True +test772 True +test773 True +test774 True +test775 True +test776 True +test777 True +test778 True +test779 True +test780 True +test781 True +test782 True +test783 True +test784 True +test785 True +test786 True +test787 True +test788 True +test789 True +test790 True +test791 True +test792 True +test793 True +test794 True +test795 True +test796 True +test797 True +test798 True +test799 True +test800 True +test801 True +test802 True +test803 True +test804 True +test805 True +test806 True +test807 True +test808 True +test809 True +test810 True +test811 True +test812 True +test813 True +test814 True +test815 True +test816 True +test817 True +test818 True +test819 True +test820 True +test821 True +test822 True +test823 True +test824 True +test825 True +test826 True +test827 True +test828 True +test829 True +test830 True +test831 True +test832 True +test833 True +test834 True +test835 True +test836 True +test837 True +test838 True +test839 True +test840 True +test841 True +test842 True +test843 True +test844 True +test845 True +test846 True +test847 True +test848 True +test849 True +test850 True +test851 True +test852 True +test853 True +test854 True +test855 True +test856 True +test857 True +test858 True +test859 True +test860 True +test861 True +test862 True +test863 True +test864 True +test865 True +test866 True +test867 True +test868 True +test869 True +test870 True +test871 True +test872 True +test873 True +test874 True +test875 True +test876 True +test877 True +test878 True +test879 True +test880 True +test881 True +test882 True +test883 True +test884 True +test885 True +test886 True +test887 True +test888 True +test889 True +test890 True +test891 True +test892 True +test893 True +test894 True +test895 True +test896 True +test897 True +test898 True +test899 True +test900 True +test901 True +test902 True +test903 True +test904 True +test905 True +test906 True +test907 True +test908 True +test909 True +test910 True +test911 True +test912 True +test913 True +test914 True +test915 True +test916 True +test917 True +test918 True +test919 True +test920 True +test921 True +test922 True +test923 True +test924 True +test925 True +test926 True +test927 True +test928 True +test929 True +test930 True +test931 True +test932 True +test933 True +test934 True +test935 True +test936 True +test937 True +test938 True +test939 True +test940 True +test941 True +test942 True +test943 True +test944 True +test945 True +test946 True +test947 True +test948 True +test949 True +test950 True +test951 True +test952 True +test953 True +test954 True +test955 True +test956 True +test957 True +test958 True +test959 True +test960 True +test961 True +test962 True +test963 True +test964 True +test965 True +test966 True +test967 True +test968 True +test969 True +test970 True +test971 True +test972 True +test973 True +test974 True +test975 True +test976 True +test977 True +test978 True +test979 True +test980 True +test981 True +test982 True +test983 True +test984 True +test985 True +test986 True +test987 True +test988 True +test989 True +test990 True +test991 True +test992 True +test993 True +test994 True +test995 True +test996 True +test997 True +test998 True +test999 True +test1000 True +test1001 True +test1002 True +test1003 True +test1004 True +test1005 True +test1006 True +test1007 True +test1008 True +test1009 True +test1010 True +test1011 True +test1012 True +test1013 True +test1014 True +test1015 True +test1016 True +test1017 True +test1018 True +test1019 True +test1020 True +test1021 True +test1022 True +test1023 True +test1024 True +test1025 True +test1026 True +test1027 True +test1028 True +test1029 True +test1030 True +test1031 True +test1032 True +test1033 True +test1034 True +test1035 True +test1036 True +test1037 True +test1038 True +test1039 True +test1040 True +test1041 True +test1042 True +test1043 True +test1044 True +test1045 True +test1046 True +test1047 True +test1048 True +test1049 True +test1050 True +test1051 True +test1052 True +test1053 True +test1054 True +test1055 True +test1056 True +test1057 True +test1058 True +test1059 True +test1060 True +test1061 True +test1062 True +test1063 True +test1064 True +test1065 True +test1066 True +test1067 True +test1068 True +test1069 True +test1070 True +test1071 True +test1072 True +test1073 True +test1074 True +test1075 True +test1076 True +test1077 True +test1078 True +test1079 True +test1080 True +test1081 True +test1082 True +test1083 True +test1084 True +test1085 True +test1086 True +test1087 True +test1088 True +test1089 True +test1090 True +test1091 True +test1092 True +test1093 True +test1094 True +test1095 True +test1096 True +test1097 True +test1098 True +test1099 True +test1100 True +test1101 True +test1102 True +test1103 True +test1104 True +test1105 True +test1106 True +test1107 True +test1108 True +test1109 True +test1110 True +test1111 True +test1112 True +test1113 True +test1114 True +test1115 True +test1116 True +test1117 True +test1118 True +test1119 True +test1120 True +test1121 True +test1122 True +test1123 True +test1124 True +test1125 True +test1126 True +test1127 True +test1128 True +test1129 True +test1130 True +test1131 True +test1132 True +test1133 True +test1134 True +test1135 True +test1136 True +test1137 True +test1138 True +test1139 True +test1140 True +test1141 True +test1142 True +test1143 True +test1144 True +test1145 True +test1146 True +test1147 True +test1148 True +test1149 True +test1150 True +test1151 True +test1152 True +test1153 True +test1154 True +test1155 True +test1156 True +test1157 True +test1158 True +test1159 True +test1160 True +test1161 True +test1162 True +test1163 True +test1164 True +test1165 True +test1166 True +test1167 True +test1168 True +test1169 True +test1170 True +test1171 True +test1172 True +test1173 True +test1174 True +test1175 True +test1176 True +test1177 True +test1178 True +test1179 True +test1180 True +test1181 True +test1182 True +test1183 True +test1184 True +test1185 True +test1186 True +test1187 True +test1188 True +test1189 True +test1190 True +test1191 True +test1192 True +test1193 True +test1194 True +test1195 True +test1196 True +test1197 True +test1198 True +test1199 True +test1200 True +test1201 True +test1202 True +test1203 True +test1204 True +test1205 True +test1206 True +test1207 True +test1208 True +test1209 True +test1210 True +test1211 True +test1212 True +test1213 True +test1214 True +test1215 True +test1216 True +test1217 True +test1218 True +test1219 True +test1220 True +test1221 True +test1222 True +test1223 True +test1224 True +test1225 True +test1226 True +test1227 True +test1228 True +test1229 True +test1230 True +test1231 True +test1232 True +test1233 True +test1234 True +test1235 True +test1236 True +test1237 True +test1238 True +test1239 True +test1240 True +test1241 True +test1242 True +test1243 True +test1244 True +test1245 True +test1246 True +test1247 True +test1248 True +test1249 True +test1250 True +test1251 True +test1252 True +test1253 True +test1254 True +test1255 True +test1256 True +test1257 True +test1258 True +test1259 True +test1260 True +test1261 True +test1262 True +test1263 True +test1264 True +test1265 True +test1266 True +test1267 True +test1268 True +test1269 True +test1270 True +test1271 True +test1272 True +test1273 True +test1274 True +test1275 True +test1276 True +test1277 True +test1278 True +test1279 True +test1280 True +test1281 True +test1282 True +test1283 True +test1284 True +test1285 True +test1286 True +test1287 True +test1288 True +test1289 True +test1290 True +test1291 True +test1292 True +test1293 True +test1294 True +test1295 True +test1296 True +test1297 True +test1298 True +test1299 True +test1300 True +test1301 True +test1302 True +test1303 True +test1304 True +test1305 True +test1306 True +test1307 True +test1308 True +test1309 True +test1310 True +test1311 True +test1312 True +test1313 True +test1314 True +test1315 True +test1316 True +test1317 True +test1318 True +test1319 True +test1320 True +test1321 True +test1322 True +test1323 True +test1324 True +test1325 True +test1326 True +test1327 True +test1328 True +test1329 True +test1330 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('./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/b1eefe1ef761d5c2a129e71920054cbbd4ae96c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1eefe1ef761d5c2a129e71920054cbbd4ae96c4 You're receiving 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 Sep 28 08:23:23 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 28 Sep 2022 04:23:23 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix Message-ID: <6334047b6de4c_2c975753ffac60476a@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: bf71a062 by Matthew Pickering at 2022-09-28T09:23:16+01:00 fix - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -391,11 +391,10 @@ hadrian-multi: tags: - x86_64-linux script: - - git clean -xdf && git submodule foreach git clean -xdf - root=$(pwd)/ghc - | mkdir tmp - tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + tar -xf ../ghc-x86_64-linux-fedora33-release.tar.xz -C tmp pushd tmp/ghc-*/ ./configure --prefix=$root make install View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf71a062c7d9849a7a489fd67e6dc379878130d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf71a062c7d9849a7a489fd67e6dc379878130d2 You're receiving 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 Sep 28 08:39:04 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 28 Sep 2022 04:39:04 -0400 Subject: [Git][ghc/ghc][wip/T21754] 3 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <63340828a3607_2c9757514506079d7@gitlab.mail> Sebastian Graf pushed to branch wip/T21754 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 3bf718f7 by Sebastian Graf at 2022-09-28T10:38:45+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. - - - - - 30 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/TyThing.hs - compiler/Language/Haskell/Syntax/Decls.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/data_kinds.rst - + docs/users_guide/exts/type_data.rst - docs/users_guide/exts/types.rst - libraries/Cabal - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2e39aade432ec323deb7f0d7f40716ce47a7539...3bf718f71ec57e09e20a93344c8e04ebdc49eb34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f2e39aade432ec323deb7f0d7f40716ce47a7539...3bf718f71ec57e09e20a93344c8e04ebdc49eb34 You're receiving 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 Sep 28 08:44:52 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 04:44:52 -0400 Subject: [Git][ghc/ghc][wip/T21470] 4 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <63340984ad56c_2c97575148c6108f1@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 78789974 by Simon Peyton Jones at 2022-09-28T09:46:52+01: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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - 414931b2 by Simon Peyton Jones at 2022-09-28T09:46:52+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 30 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/TyThing.hs - compiler/Language/Haskell/Syntax/Decls.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/data_kinds.rst - + docs/users_guide/exts/type_data.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eecfacae84930f2dfef082d205c168543512117c...414931b2d48b5268f530b7d385296a7be2ac4e1d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eecfacae84930f2dfef082d205c168543512117c...414931b2d48b5268f530b7d385296a7be2ac4e1d You're receiving 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 Sep 28 09:15:04 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Wed, 28 Sep 2022 05:15:04 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] correctly use fadd primitive instead of + operator Message-ID: <63341098493dc_2c9757514006207c0@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: b5d0c9e8 by Luite Stegeman at 2022-09-28T11:14:08+02:00 correctly use fadd primitive instead of + operator - - - - - 2 changed files: - testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs - testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm Changes: ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs ===================================== @@ -222,11 +222,3 @@ foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #) foreign import prim cmm_array_1 :: Array# Any -> Int# -- return some arrays foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #) - --- (State# RealWorld -> (# State# RealWorld, Any #) --- foreign import prim cmm_array_3 :: MutableArray# -> MutableArray# -> State# RealWorld -> State# RealWorld - --- some examples from base --- foreign import prim cmm_decodeStack :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, Array# (Ptr InfoProvEnt) #) --- foreign import prim cmm_cloneMyStack :: State# RealWorld -> (# State# RealWorld, StackSnapshot# #) --- foreign import prim cmm_sendCloneStackMessage :: ThreadId# -> StablePtr# PrimMVar -> State# RealWorld -> (# State# RealWorld, (# #) #) ===================================== testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm ===================================== @@ -52,8 +52,8 @@ cmm_two2_l(L_ x, L_ y) { return (y); } /* additional tests for floating point, since D_ and F_ registers overlap on some platforms */ -cmm_floating_1(F_ x, F_ y) { return (x+y); } -cmm_floating_2(D_ x, D_ y) { return (x+y); } +cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); } +cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); } cmm_floating_3(F_ x, D_ y) { return (x); } cmm_floating_4(F_ x, D_ y) { return (y); } @@ -63,14 +63,13 @@ cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) { F_ y1; D_ y2; - /* for some reasons we can't do this in one sum? */ - y1 = x1+x3; - y1 = y1+x5; - y1 = y1+x7; + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); - y2 = x2+x4; - y2 = y2+x6; - y2 = y2+x8; + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); return (y1, y2); } @@ -80,14 +79,13 @@ cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) { D_ y1; F_ y2; - /* for some reasons we can't do this in one sum? */ - y1 = x1+x3; - y1 = y1+x5; - y1 = y1+x7; + y1 = %fadd(x1,x3); + y1 = %fadd(y1,x5); + y1 = %fadd(y1,x7); - y2 = x2+x4; - y2 = y2+x6; - y2 = y2+x8; + y2 = %fadd(x2,x4); + y2 = %fadd(y2,x6); + y2 = %fadd(y2,x8); return (y1, y2); } @@ -106,20 +104,19 @@ cmm_floating_7( W_ x1, F_ x2, D_ x3 D_ y3; y1 = x1+x4+x7+x10+x13+x16+x19; - /* for some reasons we can't do this in one sum? */ - y2 = x2+x5; - y2 = y2+x8; - y2 = y2+x11; - y2 = y2+x14; - y2 = y2+x17; - y2 = y2+x20; - - y3 = x3+x6; - y3 = y3+x9; - y3 = y3+x12; - y3 = y3+x15; - y3 = y3+x18; - y3 = y3+x21; + y2 = %fadd(x2,x5); + y2 = %fadd(y2,x8); + y2 = %fadd(y2,x11); + y2 = %fadd(y2,x14); + y2 = %fadd(y2,x17); + y2 = %fadd(y2,x20); + + y3 = %fadd(x3,x6); + y3 = %fadd(y3,x9); + y3 = %fadd(y3,x12); + y3 = %fadd(y3,x15); + y3 = %fadd(y3,x18); + y3 = %fadd(y3,x21); return ( y1, y2, y2 ); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5d0c9e84eb1f6075c61a56d811f6cfad633ba3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5d0c9e84eb1f6075c61a56d811f6cfad633ba3f You're receiving 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 Sep 28 09:43:35 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 28 Sep 2022 05:43:35 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Minor Linker cleanup Message-ID: <6334174743331_2c9757514786258aa@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: d373480b by Sylvain Henry at 2022-09-28T11:41:33+02:00 Minor Linker cleanup - - - - - 1 changed file: - compiler/GHC/StgToJS/Linker/Linker.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -15,16 +15,18 @@ -- Josh Meredith -- Stability : experimental -- --- GHCJS linker, collects dependencies from the object files (.js_o, js_p_o), +-- GHCJS linker, collects dependencies from the object files -- which contain linkable units with dependency information -- ----------------------------------------------------------------------------- -module GHC.StgToJS.Linker.Linker where +module GHC.StgToJS.Linker.Linker + ( link + ) +where import Prelude -import GHC.Platform.Ways import GHC.Platform.Host (hostPlatformArchOS) import GHC.StgToJS.Linker.Types @@ -86,7 +88,7 @@ import System.Directory ( createDirectoryIfMissing , getPermissions ) -import GHC.Driver.Session (targetWays_, DynFlags(..)) +import GHC.Driver.Session (DynFlags(..)) import Language.Haskell.Syntax.Module.Name import GHC.Unit.Module (moduleStableString) import GHC.Utils.Logger (Logger, logVerbAtLeast) @@ -136,7 +138,7 @@ link :: GhcjsEnv link env lc_cfg cfg logger tmpfs dflags unit_env out include pkgs objFiles jsFiles isRootFun extraStaticDeps | lcNoJSExecutables lc_cfg = return () | otherwise = do - link_res <- link' env lc_cfg cfg dflags logger unit_env out include pkgs objFiles jsFiles + link_res <- link' env lc_cfg cfg logger unit_env out include pkgs objFiles jsFiles isRootFun extraStaticDeps let genBase = isJust (lcGenBase lc_cfg) @@ -202,7 +204,6 @@ readShimsArchive ar_file = do link' :: GhcjsEnv -> JSLinkConfig -> StgToJSConfig - -> DynFlags -> Logger -> UnitEnv -> String -- ^ target (for progress message) @@ -213,7 +214,7 @@ link' :: GhcjsEnv -> (ExportedFun -> Bool) -- ^ functions from the objects to use as roots (include all their deps) -> Set ExportedFun -- ^ extra symbols to link in -> IO LinkResult -link' env lc_cfg cfg dflags logger unit_env target _include pkgs objFiles _jsFiles isRootFun extraStaticDeps +link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRootFun extraStaticDeps = do (objDepsMap, objRequiredUnits) <- loadObjDeps objFiles @@ -240,9 +241,8 @@ link' env lc_cfg cfg dflags logger unit_env target _include pkgs objFiles _jsFil -- c <- newMVar M.empty let preload_units = preloadUnits (ue_units unit_env) - let rtsPkgs = map stringToUnitId ["@rts", "@rts_" ++ waysTag (targetWays_ $ dflags)] - pkgs' :: [UnitId] - pkgs' = nub (rtsPkgs ++ preload_units ++ rdPkgs ++ reverse objPkgs ++ reverse pkgs) + let pkgs' :: [UnitId] + pkgs' = nub (preload_units ++ rdPkgs ++ reverse objPkgs ++ reverse pkgs) pkgs'' = filter (not . isAlreadyLinked base) pkgs' ue_state = ue_units $ unit_env -- pkgLibPaths = mkPkgLibPaths pkgs' @@ -690,14 +690,6 @@ rtsDeps pkgs = diffDeps pkgs $ ] ) --- | dependencies for the Template Haskell, these need to be linked when running --- Template Haskell (in addition to the RTS deps) -thDeps :: [UnitId] -> ([UnitId], Set ExportedFun) -thDeps pkgs = diffDeps pkgs $ - ( [ baseUnitId ] - , S.fromList $ mkBaseFuns "GHC.JS.Prim.TH.Eval" ["runTHServer"] - ) - -- | Export the functions in base mkBaseFuns :: FastString -> [FastString] -> [ExportedFun] mkBaseFuns = mkExportedFuns baseUnitId View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d373480b64e571008c1ea2ad08680f32f4d21a11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d373480b64e571008c1ea2ad08680f32f4d21a11 You're receiving 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 Sep 28 10:02:58 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 28 Sep 2022 06:02:58 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix Message-ID: <63341bd2728bb_2c975751450628698@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 6eba312a by Matthew Pickering at 2022-09-28T11:02:51+01:00 fix - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -392,9 +392,10 @@ hadrian-multi: - x86_64-linux script: - root=$(pwd)/ghc + - ls - | mkdir tmp - tar -xf ../ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp pushd tmp/ghc-*/ ./configure --prefix=$root make install View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6eba312abef88f49da7f7d2dd4241e5f6b12ca2c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6eba312abef88f49da7f7d2dd4241e5f6b12ca2c You're receiving 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 Sep 28 10:42:58 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 06:42:58 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] 3 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <633425326700e_2c9757514786386bc@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - c20396fa by Simon Peyton Jones at 2022-09-28T11:45:01+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 quite a bit, but the trend is slightly down Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change ------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 4,566,082,536 -25.0% GOOD T10421(normal) ghc/alloc 111,994,304 116,148,544 +3.7% BAD T10421a(normal) ghc/alloc 79,150,034 83,423,664 +5.4% T10547(normal) ghc/alloc 28,211,501 28,177,960 -0.1% T12545(normal) ghc/alloc 1,633,149,272 1,614,005,512 -1.2% T13253(normal) ghc/alloc 343,592,469 347,635,808 +1.2% T14052(ghci) ghc/alloc 3,681,055,512 3,749,063,688 +1.8% T15304(normal) ghc/alloc 1,295,512,578 1,277,067,608 -1.4% T16577(normal) ghc/alloc 8,050,423,421 8,291,093,504 +3.0% BAD T17516(normal) ghc/alloc 1,800,051,592 1,840,575,008 +2.3% T17836(normal) ghc/alloc 829,913,981 812,805,232 -2.1% T17836b(normal) ghc/alloc 45,437,680 45,057,120 -0.8% T18223(normal) ghc/alloc 734,732,288 646,329,352 -12.0% GOOD T3064(normal) ghc/alloc 180,023,717 182,061,608 +1.1% T9630(normal) ghc/alloc 1,523,682,706 1,492,863,632 -2.0% GOOD T9961(normal) ghc/alloc 358,760,821 368,223,992 +2.6% BAD geo. mean -0.3% minimum -25.0% maximum +5.4% Metric Decrease: LargeRecord T18223 T9630 Metric Increase: T10421 T16577 T9961 - - - - - 30 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/TyThing.hs - compiler/Language/Haskell/Syntax/Decls.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/data_kinds.rst - + docs/users_guide/exts/type_data.rst - docs/users_guide/exts/types.rst - libraries/Cabal - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/driver/T4437.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c434c0a4977637dec45a29755b39c50930fe597d...c20396faef0cc3c18e57c977ac439a00d19e16ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c434c0a4977637dec45a29755b39c50930fe597d...c20396faef0cc3c18e57c977ac439a00d19e16ed You're receiving 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 Sep 28 12:09:24 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 28 Sep 2022 08:09:24 -0400 Subject: [Git][ghc/ghc][wip/andreask/ghci-tag-nullary] 38 commits: Tag inference: Fix #21954 by retaining tagsigs of vars in function position. Message-ID: <63343974aa8cb_2c975753ffac668176@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ghci-tag-nullary at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - fcbed009 by Andreas Klebinger at 2022-09-28T14:07:36+02: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 ------------------------- - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Data/Pair.hs - compiler/GHC/Data/Stream.hs - compiler/GHC/Driver/CmdLine.hs - compiler/GHC/Driver/GenerateCgIPEStub.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2fa23b2f586351d5a488f48caceaa540ccd2b780...fcbed0096daa44071274ac7784f722feed1fb24b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2fa23b2f586351d5a488f48caceaa540ccd2b780...fcbed0096daa44071274ac7784f722feed1fb24b You're receiving 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 Sep 28 12:16:09 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 28 Sep 2022 08:16:09 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] 2 commits: update containers submodule Message-ID: <63343b099109_2c9757514506707e@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: f19d7a98 by Matthew Pickering at 2022-09-28T12:02:01+01:00 update containers submodule - - - - - 0f62bc7c by Matthew Pickering at 2022-09-28T13:15:45+01:00 Fix - - - - - 2 changed files: - .gitlab-ci.yml - libraries/containers Changes: ===================================== .gitlab-ci.yml ===================================== @@ -403,9 +403,12 @@ hadrian-multi: rm -Rf tmp - export BOOT_HC=$(which ghc) - export HC=$root/bin/ghc + # This GHC means, use this GHC to configure with - export GHC=$root/bin/ghc - .gitlab/ci.sh setup - .gitlab/ci.sh configure + # Now GHC means, use this GHC for hadrian + - export GHC=$(which ghc) # Load hadrian-multi then immediately exit and check the modules loaded - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," after_script: ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 5e338df84454b56d649360a57d2c186785aff2b4 +Subproject commit fb8148e40d9f6487fe26340f21ab2ed2935a01ce View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6eba312abef88f49da7f7d2dd4241e5f6b12ca2c...0f62bc7cf7c816a08fe58e96f22bf7ffce2d9aab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6eba312abef88f49da7f7d2dd4241e5f6b12ca2c...0f62bc7cf7c816a08fe58e96f22bf7ffce2d9aab You're receiving 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 Sep 28 12:17:33 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 08:17:33 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) Message-ID: <63343b5ddb48d_2c9757514786732b8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 2b71cfab by Andreas Klebinger at 2022-09-28T08:17:18-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 ------------------------- - - - - - 0db6b616 by sheaf at 2022-09-28T08:17:20-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 - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/TyThing.hs - compiler/GHC/Utils/Misc.hs - compiler/Language/Haskell/Syntax/Decls.hs - compiler/ghc.cabal.in - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/data_kinds.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc3878008b0adf15264386347638421c9b5168ab...0db6b61621319bc5d5329e2217fb009644b86fa5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc3878008b0adf15264386347638421c9b5168ab...0db6b61621319bc5d5329e2217fb009644b86fa5 You're receiving 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 Sep 28 12:25:07 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Wed, 28 Sep 2022 08:25:07 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] mark test ghci/prog014 as not broken anymore Message-ID: <63343d2395d7b_2c9757514506829d6@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 68cd699c by Luite Stegeman at 2022-09-28T14:24:16+02:00 mark test ghci/prog014 as not broken anymore - - - - - 1 changed file: - testsuite/tests/ghci/prog014/prog014.T Changes: ===================================== testsuite/tests/ghci/prog014/prog014.T ===================================== @@ -1,6 +1,5 @@ test('prog014', [extra_files(['Primop.hs', 'dummy.c']), - expect_fail, # bytecode compiler doesn't support foreign import prim extra_run_opts('dummy.o'), pre_cmd('$MAKE -s --no-print-directory prog014')], ghci_script, ['prog014.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68cd699cdbef07f376017bea3555c74f10b74ebe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68cd699cdbef07f376017bea3555c74f10b74ebe You're receiving 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 Sep 28 12:29:02 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 08:29:02 -0400 Subject: [Git][ghc/ghc][wip/T21623] 15 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <63343e0ed3b29_2c97575143c684913@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 8c06730f by Simon Peyton Jones at 2022-09-28T12:26:16+01: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 - - - - - 8184267e by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Revert accidental changes in SameOccInfo fixes mod180, tcfail182 - - - - - 0ce866f2 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare - - - - - 340e11d0 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Wibbles - - - - - e5f2c4bf by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 More wibbles Reaedy for RAE review - - - - - 91d3977a by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] - - - - - 44007e50 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Wibbles - - - - - ea61b140 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 More wibbles - - - - - 5cbd5f61 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Remove unused import - - - - - e8a72c66 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Remove another unused import - - - - - e1f24093 by Simon Peyton Jones at 2022-09-28T12:26:16+01:00 Wibbles - - - - - a9f3f8a2 by Simon Peyton Jones at 2022-09-28T12:29:38+01:00 Update haddock submodule - - - - - d963b075 by Simon Peyton Jones at 2022-09-28T13:28:49+01:00 Respond to Sam's suggestions - - - - - 16 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 - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e25f42f0cd0848e06ad840a6d4037e0d63ed4cd7...d963b07594a79cbf091cd8c080288824e179612d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e25f42f0cd0848e06ad840a6d4037e0d63ed4cd7...d963b07594a79cbf091cd8c080288824e179612d You're receiving 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 Sep 28 12:30:09 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Wed, 28 Sep 2022 08:30:09 -0400 Subject: [Git][ghc/ghc][wip/jsem] 82 commits: DmdAnal: Don't panic in addCaseBndrDmd (#22039) Message-ID: <63343e5187d37_2c97575143c687541@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 514836e2 by sheaf at 2022-09-28T12:12:35+02:00 WIP: jsem, using POSIX/Win32 semaphores - - - - - fe62fb9e by sheaf at 2022-09-28T12:12:35+02:00 remove -jsemcreate: semaphores should be created externally - - - - - db53cc1f by sheaf at 2022-09-28T12:12:35+02:00 jsem: add debouncing - - - - - 822b8317 by Douglas Wilson at 2022-09-28T12:12:35+02:00 Add GHC.Utils.IO.Semaphore - - - - - 0613ddf1 by sheaf at 2022-09-28T12:12:35+02:00 Add more cross-platform semaphore operations - - - - - 925665a4 by sheaf at 2022-09-28T12:44:30+02:00 jsem: add a logger - - - - - 6367d03c by sheaf at 2022-09-28T14:28:42+02:00 WIP: testing framework - - - - - 30 changed files: - − .appveyor.sh - .gitlab-ci.yml - .gitlab/ci.sh - − 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/CLabel.hs - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Dominators.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Sink.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Instr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/504045aeb075a70e5215b380d73e050cab832092...6367d03cc2a45f412bf5f8ae80e3e7669836808b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/504045aeb075a70e5215b380d73e050cab832092...6367d03cc2a45f412bf5f8ae80e3e7669836808b You're receiving 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 Sep 28 12:47:26 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 08:47:26 -0400 Subject: [Git][ghc/ghc][wip/T21286] 5 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <6334425ed158c_2c975751428694364@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 994d75ea by Simon Peyton Jones at 2022-09-28T13:47:28+01: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 - - - - - 6c8fa079 by Simon Peyton Jones at 2022-09-28T13:48:01+01: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. - - - - - 7ecde6e4 by Simon Peyton Jones at 2022-09-28T13:48:01+01: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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8dca5184c925159119aae1d7860a91c3f22656b5...7ecde6e4cebdcd885db71030e058f0409973caea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8dca5184c925159119aae1d7860a91c3f22656b5...7ecde6e4cebdcd885db71030e058f0409973caea You're receiving 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 Sep 28 12:53:31 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 28 Sep 2022 08:53:31 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Minor cleanup Message-ID: <633443cb7ac37_2c97572ed3bc7869541f@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 3e4af077 by Sylvain Henry at 2022-09-28T14:56:19+02:00 Minor cleanup - - - - - 028fb846 by Sylvain Henry at 2022-09-28T14:56:37+02:00 Linker: load all the dependent units transitively - - - - - 2 changed files: - compiler/GHC/StgToJS/Deps.hs - compiler/GHC/StgToJS/Linker/Linker.hs Changes: ===================================== compiler/GHC/StgToJS/Deps.hs ===================================== @@ -40,14 +40,14 @@ import Control.Monad.Trans.Class import Control.Monad.Trans.State data DependencyDataCache = DDC - { ddcModule :: !(IntMap Unit) -- ^ Unique Module -> Object.Package + { ddcModule :: !(IntMap Unit) -- ^ Unique Module -> Unit , ddcId :: !(IntMap Object.ExportedFun) -- ^ Unique Id -> Object.ExportedFun (only to other modules) , ddcOther :: !(Map OtherSymb Object.ExportedFun) } -- | Generate module dependency data -- --- Generate the object's dependy data, taking care that package and module names +-- Generate the object's dependency data, taking care that package and module names -- are only stored once genDependencyData :: HasDebugCallStack ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -216,6 +216,7 @@ link' :: GhcjsEnv -> IO LinkResult link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRootFun extraStaticDeps = do + let ue_state = ue_units $ unit_env (objDepsMap, objRequiredUnits) <- loadObjDeps objFiles let rootSelector | Just baseMod <- lcGenBase lc_cfg = @@ -236,29 +237,51 @@ link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRo BaseFile _file -> panic "support for base bundle not implemented" -- loadBase file BaseState b -> return b - let (rdPkgs, rds) = rtsDeps pkgs + let (rts_wired_units, rts_wired_functions) = rtsDeps pkgs - -- c <- newMVar M.empty let preload_units = preloadUnits (ue_units unit_env) - let pkgs' :: [UnitId] - pkgs' = nub (preload_units ++ rdPkgs ++ reverse objPkgs ++ reverse pkgs) - pkgs'' = filter (not . isAlreadyLinked base) pkgs' - ue_state = ue_units $ unit_env - -- pkgLibPaths = mkPkgLibPaths pkgs' - -- getPkgLibPaths :: UnitId -> ([FilePath],[String]) - -- getPkgLibPaths k = fromMaybe ([],[]) (lookup k pkgLibPaths) - (archsDepsMap, archsRequiredUnits) <- loadArchiveDeps env =<< getPackageArchives cfg (map snd $ mkPkgLibPaths ue_state pkgs') - pkgArchs <- getPackageArchives cfg (map snd $ mkPkgLibPaths ue_state pkgs'') + -- all the units we want to link together, without their dependencies + let root_units = nub (preload_units ++ rts_wired_units ++ reverse objPkgs ++ reverse pkgs) + + -- all the units we want to link together, including their dependencies + let all_units = transitive_units root_units + + -- compute transitive unit dependencies + transitive_units = reverse . transitive_units_ [] + transitive_units_ xs = \case + [] -> xs + (u:us) + | u == mainUnitId -> transitive_units_ (u:xs) us + | otherwise -> case lookupUnitId ue_state u of + Nothing -> unit_not_found u + Just d -> + let deps = unitDepends d + is_new_dep x = x `notElem` xs + new_deps = filter is_new_dep deps + in case new_deps of + [] -> transitive_units_ (u:xs) us + ds -> transitive_units_ xs (ds ++ (u:us)) + + unit_not_found u = throwGhcException (CmdLineError ("unknown unit: " ++ unpackFS (unitIdFS u))) + + let + -- units that weren't already linked in the base bundle + -- (or all of them, if no base bundle) + bundle_diff = filter (not . is_in_bundle) all_units + is_in_bundle uid = uid `elem` basePkgs base + + (archsDepsMap, archsRequiredUnits) <- loadArchiveDeps env =<< getPackageArchives cfg (map snd $ mkPkgLibPaths ue_state all_units) + pkgArchs <- getPackageArchives cfg (map snd $ mkPkgLibPaths ue_state bundle_diff) when (logVerbAtLeast logger 2) $ logInfo logger $ hang (text "Linking with archives:") 2 (vcat (fmap text pkgArchs)) -- compute dependencies - let dep_units = pkgs' ++ [homeUnitId (ue_unsafeHomeUnit $ unit_env)] + let dep_units = all_units ++ [homeUnitId (ue_unsafeHomeUnit $ unit_env)] dep_map = objDepsMap `M.union` archsDepsMap excluded_units = baseUnits base -- already linked units - dep_fun_roots = roots `S.union` rds `S.union` extraStaticDeps + dep_fun_roots = roots `S.union` rts_wired_functions `S.union` extraStaticDeps dep_unit_roots = archsRequiredUnits ++ objRequiredUnits all_deps <- getDeps (fmap fst dep_map) excluded_units dep_fun_roots dep_unit_roots @@ -270,8 +293,8 @@ link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRo -- retrieve code for dependencies code <- collectDeps dep_map dep_units all_deps - (outJs, metaSize, compactorState, stats) <- renderLinker lc_cfg cfg (baseCompactorState base) rds code - let base' = Base compactorState (nub $ basePkgs base ++ pkgs'') + (outJs, metaSize, compactorState, stats) <- renderLinker lc_cfg cfg (baseCompactorState base) rts_wired_functions code + let base' = Base compactorState (nub $ basePkgs base ++ bundle_diff) (all_deps `S.union` baseUnits base) return $ LinkResult @@ -285,8 +308,6 @@ link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRo , linkBase = base' } where - isAlreadyLinked :: Base -> UnitId -> Bool - isAlreadyLinked b uid = uid `elem` basePkgs b mkPkgLibPaths :: UnitState -> [UnitId] -> [(UnitId, ([FilePath],[String]))] mkPkgLibPaths u_st @@ -613,8 +634,7 @@ readArObject ar_state mod ar_file = do go_entries entries --- | A helper function to read system dependencies that are hardcoded via a file --- path. +-- | A helper function to read system dependencies that are hardcoded diffDeps :: [UnitId] -- ^ Packages that are already Linked -> ([UnitId], Set ExportedFun) -- ^ New units and functions to link @@ -715,13 +735,6 @@ mkJsSymbol mod s = mkFastString $ mconcat , zString (zEncodeFS s) ] -{- | read a static dependencies specification and give the roots - - if dependencies come from a versioned (non-hardwired) package - that is linked multiple times, then the returned dependencies - will all come from the same version, but it's undefined which one. - -} - -- | read all dependency data from the to-be-linked files loadObjDeps :: [LinkedObj] -- ^ object files to link -> IO (Map Module (Deps, DepsLocation), [LinkableUnit]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d373480b64e571008c1ea2ad08680f32f4d21a11...028fb846a33c96a1d4880d52cc7f2f8892a5006a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d373480b64e571008c1ea2ad08680f32f4d21a11...028fb846a33c96a1d4880d52cc7f2f8892a5006a You're receiving 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 Sep 28 12:53:35 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 08:53:35 -0400 Subject: [Git][ghc/ghc][wip/T21470] Wibble Message-ID: <633443cfb1cd0_2c975751428695619@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: f7a033ac by Simon Peyton Jones at 2022-09-28T13:54:57+01:00 Wibble Fix Specialiser for dead binders (todo: merge with previous commit) - - - - - 1 changed file: - compiler/GHC/Core/Opt/Specialise.hs Changes: ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -2458,6 +2458,7 @@ specHeader env (bndr : bndrs) (UnspecType : args) -- a wildcard binder to match the dictionary (See Note [Specialising Calls] for -- the nitty-gritty), as a LHS rule and unfolding details. specHeader env (bndr : bndrs) (SpecDict d : args) + | not (isDeadBinder bndr) = do { (env1, bndr') <- newDictBndr env bndr -- See Note [Zap occ info in rule binders] ; let (env2, dx_bind, spec_dict) = bindAuxiliaryDict env1 bndr bndr' d ; (_, env3, leftover_bndrs, rule_bs, rule_es, bs', dx, spec_args) @@ -2474,15 +2475,18 @@ specHeader env (bndr : bndrs) (SpecDict d : args) ) } --- Finally, we have the unspecialised argument 'i'. We need to produce --- a binder, LHS and RHS argument for the RULE, and a binder for the --- specialised body. +-- Finally, we don't want to specialise on this argument 'i': +-- - It's an UnSpecArg, or +-- - It's a dead dictionary +-- We need to produce a binder, LHS and RHS argument for the RULE, and +-- a binder for the specialised body. -- -- NB: Calls to 'specHeader' will trim off any trailing 'UnspecArg's, which is -- why 'i' doesn't appear in our RULE above. But we have no guarantee that -- there aren't 'UnspecArg's which come /before/ all of the dictionaries, so -- this case must be here. -specHeader env (bndr : bndrs) (UnspecArg : args) +specHeader env (bndr : bndrs) (_ : args) + -- The "_" can be UnSpecArg, or SpecDict where the bndr is dead = do { -- see Note [Zap occ info in rule binders] let (env', bndr') = substBndr env (zapIdOccInfo bndr) ; (useful, env'', leftover_bndrs, rule_bs, rule_es, bs', dx, spec_args) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7a033ac30301c942594c59e8ad5f03a3e2ecd3e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7a033ac30301c942594c59e8ad5f03a3e2ecd3e You're receiving 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 Sep 28 13:14:32 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 28 Sep 2022 09:14:32 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/ghci-tags-94 Message-ID: <633448b8886a2_2c97575146470231a@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/ghci-tags-94 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/ghci-tags-94 You're receiving 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 Sep 28 13:43:48 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 28 Sep 2022 09:43:48 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: JS.Arg: docs and cleanup Message-ID: <63344f943020a_2c975751414717287@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 5340102e by doyougnu at 2022-09-28T09:43:09-04:00 JS.Arg: docs and cleanup - - - - - 0332c416 by doyougnu at 2022-09-28T09:43:09-04:00 StgToJS.Arg: add minimal docs - - - - - 720646df by doyougnu at 2022-09-28T09:43:09-04:00 StgToJS.Ids: Add header - - - - - 2 changed files: - compiler/GHC/StgToJS/Arg.hs - compiler/GHC/StgToJS/Ids.hs Changes: ===================================== compiler/GHC/StgToJS/Arg.hs ===================================== @@ -1,6 +1,20 @@ {-# LANGUAGE LambdaCase #-} --- | Code generation of application arguments +----------------------------------------------------------------------------- +-- | +-- Module : GHC.StgToJS.Args +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Code generation of application arguments +----------------------------------------------------------------------------- + module GHC.StgToJS.Arg ( genArg , genIdArg @@ -94,6 +108,7 @@ JavaScript runtime. -} +-- | Generate JS code for static arguments genStaticArg :: HasDebugCallStack => StgArg -> G [StaticArg] genStaticArg a = case a of StgLitArg l -> map StaticLitArg <$> genStaticLit l @@ -161,9 +176,11 @@ genArg a = case a of return [allocDynamicE inl_alloc e as Nothing] x -> pprPanic "genArg: unexpected unfloated expression" (pprStgExpr panicStgPprOpts x) +-- | Generate a Var as JExpr genIdArg :: HasDebugCallStack => Id -> G [JExpr] genIdArg i = genArg (StgVarArg i) +-- | Generate an Id as an Ident genIdArgI :: HasDebugCallStack => Id -> G [Ident] genIdArgI i | isVoid r = return [] @@ -172,14 +189,14 @@ genIdArgI i where r = uTypeVt . idType $ i - +-- | Generate IDs for stack arguments. See 'StgToJS.Expr.loadRetArgs' for use case genIdStackArgI :: HasDebugCallStack => Id -> G [(Ident,StackSlot)] genIdStackArgI i = zipWith f [1..] <$> genIdArgI i where f :: Int -> Ident -> (Ident,StackSlot) f n ident = (ident, SlotId i n) - +-- | Allocate Static Constructors allocConStatic :: HasDebugCallStack => Ident -> CostCentreStack -> DataCon -> [StgArg] -> G () allocConStatic (TxtI to) cc con args = do as <- mapM genStaticArg args @@ -217,6 +234,7 @@ allocConStatic (TxtI to) cc con args = do (TxtI e) <- identForDataConWorker con emitStatic to (StaticData e xs) cc' +-- | Allocate unboxed constructors allocUnboxedConStatic :: DataCon -> [StaticArg] -> StaticArg allocUnboxedConStatic con = \case [] @@ -229,6 +247,7 @@ allocUnboxedConStatic con = \case _ -> pprPanic "allocUnboxedConStatic: not an unboxed constructor" (ppr con) +-- | Allocate Static list allocateStaticList :: [StgArg] -> StgArg -> G StaticVal allocateStaticList xs a@(StgVarArg i) | isDataConId_maybe i == Just nilDataCon = listAlloc xs Nothing ===================================== compiler/GHC/StgToJS/Ids.hs ===================================== @@ -1,4 +1,18 @@ --- | Deals with JS identifiers +----------------------------------------------------------------------------- +-- | +-- Module : GHC.StgToJS.Ids +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Module to deal with JS identifiers +----------------------------------------------------------------------------- + module GHC.StgToJS.Ids ( freshUnique , freshIdent View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/028fb846a33c96a1d4880d52cc7f2f8892a5006a...720646df58af0b44787fa32efda584d3d2b279bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/028fb846a33c96a1d4880d52cc7f2f8892a5006a...720646df58af0b44787fa32efda584d3d2b279bb You're receiving 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 Sep 28 14:03:06 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 28 Sep 2022 10:03:06 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Implement h$sleep (T5611) Message-ID: <6334541ace3dc_2c975751478719559@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: d1002769 by Sylvain Henry at 2022-09-28T16:06:19+02:00 Implement h$sleep (T5611) - - - - - 1 changed file: - rts/js/thread.js Changes: ===================================== rts/js/thread.js ===================================== @@ -185,8 +185,16 @@ function h$wakeupDelayed(now) { } function h$delayThread(time) { - var now = Date.now(); var ms = time/1000; // we have no microseconds in JS + return h$delayThreadMs(ms); +} + +function h$sleep(secs) { + return h$delayThreadMs(secs*1000); +} + +function h$delayThreadMs(ms) { + var now = Date.now(); TRACE_SCHEDULER("delaying " + h$threadString(h$currentThread) + " " + ms + "ms (" + (now+ms) + ")"); h$delayed.add(now+ms, h$currentThread); h$currentThread.delayed = true; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1002769b3dfa7c1757684f15212e7fa4849c31f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d1002769b3dfa7c1757684f15212e7fa4849c31f You're receiving 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 Sep 28 14:07:52 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 10:07:52 -0400 Subject: [Git][ghc/ghc][wip/T21623] Wibbles Message-ID: <6334553823565_2c9757514147197df@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: d594e3aa by Simon Peyton Jones at 2022-09-28T15:09:43+01:00 Wibbles - - - - - 1 changed file: - compiler/GHC/Core/Opt/ConstantFold.hs Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -46,7 +46,7 @@ import GHC.Core import GHC.Core.Make import GHC.Core.SimpleOpt ( exprIsConApp_maybe, exprIsLiteral_maybe ) import GHC.Core.DataCon ( DataCon,dataConTagZ, dataConTyCon, dataConWrapId, dataConWorkId ) -import GHC.Core.Utils ( cheapEqExpr, exprIsHNF, exprType +import GHC.Core.Utils ( cheapEqExpr, exprIsHNF , stripTicksTop, stripTicksTopT, mkTicks ) import GHC.Core.Multiplicity import GHC.Core.Rules.Config @@ -1000,7 +1000,6 @@ retLit l = do platform <- getPlatform retLitNoC :: (Platform -> Literal) -> RuleM CoreExpr retLitNoC l = do platform <- getPlatform let lit = l platform - let ty = literalType lit return $ mkCoreUnboxedTuple [Lit lit, Lit (zeroi platform)] word8Op2 @@ -1116,11 +1115,10 @@ doubleDecodeOp env (LitDouble ((decodeFloat . fromRational @Double) -> (m, e))) , mkIntVal platform (toInteger e) ] where platform = roPlatform env - (iNT64Ty, mkLitINT64) - | platformWordSizeInBits platform < 64 - = (int64PrimTy, mkLitInt64Wrap) - | otherwise - = (intPrimTy , mkLitIntWrap platform) + mkLitINT64 | platformWordSizeInBits platform < 64 + = mkLitInt64Wrap + | otherwise + = mkLitIntWrap platform doubleDecodeOp _ _ = Nothing @@ -1953,7 +1951,7 @@ Implementing seq#. The compiler has magic for SeqOp in seqRule :: RuleM CoreExpr seqRule = do - [Type ty_a, Type _ty_s, a, s] <- getArgs + [Type _ty_a, Type _ty_s, a, s] <- getArgs guard $ exprIsHNF a return $ mkCoreUnboxedTuple [s, a] @@ -2133,12 +2131,12 @@ builtinBignumRules = , divop_one "integerRem" integerRemName rem mkIntegerExpr , divop_one "integerDiv" integerDivName div mkIntegerExpr , divop_one "integerMod" integerModName mod mkIntegerExpr - , divop_both "integerDivMod" integerDivModName divMod mkIntegerExpr integerTy - , divop_both "integerQuotRem" integerQuotRemName quotRem mkIntegerExpr integerTy + , divop_both "integerDivMod" integerDivModName divMod mkIntegerExpr + , divop_both "integerQuotRem" integerQuotRemName quotRem mkIntegerExpr , divop_one "naturalQuot" naturalQuotName quot mkNaturalExpr , divop_one "naturalRem" naturalRemName rem mkNaturalExpr - , divop_both "naturalQuotRem" naturalQuotRemName quotRem mkNaturalExpr naturalTy + , divop_both "naturalQuotRem" naturalQuotRemName quotRem mkNaturalExpr -- conversions from Rational for Float/Double literals , rational_to "rationalToFloat" rationalToFloatName mkFloatExpr @@ -2288,7 +2286,7 @@ builtinBignumRules = platform <- getPlatform pure $ mk_lit platform (n `divop` d) - divop_both str name divop mk_lit ty = mkRule str name 2 $ do + divop_both str name divop mk_lit = mkRule str name 2 $ do [a0,a1] <- getArgs n <- isBignumLiteral a0 d <- isBignumLiteral a1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d594e3aa7cf990e2ca4aecad1afe2c795694905a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d594e3aa7cf990e2ca4aecad1afe2c795694905a You're receiving 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 Sep 28 14:27:04 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 28 Sep 2022 10:27:04 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Linker: don't link the same unit twice Message-ID: <633459b8b0f40_2c97575142872674b@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 04e9cfcd by Sylvain Henry at 2022-09-28T16:30:14+02:00 Linker: don't link the same unit twice - - - - - 1 changed file: - compiler/GHC/StgToJS/Linker/Linker.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -260,7 +260,9 @@ link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRo is_new_dep x = x `notElem` xs new_deps = filter is_new_dep deps in case new_deps of - [] -> transitive_units_ (u:xs) us + [] + | u `elem` xs -> transitive_units_ xs us + | otherwise -> transitive_units_ (u:xs) us ds -> transitive_units_ xs (ds ++ (u:us)) unit_not_found u = throwGhcException (CmdLineError ("unknown unit: " ++ unpackFS (unitIdFS u))) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04e9cfcd1485a8b90ef0987d8ffdaa8efb4fd9e1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04e9cfcd1485a8b90ef0987d8ffdaa8efb4fd9e1 You're receiving 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 Sep 28 14:27:21 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 10:27:21 -0400 Subject: [Git][ghc/ghc][wip/T21623] Wibbles Message-ID: <633459c9d9bfa_2c975753ffac7269fe@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 83c2c74a by Simon Peyton Jones at 2022-09-28T15:29:19+01:00 Wibbles - - - - - 2 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Make.hs Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1934,9 +1934,8 @@ boxingDataCon_maybe :: HasDebugCallStack => Type -> Maybe (DataCon, Type) -- will box it, and the type of the boxed thing, which /does/ now have kind Type. -- -- Nothing => no boxing necessary (already of kind Type) --- or no suitable boxing data constructor is available. -- --- This variant panics if it is given an unlifted type +-- This variant panics if it is given a non-TYPE type -- that it does not know how to box. boxingDataCon_maybe ty | tcIsLiftedTypeKind kind @@ -1956,7 +1955,8 @@ boxingDataConUnlifted_maybe :: HasDebugCallStack => Type -> Maybe (DataCon, Type -- or no suitable boxing data constructor is available. -- -- This variant expects the type to be unlifted, and does not --- fail if there is no suitable DataCon; used in SetLevels +-- fail if there is no suitable DataCon (it returns Nothing instead); +-- used in SetLevels boxingDataConUnlifted_maybe ty | Just box_con <- lookupTypeMap boxingDataConMap kind = Just (box_con, mkTyConApp (dataConTyCon box_con) [ty]) ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -375,8 +375,7 @@ mkCoreBoxedTuple cs (map (Type . exprType) cs ++ cs) --- | Build a small unboxed tuple holding the specified expressions, --- with the given types. The types must be the types of the expressions. +-- | Build a small unboxed tuple holding the specified expressions. -- Do not include the RuntimeRep specifiers; this function calculates them -- for you. -- Does /not/ flatten one-tuples; see Note [Flattening one-tuples] @@ -449,10 +448,10 @@ But see Note [Don't flatten tuples from HsSyn] -} mkBigCoreVarTupSolo :: [Id] -> CoreExpr --- Same as mkBigCoreVarTup, but +-- Same as mkBigCoreVarTup, but: -- - one-tuples are not flattened -- see Note [Flattening one-tuples] --- - arguements should have kind Type +-- - arguments should have kind Type mkBigCoreVarTupSolo [id] = mkCoreBoxedTuple [Var id] mkBigCoreVarTupSolo ids = mkChunkified mkCoreTup (map Var ids) @@ -464,7 +463,9 @@ mkBigCoreVarTup ids = mkBigCoreTup (map Var ids) -- | Build a "big" tuple holding the specified expressions -- One-tuples are flattened; see Note [Flattening one-tuples] --- Arguments don't have to have kind Type +-- Arguments don't have to have kind Type; ones that do not are boxed +-- This function crashes (in boxingDataCon_maybe) if given a non-Type +-- argument that it doesn't know how to box. mkBigCoreTup :: [CoreExpr] -> CoreExpr mkBigCoreTup exprs = mkChunkified mkCoreTup (map wrapBox exprs) @@ -490,6 +491,7 @@ wrapBox :: CoreExpr -> CoreExpr -- which has kind Type -- where K is the boxing data constructor for ki -- See Note [Boxing constructors] in GHC.Builtin.Types +-- Crashes in boxingDataCon_maybe if there /is/ no boxing data con wrapBox e | Just (boxing_con, _) <- boxingDataCon_maybe e_ty = mkCoreConApps boxing_con [Type e_ty, e] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83c2c74a1800e1fb9535413fa18976b84ad6295e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/83c2c74a1800e1fb9535413fa18976b84ad6295e You're receiving 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 Sep 28 14:43:30 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 10:43:30 -0400 Subject: [Git][ghc/ghc][wip/T21286] 3 commits: Improve aggressive specialisation Message-ID: <63345d9251c47_2c97575140073343d@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21286 at Glasgow Haskell Compiler / GHC Commits: c01a1489 by Simon Peyton Jones at 2022-09-28T15:43:31+01: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 - - - - - b2aa6e3d by Simon Peyton Jones at 2022-09-28T15:44:33+01: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. - - - - - 23d8ba95 by Simon Peyton Jones at 2022-09-28T15:44:37+01: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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Make.hs - libraries/base/Foreign/Marshal/Array.hs - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/deSugar/should_compile/T19969.stderr - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/indexed-types/should_compile/T7837.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ecde6e4cebdcd885db71030e058f0409973caea...23d8ba95c0592e234160811cb24ec5f5b7780b4d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ecde6e4cebdcd885db71030e058f0409973caea...23d8ba95c0592e234160811cb24ec5f5b7780b4d You're receiving 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 Sep 28 15:14:32 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 28 Sep 2022 11:14:32 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix Message-ID: <633464d84af60_2c9757514007408b9@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 912c3038 by Matthew Pickering at 2022-09-28T16:14:23+01:00 fix - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -401,14 +401,13 @@ hadrian-multi: make install popd rm -Rf tmp - - export BOOT_HC=$(which ghc) - export HC=$root/bin/ghc # This GHC means, use this GHC to configure with - export GHC=$root/bin/ghc - .gitlab/ci.sh setup - .gitlab/ci.sh configure # Now GHC means, use this GHC for hadrian - - export GHC=$(which ghc) + - unset GHC # Load hadrian-multi then immediately exit and check the modules loaded - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," after_script: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/912c3038690c7bba71cc1a85fa286cbbdabb9624 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/912c3038690c7bba71cc1a85fa286cbbdabb9624 You're receiving 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 Sep 28 17:38:15 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 28 Sep 2022 13:38:15 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Deps/Expr: add docs Message-ID: <633486871d7c0_2c975751464757992@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: fdb7e270 by doyougnu at 2022-09-28T13:38:04-04:00 StgToJS.Deps/Expr: add docs - - - - - 2 changed files: - compiler/GHC/StgToJS/Deps.hs - compiler/GHC/StgToJS/Expr.hs Changes: ===================================== compiler/GHC/StgToJS/Deps.hs ===================================== @@ -1,5 +1,20 @@ {-# LANGUAGE TupleSections #-} +----------------------------------------------------------------------------- +-- | +-- Module : GHC.StgToJS.Deps +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Module to calculate the transitive dependencies of a module +----------------------------------------------------------------------------- + module GHC.StgToJS.Deps ( genDependencyData ) ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -3,6 +3,21 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveFunctor #-} +----------------------------------------------------------------------------- +-- | +-- Module : GHC.StgToJS.Expr +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Code generation of Expressions +----------------------------------------------------------------------------- + module GHC.StgToJS.Expr ( genExpr , genEntryType @@ -246,9 +261,9 @@ genEntryLne ctx i (StgRhsCon cc con _mu _ticks args) = resetSlots $ do emitToplevel (ei ||= toJExpr (JFunc [] (mconcat [DeclStat ii, p, ac, r1 |= toJExpr ii, returnStack]))) --- generate the entry function for a local closure +-- | Generate the entry function for a local closure genEntry :: HasDebugCallStack => ExprCtx -> Id -> CgStgRhs -> G () -genEntry _ _i StgRhsCon {} = return () -- mempty -- error "local data entry" +genEntry _ _i StgRhsCon {} = return () genEntry ctx i rhs@(StgRhsClosure _ext cc {-_bi live-} upd_flag args body) = resetSlots $ do let live = stgLneLiveExpr rhs -- error "fixme" -- probably find live vars in body ll <- loadLiveFun live @@ -272,6 +287,9 @@ genEntry ctx i rhs@(StgRhsClosure _ext cc {-_bi live-} upd_flag args body) = res where entryCtx = ctxSetTarget [] (ctxClearLneFrame ctx) +-- | Generate the entry function types for identifiers. Note that this only +-- returns either 'CIThunk' or 'CIFun'. Everything else (PAP Blackhole etc.) is +-- filtered as not a RuntimeRepKinded type. genEntryType :: HasDebugCallStack => [Id] -> G CIType genEntryType [] = return CIThunk genEntryType args0 = do @@ -280,6 +298,7 @@ genEntryType args0 = do where args = filter (not . isRuntimeRepKindedTy . idType) args0 +-- | Generate the body of an object genBody :: HasDebugCallStack => ExprCtx -> Id @@ -316,7 +335,7 @@ genBody ctx i startReg args e = do return $ la <> lav <> e <> returnStack --- find the result type after applying the function to the arguments +-- | Find the result type after applying the function to the arguments resultSize :: HasDebugCallStack => [Id] -> Type -> [(PrimRep, Int)] resultSize xxs@(_:xs) t -- case: (# x, y, z #) -> r @@ -355,6 +374,8 @@ resultSize [] t where t' = unwrapType t +-- | Ensure that the set of identifiers has valid 'RuntimeRep's. This function +-- returns a no-op when 'csRuntimeAssert' in 'StgToJSConfig' is False. verifyRuntimeReps :: HasDebugCallStack => [Id] -> G JStat verifyRuntimeReps xs = do runtime_assert <- csRuntimeAssert <$> getSettings @@ -379,16 +400,23 @@ verifyRuntimeReps xs = do ver _ _ = mempty v f as = ApplStat (var f) as +-- | Given a set of 'Id's, bind each 'Id' to the appropriate data fields in N +-- registers. This assumes these data fields have already been populated in the +-- registers. For the empty, singleton, and binary case use register 1, for any +-- more use as many registers as necessary. loadLiveFun :: [Id] -> G JStat loadLiveFun l = do l' <- concat <$> mapM identsForId l case l' of [] -> return mempty + -- set the ident to d1 field of register 1 [v] -> return (v ||= r1 .^ closureField1_) + -- set the idents to d1 and d2 fields of register 1 [v1,v2] -> return $ mconcat [ v1 ||= r1 .^ closureField1_ , v2 ||= r1 .^ closureField2_ ] + -- and so on (v:vs) -> do d <- freshIdent let l'' = mconcat . zipWith (loadLiveVar $ toJExpr d) [(1::Int)..] $ vs @@ -401,8 +429,10 @@ loadLiveFun l = do loadLiveVar d n v = let ident = TxtI (dataFieldName n) in DeclStat v `mappend` (toJExpr v |= SelExpr d ident) +-- | Pop a let-no-escape frame off the stack popLneFrame :: Bool -> Int -> ExprCtx -> G JStat popLneFrame inEntry size ctx = do + -- calculate the new stack size let ctx' = ctxLneShrinkStack ctx size let gen_id_slot (i,n) = do @@ -415,6 +445,7 @@ popLneFrame inEntry size ctx = do let skip = if inEntry then 1 else 0 -- pop the frame header popSkipI skip is +-- | Generate an updated given an 'Id' genUpdFrame :: UpdateFlag -> Id -> G JStat genUpdFrame u i | isReEntrant u = pure mempty @@ -461,8 +492,8 @@ genStaticRefs lv getStaticRef :: Id -> G (Maybe FastString) getStaticRef = fmap (fmap itxt . listToMaybe) . identsForId --- reorder the things we need to push to reuse existing stack values as much as possible --- True if already on the stack at that location +-- | Reorder the things we need to push to reuse existing stack values as much +-- as possible True if already on the stack at that location optimizeFree :: HasDebugCallStack => Int -> [Id] -> G [(Id,Int,Bool)] optimizeFree offset ids = do -- this line goes wrong vvvvvvv @@ -483,7 +514,7 @@ optimizeFree offset ids = do allSlots = L.sortBy (compare `on` \(_,_,x,_) -> x) (fixed ++ remaining') return $ map (\(i,n,_,b) -> (i,n,b)) allSlots --- allocate local closures +-- | Allocate local closures allocCls :: Maybe JStat -> [(Id, CgStgRhs)] -> G JStat allocCls dynMiddle xs = do (stat, dyn) <- partitionEithers <$> mapM toCl xs @@ -520,6 +551,8 @@ allocCls dynMiddle xs = do <*> pure cc) -- fixme CgCase has a reps_compatible check here +-- | Consume Stg case statement and generate a case statement. See also +-- 'genAlts' genCase :: HasDebugCallStack => ExprCtx -> Id @@ -624,6 +657,9 @@ genRet ctx e at as l = freshIdent >>= f return $ decs <> load <> loadv <> ras <> rasv <> restoreCCS <> rlne <> rlnev <> alts <> returnStack +-- | Consume an Stg case alternative and generate the corresponding alternative +-- in JS land. If one alternative is a continuation then we must normalize the +-- other alternatives. See 'Branch' and 'normalizeBranches'. genAlts :: HasDebugCallStack => ExprCtx -- ^ lhs to assign expression result to -> Id -- ^ id being matched @@ -712,6 +748,9 @@ genAlts ctx e at me alts = do ver <- verifyMatchRep e at pure (ver <> st, er) +-- | If 'StgToJSConfig.csRuntimeAssert' is set, then generate an assertion that +-- asserts the pattern match is valid, e.g., the match is attempted on a +-- Boolean, a Data Constructor, or some number. verifyMatchRep :: HasDebugCallStack => Id -> AltType -> G JStat verifyMatchRep x alt = do runtime_assert <- csRuntimeAssert <$> getSettings @@ -723,6 +762,8 @@ verifyMatchRep x alt = do pure $ ApplStat (var "h$verify_match_alg") (ValExpr(JStr(mkFastString (renderWithContext defaultSDocContext (ppr tc)))):ix) _ -> pure mempty +-- | A 'Branch' represents a possible branching path of an Stg case statement, +-- i.e., a possible code path from an 'StgAlt' data Branch a = Branch { branch_expr :: a , branch_stat :: JStat @@ -730,8 +771,8 @@ data Branch a = Branch } deriving (Eq,Functor) --- if one branch ends in a continuation but another is inline, --- we need to adjust the inline branch to use the continuation convention +-- | If one branch ends in a continuation but another is inline, we need to +-- adjust the inline branch to use the continuation convention normalizeBranches :: ExprCtx -> [Branch a] -> (ExprResult, [Branch a]) @@ -750,6 +791,9 @@ normalizeBranches ctx brs } _ -> b +-- | Load an unboxed tuple. "Loading" means getting all 'Idents' from the input +-- ID's, declaring them as variables in JS land and binding them, in order, to +-- 'es'. loadUbxTup :: [JExpr] -> [Id] -> Int -> G JStat loadUbxTup es bs _n = do bs' <- concatMapM identsForId bs @@ -759,7 +803,7 @@ mkSw :: [JExpr] -> [Branch (Maybe [JExpr])] -> JStat mkSw [e] cases = mkSwitch e (fmap (fmap (fmap head)) cases) mkSw es cases = mkIfElse es cases --- switch for pattern matching on constructors or prims +-- | Switch for pattern matching on constructors or prims mkSwitch :: JExpr -> [Branch (Maybe JExpr)] -> JStat mkSwitch e cases | [Branch (Just c1) s1 _] <- n @@ -794,6 +838,10 @@ mkIfElse e s = go (L.reverse s) [] -> panic "mkIfElse: empty expression list" _ -> panic "mkIfElse: multiple DEFAULT cases" +-- | Wrapper to contruct sequences of (===), e.g., +-- +-- > mkEq [l0,l1,l2] [r0,r1,r2] = (l0 === r0) && (l1 === r1) && (l2 === r2) +-- mkEq :: [JExpr] -> [JExpr] -> JExpr mkEq es1 es2 | length es1 == length es2 = foldl1 (InfixExpr LAndOp) (zipWith (InfixExpr StrictEqOp) es1 es2) @@ -824,6 +872,7 @@ mkAlgBranch top d alt (ej, er) <- genExpr top (alt_rhs alt) return (Branch cc (b <> ej) er) +-- | Generate a primitive If-expression mkPrimIfBranch :: ExprCtx -> [VarType] -> CgStgAlt @@ -846,8 +895,8 @@ caseCond = \case [e] -> pure (Just e) es -> pprPanic "caseCond: expected single-variable literal" (ppr es) --- load parameters from constructor -- fixme use single tmp var for all branches +-- | Load parameters from constructor loadParams :: JExpr -> [Id] -> G JStat loadParams from args = do as <- concat <$> zipWithM (\a u -> map (,u) <$> identsForId a) args use @@ -872,7 +921,9 @@ loadParams from args = do loadConVarsIfUsed fr cs = mconcat $ zipWith f cs [(1::Int)..] where f (x,u) n = loadIfUsed (SelExpr fr (TxtI (dataFieldName n))) x u --- not a Monoid +-- | Determine if a branch will end in a continuation or not. If not the inline +-- branch must be normalized. See 'normalizeBranches' +-- NB. not a Monoid branchResult :: HasDebugCallStack => [ExprResult] -> ExprResult branchResult = \case [] -> panic "branchResult: empty list" @@ -882,11 +933,14 @@ branchResult = \case | elem ExprCont es -> ExprCont | otherwise -> ExprInline Nothing +-- | Push return arguments onto the stack. The 'Bool' tracks whether the value +-- is already on the stack or not, used in 'StgToJS.Stack.pushOptimized'. pushRetArgs :: HasDebugCallStack => [(Id,Int,Bool)] -> JExpr -> G JStat pushRetArgs free fun = do rs <- mapM (\(i,n,b) -> (\es->(es!!(n-1),b)) <$> genIdArg i) free pushOptimized (rs++[(fun,False)]) +-- | Load the return arguments then pop the stack frame loadRetArgs :: HasDebugCallStack => [(Id,Int,Bool)] -> G JStat loadRetArgs free = do ids <- mapM (\(i,n,_b) -> (!! (n-1)) <$> genIdStackArgI i) free @@ -959,6 +1013,9 @@ allocDynAll haveDecl middle cls = do objs <- makeObjs pure $ mconcat [objs, middle', fillObjs, checkObjs] +-- | Generate a primop. This function wraps around the real generator +-- 'GHC.StgToJS.genPrim', handling the 'ExprCtx' and all arguments before +-- generating the primop. genPrimOp :: ExprCtx -> PrimOp -> [StgArg] -> Type -> G (JStat, ExprResult) genPrimOp ctx op args t = do as <- concatMapM genArg args View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fdb7e270990869bbc663b4531b5b6965ff331e67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fdb7e270990869bbc663b4531b5b6965ff331e67 You're receiving 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 Sep 28 18:00:20 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 28 Sep 2022 14:00:20 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.DataCon: add minor docs Message-ID: <63348bb424812_2c97575146475813e@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: cf829532 by doyougnu at 2022-09-28T14:00:02-04:00 StgToJS.DataCon: add minor docs - - - - - 1 changed file: - compiler/GHC/StgToJS/DataCon.hs Changes: ===================================== compiler/GHC/StgToJS/DataCon.hs ===================================== @@ -1,6 +1,21 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} +----------------------------------------------------------------------------- +-- | +-- Module : GHC.StgToJS.DataCon +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Code generation of data constructors +----------------------------------------------------------------------------- + module GHC.StgToJS.DataCon ( genCon , allocCon @@ -35,6 +50,7 @@ import GHC.Data.FastString import Data.Maybe +-- | Generate a data constructor. Special handling for unboxed tuples genCon :: ExprCtx -> DataCon -> [JExpr] -> G JStat genCon ctx con args | isUnboxedTupleDataCon con @@ -46,6 +62,8 @@ genCon ctx con args | xs <- concatMap typex_expr (ctxTarget ctx) = pprPanic "genCon: unhandled DataCon" (ppr (con, args, xs)) +-- | Allocate a data constructor. Allocate in this context means bind the data +-- constructor to 'to' allocCon :: Ident -> DataCon -> CostCentreStack -> [JExpr] -> G JStat allocCon to con cc xs | isBoolDataCon con || isUnboxableCon con = @@ -60,6 +78,9 @@ allocCon to con cc xs ccsJ <- if prof then ccsVarJ cc else return Nothing return $ allocDynamic cs False to e xs ccsJ +-- | Allocate an unboxed data constructor. If we have a bool we calculate the +-- right value. If not then we expect a singleton list and unbox by converting +-- ''C x' to 'x'. NB. This function may panic. allocUnboxedCon :: DataCon -> [JExpr] -> JExpr allocUnboxedCon con = \case [] @@ -69,6 +90,7 @@ allocUnboxedCon con = \case | isUnboxableCon con -> x xs -> pprPanic "allocUnboxedCon: not an unboxed constructor" (ppr (con,xs)) +-- | Allocate an entry function. See 'GHC.StgToJS.hs' for the object layout. allocDynamicE :: Bool -- ^ csInlineAlloc from StgToJSConfig -> JExpr -> [JExpr] @@ -93,6 +115,7 @@ allocDynamicE inline_alloc entry free cc (x:xs) -> (x,toJExpr (JHash $ listToUniqMap (zip dataFields xs))) dataFields = map (mkFastString . ('d':) . show) [(1::Int)..] +-- | Allocate a dynamic object allocDynamic :: StgToJSConfig -> Bool -> Ident -> JExpr -> [JExpr] -> Maybe JExpr -> JStat allocDynamic s haveDecl to entry free cc = dec to `mappend` (toJExpr to |= allocDynamicE (csInlineAlloc s) entry free cc) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf8295321905a3992a938ff9f504cd662a35fa7d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf8295321905a3992a938ff9f504cd662a35fa7d You're receiving 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 Sep 28 18:07:37 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 28 Sep 2022 14:07:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22231 Message-ID: <63348d6917cee_2c9757514787626a4@gitlab.mail> Sebastian Graf pushed new branch wip/T22231 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22231 You're receiving 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 Sep 28 19:07:48 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 15:07:48 -0400 Subject: [Git][ghc/ghc][master] Apply some tricks to speed up core lint. Message-ID: <63349b842fe4f_2c9757514147751a7@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 ------------------------- - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - + compiler/GHC/Data/Unboxed.hs - compiler/ghc.cabal.in - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -781,7 +781,7 @@ mkTyConAppCo r tc cos mkFunCo r w co1 co2 -- Expand type synonyms - | Just (tv_co_prs, rhs_ty, leftover_cos) <- expandSynTyCon_maybe tc cos + | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos = mkAppCos (liftCoSubst r (mkLiftingContext tv_co_prs) rhs_ty) leftover_cos | Just tys_roles <- traverse isReflCo_maybe cos ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1370,7 +1370,7 @@ normaliseTcApp env role tc tys -- See Note [Normalising types] about the LiftingContext normalise_tc_app :: TyCon -> [Type] -> NormM Reduction normalise_tc_app tc tys - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , not (isFamFreeTyCon tc) -- Expand and try again = -- A synonym with type families in the RHS -- Expand and try again ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -1,6 +1,8 @@ -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 @@ -95,6 +97,8 @@ import Data.List.NonEmpty ( NonEmpty(..), groupWith ) import Data.List ( partition ) import Data.Maybe import GHC.Data.Pair +import GHC.Base (oneShot) +import GHC.Data.Unboxed {- Note [Core Lint guarantee] @@ -263,6 +267,42 @@ case, however, we set le_joins to empty, and catch the error. Similarly, join points can occur free in RHSes of other join points but not the RHSes of value bindings (thunks and functions). +Note [Avoiding compiler perf traps when constructing error messages.] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It's quite common to put error messages into a where clause when it might +be triggered by multiple branches. E.g. + + checkThing x y z = + case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + where + errMsg = text "My error involving:" $$ ppr x <+> ppr y + +However ghc will compile this to: + + checkThink x y z = + let errMsg = text "My error involving:" $$ ppr x <+> ppr y + in case x of + X -> unless (correctX x) $ failWithL errMsg + Y -> unless (correctY y) $ failWithL errMsg + +Putting the allocation of errMsg into the common non-error path. +One way to work around this is to turn errMsg into a function: + + checkThink x y z = + case x of + X -> unless (correctX x) $ failWithL (errMsg x y) + Y -> unless (correctY y) $ failWithL (errMsg x y) + where + errMsg x y = text "My error involving:" $$ ppr x <+> ppr y + +This way `errMsg` is a static function and it being defined in the common +path does not result in allocation in the hot path. This can be surprisingly +impactful. Changing `lint_app` reduced allocations for one test program I was +looking at by ~4%. + + ************************************************************************ * * Beginning and ending passes @@ -1825,7 +1865,7 @@ lintTySynFamApp report_unsat ty tc tys = failWithL (hang (text "Un-saturated type application") 2 (ppr ty)) -- Deal with type synonyms - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc tys , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' = do { -- Kind-check the argument types, but without reporting -- un-saturated type families/synonyms @@ -1874,13 +1914,15 @@ lintArrow what t1 t2 tw -- Eg lintArrow "type or kind `blah'" k1 k2 kw ----------------- lint_ty_app :: Type -> LintedKind -> [LintedType] -> LintM () -lint_ty_app ty k tys - = lint_app (text "type" <+> quotes (ppr ty)) k tys +lint_ty_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "type" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lint_co_app :: Coercion -> LintedKind -> [LintedType] -> LintM () -lint_co_app ty k tys - = lint_app (text "coercion" <+> quotes (ppr ty)) k tys +lint_co_app msg_ty k tys + -- See Note [Avoiding compiler perf traps when constructing error messages.] + = lint_app (\msg_ty -> text "coercion" <+> quotes (ppr msg_ty)) msg_ty k tys ---------------- lintTyLit :: TyLit -> LintM () @@ -1891,46 +1933,62 @@ lintTyLit (NumTyLit n) lintTyLit (StrTyLit _) = return () lintTyLit (CharTyLit _) = return () -lint_app :: SDoc -> LintedKind -> [LintedType] -> LintM () +lint_app :: Outputable msg_thing => (msg_thing -> SDoc) -> msg_thing -> LintedKind -> [LintedType] -> LintM () -- (lint_app d fun_kind arg_tys) -- We have an application (f arg_ty1 .. arg_tyn), -- where f :: fun_kind -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] -lint_app doc kfn arg_tys - = do { in_scope <- getInScope +-- +-- Being strict in the kind here avoids quite a few pointless thunks +-- reducing allocations by ~5% +lint_app mk_msg msg_type !kfn arg_tys + = do { !in_scope <- getInScope -- We need the in_scope set to satisfy the invariant in -- Note [The substitution invariant] in GHC.Core.TyCo.Subst - ; _ <- foldlM (go_app in_scope) kfn arg_tys - ; return () } + -- Forcing the in scope set eagerly here reduces allocations by up to 4%. + ; go_app in_scope kfn arg_tys + } where - fail_msg extra = vcat [ hang (text "Kind application error in") 2 doc - , nest 2 (text "Function kind =" <+> ppr kfn) - , nest 2 (text "Arg types =" <+> ppr arg_tys) - , extra ] - go_app in_scope kfn ta + -- We use explicit recursion instead of a fold here to avoid go_app becoming + -- an allocated function closure. This reduced allocations by up to 7% for some + -- modules. + go_app :: InScopeSet -> LintedKind -> [Type] -> LintM () + go_app !in_scope !kfn ta | Just kfn' <- coreView kfn = go_app in_scope kfn' ta - go_app _ fun_kind@(FunTy _ _ kfa kfb) ta + go_app _in_scope _kind [] = return () + + go_app in_scope fun_kind@(FunTy _ _ kfa kfb) (ta:tas) = do { let ka = typeKind ta ; unless (ka `eqType` kfa) $ - addErrL (fail_msg (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return kfb } + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Fun:" <+> (ppr fun_kind $$ ppr ta <+> dcolon <+> ppr ka))) + ; go_app in_scope kfb tas } - go_app in_scope (ForAllTy (Bndr kv _vis) kfn) ta + go_app in_scope (ForAllTy (Bndr kv _vis) kfn) (ta:tas) = do { let kv_kind = varType kv ka = typeKind ta ; unless (ka `eqType` kv_kind) $ - addErrL (fail_msg (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ + addErrL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Forall:" <+> (ppr kv $$ ppr kv_kind $$ ppr ta <+> dcolon <+> ppr ka))) - ; return $ substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn } + ; let kind' = substTy (extendTCvSubst (mkEmptySubst in_scope) kv ta) kfn + ; go_app in_scope kind' tas } go_app _ kfn ta - = failWithL (fail_msg (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) - + = failWithL (lint_app_fail_msg kfn arg_tys mk_msg msg_type (text "Not a fun:" <+> (ppr kfn $$ ppr ta))) + +-- This is a top level definition to ensure we pass all variables of the error message +-- explicitly and don't capture them as free variables. Otherwise this binder might +-- become a thunk that get's allocated in the hot code path. +-- See Note [Avoiding compiler perf traps when constructing error messages.] +lint_app_fail_msg :: (Outputable a1, Outputable a2) => a1 -> a2 -> (t -> SDoc) -> t -> SDoc -> SDoc +lint_app_fail_msg kfn arg_tys mk_msg msg_type extra = vcat [ hang (text "Kind application error in") 2 (mk_msg msg_type) + , nest 2 (text "Function kind =" <+> ppr kfn) + , nest 2 (text "Arg types =" <+> ppr arg_tys) + , extra ] {- ********************************************************************* * * Linting rules @@ -2672,14 +2730,41 @@ data StaticPtrCheck deriving Eq newtype LintM a = - LintM { unLintM :: + LintM' { unLintM :: LintEnv -> WarnsAndErrs -> -- Warning and error messages so far - (Maybe a, WarnsAndErrs) } -- Result and messages (if any) - deriving (Functor) + LResult a } -- Result and messages (if any) + + +pattern LintM :: (LintEnv -> WarnsAndErrs -> LResult a) -> LintM a +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +pattern LintM m <- LintM' m + where + LintM m = LintM' (oneShot $ \env -> oneShot $ \we -> m env we) + -- LintM m = LintM' (oneShot $ oneShot m) +{-# COMPLETE LintM #-} + +instance Functor (LintM) where + fmap f (LintM m) = LintM $ \e w -> mapLResult f (m e w) type WarnsAndErrs = (Bag SDoc, Bag SDoc) +-- Using a unboxed tuple here reduced allocations for a lint heavy +-- file by ~6%. Using MaybeUB reduced them further by another ~12%. +type LResult a = (# MaybeUB a, WarnsAndErrs #) + +pattern LResult :: MaybeUB a -> WarnsAndErrs -> LResult a +pattern LResult m w = (# m, w #) +{-# COMPLETE LResult #-} + +mapLResult :: (a1 -> a2) -> LResult a1 -> LResult a2 +mapLResult f (LResult r w) = LResult (fmapMaybeUB f r) w + +-- Just for testing. +fromBoxedLResult :: (Maybe a, WarnsAndErrs) -> LResult a +fromBoxedLResult (Just x, errs) = LResult (JustUB x) errs +fromBoxedLResult (Nothing,errs) = LResult NothingUB errs + {- Note [Checking for global Ids] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before CoreTidy, all locally-bound Ids must be LocalIds, even @@ -2804,21 +2889,27 @@ Wrinkle 2: 'hasNoBinding' and laziness -} instance Applicative LintM where - pure x = LintM $ \ _ errs -> (Just x, errs) + pure x = LintM $ \ _ errs -> LResult (JustUB x) errs + --(Just x, errs) (<*>) = ap instance Monad LintM where m >>= k = LintM (\ env errs -> - let (res, errs') = unLintM m env errs in + let res = unLintM m env errs in case res of - Just r -> unLintM (k r) env errs' - Nothing -> (Nothing, errs')) + LResult (JustUB r) errs' -> unLintM (k r) env errs' + LResult NothingUB errs' -> LResult NothingUB errs' + ) + -- LError errs'-> LError errs') + -- let (res, errs') = unLintM m env errs in + -- Just r -> unLintM (k r) env errs' + -- Nothing -> (Nothing, errs')) instance MonadFail LintM where fail err = failWithL (text err) getPlatform :: LintM Platform -getPlatform = LintM (\ e errs -> (Just (le_platform e), errs)) +getPlatform = LintM (\ e errs -> (LResult (JustUB $ le_platform e) errs)) data LintLocInfo = RhsOf Id -- The variable bound @@ -2851,9 +2942,9 @@ initL :: LintConfig -> WarnsAndErrs initL cfg m = case unLintM m env (emptyBag, emptyBag) of - (Just _, errs) -> errs - (Nothing, errs@(_, e)) | not (isEmptyBag e) -> errs - | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ + LResult (JustUB _) errs -> errs + LResult NothingUB errs@(_, e) | not (isEmptyBag e) -> errs + | otherwise -> pprPanic ("Bug in Lint: a failure occurred " ++ "without reporting an error message") empty where (tcvs, ids) = partition isTyCoVar $ l_vars cfg @@ -2882,7 +2973,7 @@ noFixedRuntimeRepChecks thing_inside in unLintM thing_inside env' errs getLintFlags :: LintM LintFlags -getLintFlags = LintM $ \ env errs -> (Just (le_flags env), errs) +getLintFlags = LintM $ \ env errs -> fromBoxedLResult (Just (le_flags env), errs) checkL :: Bool -> SDoc -> LintM () checkL True _ = return () @@ -2898,15 +2989,15 @@ checkWarnL False msg = addWarnL msg failWithL :: SDoc -> LintM a failWithL msg = LintM $ \ env (warns,errs) -> - (Nothing, (warns, addMsg True env errs msg)) + fromBoxedLResult (Nothing, (warns, addMsg True env errs msg)) addErrL :: SDoc -> LintM () addErrL msg = LintM $ \ env (warns,errs) -> - (Just (), (warns, addMsg True env errs msg)) + fromBoxedLResult (Just (), (warns, addMsg True env errs msg)) addWarnL :: SDoc -> LintM () addWarnL msg = LintM $ \ env (warns,errs) -> - (Just (), (addMsg False env warns msg, errs)) + fromBoxedLResult (Just (), (addMsg False env warns msg, errs)) addMsg :: Bool -> LintEnv -> Bag SDoc -> SDoc -> Bag SDoc addMsg is_error env msgs msg @@ -2938,7 +3029,7 @@ addLoc extra_loc m unLintM m (env { le_loc = extra_loc : le_loc env }) errs inCasePat :: LintM Bool -- A slight hack; see the unique call site -inCasePat = LintM $ \ env errs -> (Just (is_case_pat env), errs) +inCasePat = LintM $ \ env errs -> fromBoxedLResult (Just (is_case_pat env), errs) where is_case_pat (LE { le_loc = CasePat {} : _ }) = True is_case_pat _other = False @@ -2954,7 +3045,7 @@ addInScopeId id linted_ty m | otherwise = delVarSet join_set id -- Remove any existing binding getInScopeIds :: LintM (VarEnv (Id,LintedType)) -getInScopeIds = LintM (\env errs -> (Just (le_ids env), errs)) +getInScopeIds = LintM (\env errs -> fromBoxedLResult (Just (le_ids env), errs)) extendTvSubstL :: TyVar -> Type -> LintM a -> LintM a extendTvSubstL tv ty m @@ -2974,16 +3065,16 @@ markAllJoinsBadIf True m = markAllJoinsBad m markAllJoinsBadIf False m = m getValidJoins :: LintM IdSet -getValidJoins = LintM (\ env errs -> (Just (le_joins env), errs)) +getValidJoins = LintM (\ env errs -> fromBoxedLResult (Just (le_joins env), errs)) getSubst :: LintM Subst -getSubst = LintM (\ env errs -> (Just (le_subst env), errs)) +getSubst = LintM (\ env errs -> fromBoxedLResult (Just (le_subst env), errs)) getUEAliases :: LintM (NameEnv UsageEnv) -getUEAliases = LintM (\ env errs -> (Just (le_ue_aliases env), errs)) +getUEAliases = LintM (\ env errs -> fromBoxedLResult (Just (le_ue_aliases env), errs)) getInScope :: LintM InScopeSet -getInScope = LintM (\ env errs -> (Just (getSubstInScope $ le_subst env), errs)) +getInScope = LintM (\ env errs -> fromBoxedLResult (Just (getSubstInScope $ le_subst env), errs)) lookupIdInScope :: Id -> LintM (Id, LintedType) lookupIdInScope id_occ ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -108,6 +108,7 @@ module GHC.Core.TyCon( mkTyConTagMap, -- ** Manipulating TyCons + ExpandSynResult(..), expandSynTyCon_maybe, newTyConCo, newTyConCo_maybe, pprPromotionQuote, mkTyConKind, @@ -2521,12 +2522,14 @@ isConcreteTyConFlavour = \case ----------------------------------------------- -} +data ExpandSynResult tyco + = NoExpansion + | ExpandsSyn [(TyVar,tyco)] Type [tyco] + expandSynTyCon_maybe :: TyCon -> [tyco] -- ^ Arguments to 'TyCon' - -> Maybe ([(TyVar,tyco)], - Type, - [tyco]) -- ^ Returns a 'TyVar' substitution, the body + -> ExpandSynResult tyco -- ^ Returns a 'TyVar' substitution, the body -- type of the synonym (not yet substituted) -- and any arguments remaining from the -- application @@ -2536,13 +2539,13 @@ expandSynTyCon_maybe expandSynTyCon_maybe tc tys | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc = if arity == 0 - then Just ([], rhs, tys) -- Avoid a bit of work in the case of nullary synonyms + then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of - GT -> Just (tvs `zip` tys, rhs, drop arity tys) - EQ -> Just (tvs `zip` tys, rhs, []) - LT -> Nothing + GT -> ExpandsSyn (tvs `zip` tys) rhs (drop arity tys) + EQ -> ExpandsSyn (tvs `zip` tys) rhs [] + LT -> NoExpansion | otherwise - = Nothing + = NoExpansion ---------------- ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -4,6 +4,7 @@ -- Type - public interface {-# LANGUAGE FlexibleContexts, PatternSynonyms, ViewPatterns #-} +{-# LANGUAGE MagicHash #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} @@ -294,10 +295,10 @@ import GHC.Data.Pair import GHC.Data.List.SetOps import GHC.Types.Unique ( nonDetCmpUnique ) +import GHC.Base (reallyUnsafePtrEquality#) import GHC.Data.Maybe ( orElse, expectJust, isJust ) import Control.Monad ( guard ) import qualified Data.Semigroup as S --- import GHC.Utils.Trace -- $type_classification -- #type_classification# @@ -556,7 +557,7 @@ expandTypeSynonyms ty in_scope = mkInScopeSet (tyCoVarsOfType ty) go subst (TyConApp tc tys) - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc expanded_tys + | ExpandsSyn tenv rhs tys' <- expandSynTyCon_maybe tc expanded_tys = let subst' = mkTvSubst in_scope (mkVarEnv tenv) -- Make a fresh substitution; rhs has nothing to -- do with anything that has happened so far @@ -2787,6 +2788,16 @@ comparing type variables is nondeterministic, note the call to nonDetCmpVar in nonDetCmpTypeX. See Note [Unique Determinism] for more details. +Note [Type comparisons using object pointer comparisons] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Quite often we substitute the type from a definition site into +occurances without a change. This means for code like: + \x -> (x,x,x) +The type of every `x` will often be represented by a single object +in the heap. We can take advantage of this by shortcutting the equality +check if two types are represented by the same pointer under the hood. +In some cases this reduces compiler allocations by ~2%. + Note [Computing equality on types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are several places within GHC that depend on the precise choice of @@ -2800,11 +2811,15 @@ See also Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. -} nonDetCmpType :: Type -> Type -> Ordering +nonDetCmpType !t1 !t2 + -- See Note [Type comparisons using object pointer comparisons] + | 1# <- reallyUnsafePtrEquality# t1 t2 + = EQ nonDetCmpType (TyConApp tc1 []) (TyConApp tc2 []) | tc1 == tc2 = EQ -nonDetCmpType t1 t2 +nonDetCmpType t1 t2 = -- we know k1 and k2 have the same kind, because they both have kind *. - = nonDetCmpTypeX rn_env t1 t2 + nonDetCmpTypeX rn_env t1 t2 where rn_env = mkRnEnv2 (mkInScopeSet (tyCoVarsOfTypes [t1, t2])) {-# INLINE nonDetCmpType #-} ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -0,0 +1,50 @@ +-- Unboxed counterparts to data structures + +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE UnliftedNewtypes #-} + +module GHC.Data.Unboxed ( + MaybeUB(JustUB, NothingUB), + fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB + ) where + +import GHC.Prelude hiding (Maybe(..), Either(..)) + +-- | Like Maybe, but using unboxed sums. +-- +-- Use with care. Using a unboxed maybe is not always a win +-- in execution *time* even when allocations go down. So make +-- sure to benchmark for execution time as well. If the difference +-- in *runtime* for the compiler is too small to measure it's likely +-- better to use a regular Maybe instead. +-- +-- This is since it causes more function arguments to be passed, and +-- potentially more variables to be captured by closures increasing +-- closure size. +newtype MaybeUB a = MaybeUB (# (# #) | a #) + +pattern JustUB :: a -> MaybeUB a +pattern JustUB x = MaybeUB (# | x #) + +pattern NothingUB :: MaybeUB a +pattern NothingUB = MaybeUB (# (# #) | #) + +{-# COMPLETE NothingUB, JustUB #-} + +fromMaybeUB :: a -> MaybeUB a -> a +fromMaybeUB d NothingUB = d +fromMaybeUB _ (JustUB x) = x + +apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b +apMaybeUB (JustUB f) (JustUB x) = JustUB (f x) +apMaybeUB _ _ = NothingUB + +fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b +fmapMaybeUB _f NothingUB = NothingUB +fmapMaybeUB f (JustUB x) = JustUB $ f x + +maybeUB :: b -> (a -> b) -> MaybeUB a -> b +maybeUB _def f (JustUB x) = f x +maybeUB def _f NothingUB = def ===================================== compiler/ghc.cabal.in ===================================== @@ -387,6 +387,7 @@ Library GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap + GHC.Data.Unboxed GHC.Data.UnionFind GHC.Driver.Backend GHC.Driver.Backend.Internal ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.CmdLine ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -96,6 +96,7 @@ GHC.Data.Stream GHC.Data.Strict GHC.Data.StringBuffer GHC.Data.TrieMap +GHC.Data.Unboxed GHC.Driver.Backend GHC.Driver.Backend.Internal GHC.Driver.Backpack.Syntax View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2d73cb47562a86da76dae217d15f0dbd2b05b0e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2d73cb47562a86da76dae217d15f0dbd2b05b0e You're receiving 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 Sep 28 19:08:33 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 15:08:33 -0400 Subject: [Git][ghc/ghc][master] matchLocalInst: do domination analysis Message-ID: <63349bb15e2e1_2c9757514787825fe@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 13 changed files: - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Utils/Misc.hs - docs/users_guide/9.6.1-notes.rst - + testsuite/tests/quantified-constraints/T22216a.hs - + testsuite/tests/quantified-constraints/T22216b.hs - + testsuite/tests/quantified-constraints/T22216c.hs - + testsuite/tests/quantified-constraints/T22216d.hs - + testsuite/tests/quantified-constraints/T22216e.hs - + testsuite/tests/quantified-constraints/T22223.hs - testsuite/tests/quantified-constraints/all.T Changes: ===================================== compiler/GHC/Tc/Solver/InertSet.hs ===================================== @@ -1558,23 +1558,28 @@ matchableGivens loc_w pred_w inerts@(IS { inert_cans = inert_cans }) matchable_given :: Ct -> Bool matchable_given ct | CtGiven { ctev_loc = loc_g, ctev_pred = pred_g } <- ctEvidence ct - = mightEqualLater inerts pred_g loc_g pred_w loc_w + = isJust $ mightEqualLater inerts pred_g loc_g pred_w loc_w | otherwise = False -mightEqualLater :: InertSet -> TcPredType -> CtLoc -> TcPredType -> CtLoc -> Bool +mightEqualLater :: InertSet -> TcPredType -> CtLoc -> TcPredType -> CtLoc -> Maybe Subst -- See Note [What might equal later?] -- Used to implement logic in Note [Instance and Given overlap] in GHC.Tc.Solver.Interact mightEqualLater inert_set given_pred given_loc wanted_pred wanted_loc | prohibitedSuperClassSolve given_loc wanted_loc - = False + = Nothing | otherwise = case tcUnifyTysFG bind_fun [flattened_given] [flattened_wanted] of - SurelyApart -> False -- types that are surely apart do not equal later - MaybeApart MARInfinite _ -> False -- see Example 7 in the Note. - _ -> True + Unifiable subst + -> Just subst + MaybeApart reason subst + | MARInfinite <- reason -- see Example 7 in the Note. + -> Nothing + | otherwise + -> Just subst + SurelyApart -> Nothing where in_scope = mkInScopeSet $ tyCoVarsOfTypes [given_pred, wanted_pred] ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Types.Var.Env import qualified Data.Semigroup as S import Control.Monad +import Data.Maybe ( listToMaybe, mapMaybe ) import GHC.Data.Pair (Pair(..)) import GHC.Types.Unique( hasKey ) import GHC.Driver.Session @@ -2470,109 +2471,236 @@ matchLocalInst :: TcPredType -> CtLoc -> TcS ClsInstResult matchLocalInst pred loc = do { inerts@(IS { inert_cans = ics }) <- getTcSInerts ; case match_local_inst inerts (inert_insts ics) of - ([], Nothing) -> do { traceTcS "No local instance for" (ppr pred) - ; return NoInstance } - - -- See Note [Use only the best local instance] about - -- superclass depths - (matches, unifs) - | [(dfun_ev, inst_tys)] <- best_matches - , maybe True (> min_sc_depth) unifs - -> do { let dfun_id = ctEvEvId dfun_ev - ; (tys, theta) <- instDFunType dfun_id inst_tys - ; let result = OneInst { cir_new_theta = theta - , cir_mk_ev = evDFunApp dfun_id tys - , cir_what = LocalInstance } - ; traceTcS "Best local inst found:" (ppr result) - ; traceTcS "All local insts:" (ppr matches) - ; return result } - - | otherwise - -> do { traceTcS "Multiple local instances for" (ppr pred) - ; return NotSure } - - where - extract_depth = sc_depth . ctEvLoc . fst - min_sc_depth = minimum (map extract_depth matches) - best_matches = filter ((== min_sc_depth) . extract_depth) matches } + { ([], []) -> do { traceTcS "No local instance for" (ppr pred) + ; return NoInstance } + ; (matches, unifs) -> + do { matches <- mapM mk_instDFun matches + ; unifs <- mapM mk_instDFun unifs + -- See Note [Use only the best matching quantified constraint] + ; case dominatingMatch matches of + { Just (dfun_id, tys, theta) + | all ((theta `impliedBySCs`) . thdOf3) unifs + -> + do { let result = OneInst { cir_new_theta = theta + , cir_mk_ev = evDFunApp dfun_id tys + , cir_what = LocalInstance } + ; traceTcS "Best local instance found:" $ + vcat [ text "pred:" <+> ppr pred + , text "result:" <+> ppr result + , text "matches:" <+> ppr matches + , text "unifs:" <+> ppr unifs ] + ; return result } + + ; mb_best -> + do { traceTcS "Multiple local instances; not committing to any" + $ vcat [ text "pred:" <+> ppr pred + , text "matches:" <+> ppr matches + , text "unifs:" <+> ppr unifs + , text "best_match:" <+> ppr mb_best ] + ; return NotSure }}}}} where pred_tv_set = tyCoVarsOfType pred - sc_depth :: CtLoc -> Int - sc_depth ctloc = case ctLocOrigin ctloc of - InstSCOrigin depth _ -> depth - OtherSCOrigin depth _ -> depth - _ -> 0 + mk_instDFun :: (CtEvidence, [DFunInstType]) -> TcS InstDFun + mk_instDFun (ev, tys) = + let dfun_id = ctEvEvId ev + in do { (tys, theta) <- instDFunType (ctEvEvId ev) tys + ; return (dfun_id, tys, theta) } - -- See Note [Use only the best local instance] about superclass depths + -- Compute matching and unifying local instances match_local_inst :: InertSet -> [QCInst] -> ( [(CtEvidence, [DFunInstType])] - , Maybe Int ) -- Nothing ==> no unifying local insts - -- Just n ==> unifying local insts, with - -- minimum superclass depth - -- of n + , [(CtEvidence, [DFunInstType])] ) match_local_inst _inerts [] - = ([], Nothing) - match_local_inst inerts (qci@(QCI { qci_tvs = qtvs, qci_pred = qpred - , qci_ev = qev }) - : qcis) + = ([], []) + match_local_inst inerts (qci@(QCI { qci_tvs = qtvs + , qci_pred = qpred + , qci_ev = qev }) + :qcis) | let in_scope = mkInScopeSet (qtv_set `unionVarSet` pred_tv_set) , Just tv_subst <- ruleMatchTyKiX qtv_set (mkRnEnv2 in_scope) emptyTvSubstEnv qpred pred , let match = (qev, map (lookupVarEnv tv_subst) qtvs) - = (match:matches, unif) + = (match:matches, unifs) | otherwise = assertPpr (disjointVarSet qtv_set (tyCoVarsOfType pred)) (ppr qci $$ ppr pred) -- ASSERT: unification relies on the -- quantified variables being fresh - (matches, unif `combine` this_unif) + (matches, this_unif `combine` unifs) where qloc = ctEvLoc qev qtv_set = mkVarSet qtvs + (matches, unifs) = match_local_inst inerts qcis this_unif - | mightEqualLater inerts qpred qloc pred loc = Just (sc_depth qloc) - | otherwise = Nothing - (matches, unif) = match_local_inst inerts qcis + | Just subst <- mightEqualLater inerts qpred qloc pred loc + = Just (qev, map (lookupTyVar subst) qtvs) + | otherwise + = Nothing - combine Nothing Nothing = Nothing - combine (Just n) Nothing = Just n - combine Nothing (Just n) = Just n - combine (Just n1) (Just n2) = Just (n1 `min` n2) + combine Nothing us = us + combine (Just u) us = u : us -{- Note [Use only the best local instance] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- | Instance dictionary function and type. +type InstDFun = (DFunId, [TcType], TcThetaType) + +-- | Try to find a local quantified instance that dominates all others, +-- i.e. which has a weaker instance context than all the others. +-- +-- See Note [Use only the best matching quantified constraint]. +dominatingMatch :: [InstDFun] -> Maybe InstDFun +dominatingMatch matches = + listToMaybe $ mapMaybe (uncurry go) (holes matches) + -- listToMaybe: arbitrarily pick any one context that is weaker than + -- all others, e.g. so that we can handle [Eq a, Num a] vs [Num a, Eq a] + -- (see test case T22223). + + where + go :: InstDFun -> [InstDFun] -> Maybe InstDFun + go this [] = Just this + go this@(_,_,this_theta) ((_,_,other_theta):others) + | this_theta `impliedBySCs` other_theta + = go this others + | otherwise + = Nothing + +-- | Whether a collection of constraints is implied by another collection, +-- according to a simple superclass check. +-- +-- See Note [When does a quantified instance dominate another?]. +impliedBySCs :: TcThetaType -> TcThetaType -> Bool +impliedBySCs c1 c2 = all in_c2 c1 + where + in_c2 :: TcPredType -> Bool + in_c2 pred = any (pred `eqType`) c2_expanded + + c2_expanded :: [TcPredType] -- Includes all superclasses + c2_expanded = [ q | p <- c2, q <- p : transSuperClasses p ] + + +{- Note [When does a quantified instance dominate another?] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When matching local quantified instances, it's useful to be able to pick +the one with the weakest precondition, e.g. if one has both + + [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 + +Then it makes sense to use d2 to solve w, as doing so we end up with a strictly +weaker proof obligation of `C a Int`, compared to `(Eq a, Num Int, C a Int)` +were we to use d1. + +In theory, to compute whether one context implies another, we would need to +recursively invoke the constraint solver. This is expensive, so we instead do +a simple check using superclasses, implemented in impliedBySCs. + +Examples: + + - [Eq a] is implied by [Ord a] + - [Ord a] is not implied by [Eq a], + - any context is implied by itself, + - the empty context is implied by any context. + +Note [Use only the best matching quantified constraint] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider (#20582) the ambiguity check for (forall a. Ord (m a), forall a. Semigroup a => Eq (m a)) => m Int Because of eager expansion of given superclasses, we get - [G] forall a. Ord (m a) - [G] forall a. Eq (m a) - [G] forall a. Semigroup a => Eq (m a) + [G] d1: forall a. Ord (m a) + [G] d2: forall a. Eq (m a) + [G] d3: forall a. Semigroup a => Eq (m a) - [W] forall a. Ord (m a) - [W] forall a. Semigroup a => Eq (m a) + [W] {w1}: forall a. Ord (m a) + [W] {w2}: forall a. Semigroup a => Eq (m a) The first wanted is solved straightforwardly. But the second wanted -matches *two* local instances. Our general rule around multiple local +matches *two* local instances: d2 and d3. Our general rule around multiple local instances is that we refuse to commit to any of them. However, that means that our type fails the ambiguity check. That's bad: the type is perfectly fine. (This actually came up in the wild, in the streamly library.) -The solution is to prefer local instances with fewer superclass selections. -So, matchLocalInst is careful to whittle down the matches only to the -ones with the shallowest superclass depth, and also to worry about unifying -local instances that are at that depth (or less). +The solution is to prefer local instances which are easier to prove, meaning +that they have a weaker precondition. In this case, the empty context +of d2 is a weaker constraint than the "Semigroup a" context of d3, so we prefer +using it when proving w2. This allows us to pass the ambiguity check here. + +Our criterion for solving a Wanted by matching local quantified instances is +thus as follows: + + - There is a matching local quantified instance that dominates all others + matches, in the sense of [When does a quantified instance dominate another?]. + Any such match do, we pick it arbitrarily (the T22223 example below says why). + - This local quantified instance also dominates all the unifiers, as we + wouldn't want to commit to a single match when we might have multiple, + genuinely different matches after further unification takes place. + +Some other examples: + + + #15244: + + f :: (C g, D g) => .... + class S g => C g where ... + class S g => D g where ... + class (forall a. Eq a => Eq (g a)) => S g where ... + + Here, in f's RHS, there are two identical quantified constraints + available, one via the superclasses of C and one via the superclasses + of D. Given that each implies the other, we pick one arbitrarily. + + + #22216: + + class Eq a + class Eq a => Ord a + class (forall b. Eq b => Eq (f b)) => Eq1 f + class (Eq1 f, forall b. Ord b => Ord (f b)) => Ord1 f + + Suppose we have + + [G] d1: Ord1 f + [G] d2: Eq a + [W] {w}: Eq (f a) + + Superclass expansion of d1 gives us: + + [G] d3 : Eq1 f + [G] d4 : forall b. Ord b => Ord (f b) + + expanding d4 and d5 gives us, respectively: + + [G] d5 : forall b. Eq b => Eq (f b) + [G] d6 : forall b. Ord b => Eq (f b) + + Now we have two matching local instances that we could use when solving the + Wanted. However, it's obviously silly to use d6, given that d5 provides us with + as much information, with a strictly weaker precondition. So we pick d5 to solve + w. If we chose d6, we would get [W] Ord a, which in this case we can't solve. + + + #22223: -By preferring these shallower local instances, we can use the last given -listed above and pass the ambiguity check. + [G] forall a b. (Eq a, Ord b) => C a b + [G] forall a b. (Ord b, Eq a) => C a b + [W] C x y -The instance-depth mechanism uses the same superclass depth -information as described in Note [Replacement vs keeping], 2a. + Here we should be free to pick either quantified constraint, as they are + equivalent up to re-ordering of the constraints in the context. + See also Note [Do not add duplicate quantified instances] + in GHC.Tc.Solver.Monad. -Test case: typecheck/should_compile/T20582. +Test cases: + typecheck/should_compile/T20582 + quantified-constraints/T15244 + quantified-constraints/T22216{a,b,c,d,e} + quantified-constraints/T22223 +Historical note: a previous solution was to instead pick the local instance +with the least superclass depth (see Note [Replacement vs keeping]), +but that doesn't work for the example from #22216. -} ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -220,21 +220,17 @@ addInertForAll new_qci {- Note [Do not add duplicate quantified instances] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider this (#15244): +As an optimisation, we avoid adding duplicate quantified instances to the +inert set; we use a simple duplicate check using tcEqType for simplicity, +even though it doesn't account for superficial differences, e.g. it will count +the following two constraints as different (#22223): - f :: (C g, D g) => .... - class S g => C g where ... - class S g => D g where ... - class (forall a. Eq a => Eq (g a)) => S g where ... + - forall a b. C a b + - forall b a. C a b -Then in f's RHS there are two identical quantified constraints -available, one via the superclasses of C and one via the superclasses -of D. The two are identical, and it seems wrong to reject the program -because of that. But without doing duplicate-elimination we will have -two matching QCInsts when we try to solve constraints arising from f's -RHS. - -The simplest thing is simply to eliminate duplicates, which we do here. +The main logic that allows us to pick local instances, even in the presence of +duplicates, is explained in Note [Use only the best matching quantified constraint] +in GHC.Tc.Solver.Interact. -} {- ********************************************************************* ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -464,8 +464,7 @@ data CtOrigin -- have 'InstSCOrigin' origin. | InstSCOrigin ScDepth -- ^ The number of superclass selections necessary to -- get this constraint; see Note [Replacement vs keeping] - -- and Note [Use only the best local instance], both in - -- GHC.Tc.Solver.Interact + -- in GHC.Tc.Solver.Interact TypeSize -- ^ If @(C ty1 .. tyn)@ is the largest class from -- which we made a superclass selection in the chain, -- then @TypeSize = sizeTypes [ty1, .., tyn]@ @@ -478,12 +477,13 @@ data CtOrigin -- f = e -- When typechecking body of 'f', the superclasses of the Given (Foo a) -- will have 'OtherSCOrigin'. - -- Needed for Note [Replacement vs keeping] and - -- Note [Use only the best local instance], both in GHC.Tc.Solver.Interact. + -- + -- Needed for Note [Replacement vs keeping] in GHC.Tc.Solver.Interact. | OtherSCOrigin ScDepth -- ^ The number of superclass selections necessary to -- get this constraint - SkolemInfoAnon -- ^ Where the sub-class constraint arose from - -- (used only for printing) + SkolemInfoAnon + -- ^ Where the sub-class constraint arose from + -- (used only for printing) -- All the others are for *wanted* constraints ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -43,6 +43,8 @@ module GHC.Utils.Misc ( chunkList, + holes, + changeLast, mapLastM, @@ -506,6 +508,13 @@ chunkList :: Int -> [a] -> [[a]] chunkList _ [] = [] chunkList n xs = as : chunkList n bs where (as,bs) = splitAt n xs +-- | Compute all the ways of removing a single element from a list. +-- +-- > holes [1,2,3] = [(1, [2,3]), (2, [1,3]), (3, [1,2])] +holes :: [a] -> [(a, [a])] +holes [] = [] +holes (x:xs) = (x, xs) : mapSnd (x:) (holes xs) + -- | Replace the last element of a list with another element. changeLast :: [a] -> a -> [a] changeLast [] _ = panic "changeLast" ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -68,6 +68,16 @@ Language :extension:`TypeData`. This extension permits ``type data`` declarations as a more fine-grained alternative to :extension:`DataKinds`. +- GHC now does a better job of solving constraints in the presence of multiple + matching quantified constraints. For example, if we want to solve + ``C a b Int`` and we have matching quantified constraints: :: + + forall x y z. (Ord x, Enum y, Num z) => C x y z + forall u v. (Enum v, Eq u) => C u v Int + + Then GHC will use the second quantified constraint to solve ``C a b Int``, + as it has a strictly weaker precondition. + Compiler ~~~~~~~~ ===================================== testsuite/tests/quantified-constraints/T22216a.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE QuantifiedConstraints, UndecidableInstances #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module T22216a where + +class Eq a +class Eq a => Ord a + +class (forall b. Eq b => Eq (f b)) => Eq1 f +class (Eq1 f, forall b. Ord b => Ord (f b)) => Ord1 f + +foo :: (Ord a, Ord1 f) => (Eq (f a) => r) -> r +foo r = r ===================================== testsuite/tests/quantified-constraints/T22216b.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE StandaloneDeriving #-} + +module T22216b where + +import Data.Functor.Classes + +newtype T f a = MkT (f a) + deriving ( Eq, Ord, Eq1 + , Ord1 + ) ===================================== testsuite/tests/quantified-constraints/T22216c.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE UndecidableInstances #-} + +module T22216c where + +import Prelude (Bool, Ordering) + +class Eq a where +class Eq a => Ord a where +class (forall a. Eq a => Eq (f a)) => Eq1 f where + +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where + liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + +instance Eq (T f a) +instance Ord (T f a) +instance Eq1 (T f) + +newtype T f a = MkT (f a) + deriving Ord1 ===================================== testsuite/tests/quantified-constraints/T22216d.hs ===================================== @@ -0,0 +1,33 @@ +{-# LANGUAGE QuantifiedConstraints #-} + +module T22216d where + +class (forall a. Eq a => Eq (f a)) => Eq1 f where + liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool + +eq1 :: (Eq1 f, Eq a) => f a -> f a -> Bool +eq1 = liftEq (==) + +class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where + liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering + +compare1 :: (Ord1 f, Ord a) => f a -> f a -> Ordering +compare1 = liftCompare compare + +data Cofree f a = a :< f (Cofree f a) + +instance (Eq1 f, Eq a) => Eq (Cofree f a) where + (==) = eq1 + +instance (Eq1 f) => Eq1 (Cofree f) where + liftEq eq = go + where + go (a :< as) (b :< bs) = eq a b && liftEq go as bs + +instance (Ord1 f, Ord a) => Ord (Cofree f a) where + compare = compare1 + +instance (Ord1 f) => Ord1 (Cofree f) where + liftCompare cmp = go + where + go (a :< as) (b :< bs) = cmp a b `mappend` liftCompare go as bs ===================================== testsuite/tests/quantified-constraints/T22216e.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE QuantifiedConstraints, UndecidableInstances #-} +{-# LANGUAGE RankNTypes #-} + +module T22216e where + +import Data.Kind + +type C :: Type -> Type -> Constraint +type D :: Type -> Type -> Constraint + +class C a b +instance C () Int +class D a b + +foo :: ( forall a b. ( Eq a, Num b, C a b ) => D a b + , forall a . C a Int => D a Int + ) + => ( D () Int => r ) -> r +foo r = r ===================================== testsuite/tests/quantified-constraints/T22223.hs ===================================== @@ -0,0 +1,24 @@ +{-# LANGUAGE AllowAmbiguousTypes, RankNTypes, QuantifiedConstraints #-} + +module T22223 where + +import Data.Kind + +type C :: Type -> Type -> Constraint +class C a b + +-- Change the order of quantification +foo :: ( forall a b. (Eq a, Ord b) => C a b + , forall b a. (Eq a, Ord b) => C a b + , Eq x + , Ord y ) + => ( C x y => r ) -> r +foo r = r + +-- Permute the constraints in the context +bar :: ( forall a b. (Eq a, Ord b) => C a b + , forall a b. (Ord b, Eq a) => C a b + , Eq x + , Ord y ) + => ( C x y => r ) -> r +bar r = r ===================================== testsuite/tests/quantified-constraints/all.T ===================================== @@ -34,3 +34,9 @@ test('T19921', normal, compile_fail, ['']) test('T16474', normal, compile_fail, ['']) test('T21006', normal, compile_fail, ['']) test('T21037', normal, compile, ['']) +test('T22216a', normal, compile, ['']) +test('T22216b', normal, compile, ['']) +test('T22216c', normal, compile, ['']) +test('T22216d', normal, compile, ['']) +test('T22216e', normal, compile, ['']) +test('T22223', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b74b6191d7c442dffdfc9a9e2a6d476d7b3a28f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b74b6191d7c442dffdfc9a9e2a6d476d7b3a28f2 You're receiving 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 Sep 28 19:39:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 15:39:22 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Apply some tricks to speed up core lint. Message-ID: <6334a2ea168af_2c9757514787901cb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 9f14b947 by Simon Peyton Jones at 2022-09-28T15:38:56-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 - - - - - 790e7adb by Simon Peyton Jones at 2022-09-28T15:38:56-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. - - - - - 23068582 by Simon Peyton Jones at 2022-09-28T15:38:56-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. - - - - - 2c999d36 by Jade Lovelace at 2022-09-28T15:39:00-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. - - - - - ee99a72e by Bodigrim at 2022-09-28T15:39:04-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. - - - - - 30 changed files: - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - + compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Rename.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0db6b61621319bc5d5329e2217fb009644b86fa5...ee99a72eb6f5ade78f6424359b36f3319fdf040f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0db6b61621319bc5d5329e2217fb009644b86fa5...ee99a72eb6f5ade78f6424359b36f3319fdf040f You're receiving 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 Sep 28 21:49:33 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 17:49:33 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Improve aggressive specialisation Message-ID: <6334c16d75450_2c97575148c812741@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Id/Make.hs - libraries/base/Foreign/Marshal/Array.hs - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/deSugar/should_compile/T19969.stderr - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/indexed-types/should_compile/T7837.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b74b6191d7c442dffdfc9a9e2a6d476d7b3a28f2...7be6f9a459b2fb0cdf7d1d26a373f7d4f89f7499 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b74b6191d7c442dffdfc9a9e2a6d476d7b3a28f2...7be6f9a459b2fb0cdf7d1d26a373f7d4f89f7499 You're receiving 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 Sep 28 21:50:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 17:50:05 -0400 Subject: [Git][ghc/ghc][master] Export OnOff from GHC.Driver.Session Message-ID: <6334c18d615f2_2c97572ed3bc7881643d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - compiler/GHC/Driver/Session.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -41,6 +41,7 @@ module GHC.Driver.Session ( DynamicTooState(..), dynamicTooState, setDynamicNow, sccProfilingEnabled, needSourceNotes, + OnOff(..), DynFlags(..), outputFile, objectSuf, ways, FlagSpec(..), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b0c89dfaf9f8aeda9dd69a9583fd29150099aa27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b0c89dfaf9f8aeda9dd69a9583fd29150099aa27 You're receiving 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 Sep 28 21:50:47 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 17:50:47 -0400 Subject: [Git][ghc/ghc][master] Avoid Data.List.group; prefer Data.List.NonEmpty.group Message-ID: <6334c1b7361a5_2c975751400820064@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 14 changed files: - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Gen/Expr.hs - ghc/GHCi/UI.hs - ghc/GHCi/UI/Tags.hs - hadrian/src/Rules/Dependencies.hs - testsuite/tests/lib/integer/integerGmpInternals.hs - testsuite/tests/numeric/should_run/CarryOverflow.hs Changes: ===================================== compiler/GHC/Cmm/Switch.hs ===================================== @@ -20,8 +20,7 @@ import GHC.Utils.Panic import GHC.Cmm.Dataflow.Label (Label) import Data.Maybe -import Data.List (groupBy) -import Data.Function (on) +import qualified Data.List.NonEmpty as NE import qualified Data.Map as M -- Note [Cmm Switches, the general plan] @@ -204,8 +203,8 @@ switchTargetsToList (SwitchTargets _ _ mbdef branches) switchTargetsFallThrough :: SwitchTargets -> ([([Integer], Label)], Maybe Label) switchTargetsFallThrough (SwitchTargets _ _ mbdef branches) = (groups, mbdef) where - groups = map (\xs -> (map fst xs, snd (head xs))) $ - groupBy ((==) `on` snd) $ + groups = map (\xs -> (map fst (NE.toList xs), snd (NE.head xs))) $ + NE.groupWith snd $ M.toList branches -- | Custom equality helper, needed for "GHC.Cmm.CommonBlockElim" ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -139,7 +139,8 @@ import GHC.Unit import GHC.Data.Stream (Stream) import qualified GHC.Data.Stream as Stream -import Data.List (sortBy, groupBy) +import Data.List (sortBy) +import qualified Data.List.NonEmpty as NE import Data.Maybe import Data.Ord ( comparing ) import Control.Monad @@ -769,17 +770,14 @@ makeImportsDoc config imports -- Generate "symbol stubs" for all external symbols that might -- come from a dynamic library. dyld_stubs :: [CLabel] -> SDoc -{- dyld_stubs imps = vcat $ map pprDyldSymbolStub $ - map head $ group $ sort imps-} -- (Hack) sometimes two Labels pretty-print the same, but have -- different uniques; so we compare their text versions... dyld_stubs imps | needImportedSymbols config = vcat $ (pprGotDeclaration config :) $ - map ( pprImportedSymbol config . fst . head) $ - groupBy (\(_,a) (_,b) -> a == b) $ - sortBy (\(_,a) (_,b) -> compare a b) $ + fmap ( pprImportedSymbol config . fst . NE.head) $ + NE.groupAllWith snd $ map doPpr $ imps | otherwise ===================================== compiler/GHC/CmmToAsm/Reg/Liveness.hs ===================================== @@ -67,7 +67,7 @@ import GHC.Types.Unique.Supply import GHC.Data.Bag import GHC.Utils.Monad.State.Strict -import Data.List (mapAccumL, groupBy, partition) +import Data.List (mapAccumL, partition) import Data.Maybe import Data.IntSet (IntSet) @@ -911,13 +911,11 @@ livenessSCCs platform blockmap done -> a -> b -> (a,c) - iterateUntilUnchanged f eq a b - = head $ - concatMap tail $ - groupBy (\(a1, _) (a2, _) -> eq a1 a2) $ - iterate (\(a, _) -> f a b) $ - (a, panic "RegLiveness.livenessSCCs") - + iterateUntilUnchanged f eq aa b = go aa + where + go a = if eq a a' then ac else go a' + where + ac@(a', _) = f a b linearLiveness :: Instruction instr ===================================== compiler/GHC/CmmToLlvm/Base.hs ===================================== @@ -59,7 +59,8 @@ import GHC.Utils.Logger import Data.Maybe (fromJust) import Control.Monad.Trans.State (StateT (..)) -import Data.List (sortBy, groupBy, isPrefixOf) +import Data.List (isPrefixOf) +import qualified Data.List.NonEmpty as NE import Data.Ord (comparing) -- ---------------------------------------------------------------------------- @@ -192,7 +193,7 @@ padLiveArgs platform live = -- set of real registers to be passed. E.g. FloatReg, DoubleReg and XmmReg -- all use the same real regs on X86-64 (XMM registers). -- - classes = groupBy sharesClass fprLive + classes = NE.groupBy sharesClass fprLive sharesClass a b = regsOverlap platform (norm a) (norm b) -- check if mapped to overlapping registers norm x = CmmGlobal ((fpr_ctor x) 1) -- get the first register of the family @@ -202,10 +203,10 @@ padLiveArgs platform live = -- E.g. sortedRs = [ F2, XMM4, D5] -- output = [D1, D3] padded = concatMap padClass classes - padClass rs = go sortedRs [1..] + padClass rs = go (NE.toList sortedRs) 1 where - sortedRs = sortBy (comparing fpr_num) rs - maxr = last sortedRs + sortedRs = NE.sortBy (comparing fpr_num) rs + maxr = NE.last sortedRs ctor = fpr_ctor maxr go [] _ = [] @@ -216,10 +217,9 @@ padLiveArgs platform live = text "Found two different Cmm registers (" <> ppr c1 <> text "," <> ppr c2 <> text ") both alive AND mapped to the same real register: " <> ppr real <> text ". This isn't currently supported by the LLVM backend." - go (c:cs) (f:fs) - | fpr_num c == f = go cs fs -- already covered by a real register - | otherwise = ctor f : go (c:cs) fs -- add padding register - go _ _ = undefined -- unreachable + go (c:cs) f + | fpr_num c == f = go cs f -- already covered by a real register + | otherwise = ctor f : go (c:cs) (f + 1) -- add padding register fpr_ctor :: GlobalReg -> Int -> GlobalReg fpr_ctor (FloatReg _) = FloatReg ===================================== compiler/GHC/Core/Opt/Stats.hs ===================================== @@ -22,12 +22,14 @@ import GHC.Utils.Outputable as Outputable import GHC.Data.FastString -import Data.List (groupBy, sortBy) +import Data.List (sortOn) +import Data.List.NonEmpty (NonEmpty(..)) +import qualified Data.List.NonEmpty as NE import Data.Ord import Data.Map (Map) import qualified Data.Map as Map import qualified Data.Map.Strict as MapStrict -import GHC.Utils.Panic (throwGhcException, GhcException(..), panic) +import GHC.Utils.Panic (throwGhcException, GhcException(..)) getVerboseSimplStats :: (Bool -> SDoc) -> SDoc getVerboseSimplStats = getPprDebug -- For now, anyway @@ -205,18 +207,16 @@ pprTickCounts :: Map Tick Int -> SDoc pprTickCounts counts = vcat (map pprTickGroup groups) where - groups :: [[(Tick,Int)]] -- Each group shares a common tag - -- toList returns common tags adjacent - groups = groupBy same_tag (Map.toList counts) - same_tag (tick1,_) (tick2,_) = tickToTag tick1 == tickToTag tick2 - -pprTickGroup :: [(Tick, Int)] -> SDoc -pprTickGroup group@((tick1,_):_) - = hang (int (sum [n | (_,n) <- group]) <+> text (tickString tick1)) + groups :: [NonEmpty (Tick, Int)] -- Each group shares a common tag + -- toList returns common tags adjacent + groups = NE.groupWith (tickToTag . fst) (Map.toList counts) + +pprTickGroup :: NonEmpty (Tick, Int) -> SDoc +pprTickGroup group@((tick1,_) :| _) + = hang (int (sum (fmap snd group)) <+> text (tickString tick1)) 2 (vcat [ int n <+> pprTickCts tick -- flip as we want largest first - | (tick,n) <- sortBy (flip (comparing snd)) group]) -pprTickGroup [] = panic "pprTickGroup" + | (tick,n) <- sortOn (Down . snd) (NE.toList group)]) data Tick -- See Note [Which transformations are innocuous] = PreInlineUnconditionally Id ===================================== compiler/GHC/HsToCore/Match/Constructor.hs ===================================== @@ -36,8 +36,8 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain import Control.Monad(liftM) -import Data.List (groupBy) import Data.List.NonEmpty (NonEmpty(..)) +import qualified Data.List.NonEmpty as NE {- We are confronted with the first column of patterns in a set of @@ -143,13 +143,13 @@ matchOneConLike vars ty mult (eqn1 :| eqns) -- All eqns for a single construct -- and returns the types of the *value* args, which is what we want match_group :: [Id] - -> [(ConArgPats, EquationInfo)] -> DsM (MatchResult CoreExpr) + -> NonEmpty (ConArgPats, EquationInfo) + -> DsM (MatchResult CoreExpr) -- All members of the group have compatible ConArgPats match_group arg_vars arg_eqn_prs - = assert (notNull arg_eqn_prs) $ - do { (wraps, eqns') <- liftM unzip (mapM shift arg_eqn_prs) + = do { (wraps, eqns') <- liftM NE.unzip (mapM shift arg_eqn_prs) ; let group_arg_vars = select_arg_vars arg_vars arg_eqn_prs - ; match_result <- match (group_arg_vars ++ vars) ty eqns' + ; match_result <- match (group_arg_vars ++ vars) ty (NE.toList eqns') ; return $ foldr1 (.) wraps <$> match_result } @@ -184,9 +184,9 @@ matchOneConLike vars ty mult (eqn1 :| eqns) -- All eqns for a single construct -- suggestions for the new variables -- Divide into sub-groups; see Note [Record patterns] - ; let groups :: [[(ConArgPats, EquationInfo)]] - groups = groupBy compatible_pats [ (pat_args (firstPat eqn), eqn) - | eqn <- eqn1:eqns ] + ; let groups :: NonEmpty (NonEmpty (ConArgPats, EquationInfo)) + groups = NE.groupBy1 compatible_pats + $ fmap (\eqn -> (pat_args (firstPat eqn), eqn)) (eqn1 :| eqns) ; match_results <- mapM (match_group arg_vars) groups @@ -210,8 +210,8 @@ matchOneConLike vars ty mult (eqn1 :| eqns) -- All eqns for a single construct -- Choose the right arg_vars in the right order for this group -- Note [Record patterns] - select_arg_vars :: [Id] -> [(ConArgPats, EquationInfo)] -> [Id] - select_arg_vars arg_vars ((arg_pats, _) : _) + select_arg_vars :: [Id] -> NonEmpty (ConArgPats, EquationInfo) -> [Id] + select_arg_vars arg_vars ((arg_pats, _) :| _) | RecCon flds <- arg_pats , let rpats = rec_flds flds , not (null rpats) -- Treated specially; cf conArgPats @@ -224,7 +224,6 @@ matchOneConLike vars ty mult (eqn1 :| eqns) -- All eqns for a single construct fld_var_env = mkNameEnv $ zipEqual "get_arg_vars" fields1 arg_vars lookup_fld (L _ rpat) = lookupNameEnv_NF fld_var_env (idName (hsRecFieldId rpat)) - select_arg_vars _ [] = panic "matchOneCon/select_arg_vars []" ----------------- compatible_pats :: (ConArgPats,a) -> (ConArgPats,a) -> Bool ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -80,7 +80,7 @@ import qualified GHC.LanguageExtensions as LangExt import Language.Haskell.Syntax.Basic (FieldLabelString(..)) -import Data.List (sortBy, nubBy, partition) +import Data.List (nubBy, partition) import qualified Data.List.NonEmpty as NE import Data.List.NonEmpty (NonEmpty(..)) import Control.Monad @@ -443,7 +443,7 @@ rnImplicitTvBndrs :: HsDocContext -> ([Name] -> RnM (a, FreeVars)) -> RnM (a, FreeVars) rnImplicitTvBndrs ctx mb_assoc implicit_vs_with_dups thing_inside - = do { implicit_vs <- forM (NE.groupBy eqLocated $ sortBy cmpLocated $ implicit_vs_with_dups) $ \case + = do { implicit_vs <- forM (NE.groupAllWith unLoc $ implicit_vs_with_dups) $ \case (x :| []) -> return x (x :| _) -> do let msg = mkTcRnUnknownMessage $ mkPlainError noHints $ ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -93,7 +93,9 @@ import Data.Either ( partitionEithers ) import Data.Map ( Map ) import qualified Data.Map as Map import Data.Ord ( comparing ) -import Data.List ( partition, (\\), find, sortBy, groupBy, sortOn ) +import Data.List ( partition, (\\), find, sortBy ) +import Data.List.NonEmpty (NonEmpty(..)) +import qualified Data.List.NonEmpty as NE import Data.Function ( on ) import qualified Data.Set as S import Data.Foldable ( toList ) @@ -1968,7 +1970,7 @@ getMinimalImports = fmap combine . mapM mk_minimal all_non_overloaded = all (not . flIsOverloaded) combine :: [LImportDecl GhcRn] -> [LImportDecl GhcRn] - combine = map merge . groupBy ((==) `on` getKey) . sortOn getKey + combine = map merge . NE.groupAllWith getKey getKey :: LImportDecl GhcRn -> (Bool, Maybe ModuleName, ModuleName) getKey decl = @@ -1980,10 +1982,9 @@ getMinimalImports = fmap combine . mapM mk_minimal idecl :: ImportDecl GhcRn idecl = unLoc decl - merge :: [LImportDecl GhcRn] -> LImportDecl GhcRn - merge [] = error "getMinimalImports: unexpected empty list" - merge decls@((L l decl) : _) = L l (decl { ideclImportList = Just (Exactly, L (noAnnSrcSpan (locA l)) lies) }) - where lies = concatMap (unLoc . snd) $ mapMaybe (ideclImportList . unLoc) decls + merge :: NonEmpty (LImportDecl GhcRn) -> LImportDecl GhcRn + merge decls@((L l decl) :| _) = L l (decl { ideclImportList = Just (Exactly, L (noAnnSrcSpan (locA l)) lies) }) + where lies = concatMap (unLoc . snd) $ mapMaybe (ideclImportList . unLoc) $ NE.toList decls printMinimalImports :: HscSource -> [ImportDeclUsage] -> RnM () ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -88,7 +88,8 @@ import GHC.Types.Unique.Set ( UniqSet, mkUniqSet, elementOfUniqSet, nonDetEltsUn import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Data.Function -import Data.List (partition, sortBy, groupBy, intersect) +import Data.List (partition, sortBy, intersect) +import qualified Data.List.NonEmpty as NE import GHC.Data.Bag ( unitBag ) @@ -1699,7 +1700,7 @@ badFieldsUpd rbinds data_cons in -- Fields that don't change the membership status of the set -- are redundant and can be dropped. - map (fst . head) $ groupBy ((==) `on` snd) growingSets + map (fst . NE.head) $ NE.groupWith snd growingSets aMember = assert (not (null members) ) fst (head members) (members, nonMembers) = partition (or . snd) membership ===================================== ghc/GHCi/UI.hs ===================================== @@ -122,8 +122,9 @@ import qualified Data.ByteString.Char8 as BS import Data.Char import Data.Function import Data.IORef ( IORef, modifyIORef, newIORef, readIORef, writeIORef ) -import Data.List ( elemIndices, find, group, intercalate, intersperse, +import Data.List ( elemIndices, find, intercalate, intersperse, isPrefixOf, isSuffixOf, nub, partition, sort, sortBy, (\\) ) +import qualified Data.List.NonEmpty as NE import qualified Data.Set as S import Data.Maybe import qualified Data.Map as M @@ -3699,11 +3700,11 @@ completeSetOptions = wrapCompleter flagWordBreakChars $ \w -> do return (filter (w `isPrefixOf`) opts) where opts = "args":"prog":"prompt":"prompt-cont":"prompt-function": "prompt-cont-function":"editor":"stop":flagList - flagList = map head $ group $ sort allNonDeprecatedFlags + flagList = map NE.head $ NE.group $ sort allNonDeprecatedFlags completeSeti = wrapCompleter flagWordBreakChars $ \w -> do return (filter (w `isPrefixOf`) flagList) - where flagList = map head $ group $ sort allNonDeprecatedFlags + where flagList = map NE.head $ NE.group $ sort allNonDeprecatedFlags completeShowOptions = wrapCompleter flagWordBreakChars $ \w -> do return (filter (w `isPrefixOf`) opts) ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -29,7 +29,8 @@ import GHC.Driver.Env import Control.Monad import Data.Function -import Data.List (sort, sortBy, groupBy) +import Data.List (sort, sortOn) +import qualified Data.List.NonEmpty as NE import Data.Maybe import Data.Ord import GHC.Driver.Phases @@ -176,14 +177,13 @@ collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs makeTagGroupsWithSrcInfo :: [TagInfo] -> IO [[TagInfo]] makeTagGroupsWithSrcInfo tagInfos = do - let groups = groupBy ((==) `on` tagFile) $ sortBy (comparing tagFile) tagInfos + let groups = NE.groupAllWith tagFile tagInfos mapM addTagSrcInfo groups where - addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") - addTagSrcInfo group@(tagInfo:_) = do + addTagSrcInfo group@(tagInfo NE.:| _) = do file <- readFile $ tagFile tagInfo - let sortedGroup = sortBy (comparing tagLine) group + let sortedGroup = sortOn tagLine (NE.toList group) return $ perFile sortedGroup 1 0 $ lines file perFile allTags@(tag:tags) cnt pos allLs@(l:ls) ===================================== hadrian/src/Rules/Dependencies.hs ===================================== @@ -2,6 +2,7 @@ module Rules.Dependencies (buildPackageDependencies) where import Data.Bifunctor import Data.Function +import qualified Data.List.NonEmpty as NE import Base import Context @@ -67,9 +68,8 @@ buildPackageDependencies rs = do writeFileChanged deps . unlines . map (\(src, deps) -> unwords $ src : deps) . map (bimap unifyPath (map unifyPath)) - . map (bimap head concat . unzip) - . groupBy ((==) `on` fst) - . sortBy (compare `on` fst) + . map (bimap NE.head concat . NE.unzip) + . NE.groupAllWith fst $ parseMakefile mkDeps ===================================== testsuite/tests/lib/integer/integerGmpInternals.hs ===================================== @@ -2,7 +2,7 @@ module Main (main) where -import Data.List (group) +import qualified Data.List.NonEmpty as NE import Data.Bits import Data.Word import Control.Monad @@ -40,7 +40,7 @@ main = do b1024 = roll (map fromIntegral (take 128 [0x80::Int .. ])) - rle = map (\x -> (length x, head x)) . group + rle = map (\x -> (length x, NE.head x)) . NE.group roll :: [Word8] -> Integer ===================================== testsuite/tests/numeric/should_run/CarryOverflow.hs ===================================== @@ -5,7 +5,8 @@ import GHC.Exts import Control.Monad import Data.Bits -import Data.List (sort, group) +import Data.List (sort) +import qualified Data.List.NonEmpty as NE import System.Exit allEqual :: Eq a => [a] -> Bool @@ -13,7 +14,7 @@ allEqual [] = error "allEqual: nothing to compare" allEqual (x:xs) = all (== x) xs testWords :: [Word] -testWords = map head . group . sort $ +testWords = map NE.head . NE.group . sort $ concatMap (\w -> [w - 1, w, w + 1]) $ concatMap (\w -> [w, maxBound - w]) $ trailingOnes ++ randoms View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f050687e75ffe6fbf140cacd15fd916d2997499 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f050687e75ffe6fbf140cacd15fd916d2997499 You're receiving 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 Sep 28 22:32:02 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 18:32:02 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] 8 commits: Apply some tricks to speed up core lint. Message-ID: <6334cb62b25f0_2c9757514288293e3@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 8651488d by Simon Peyton Jones at 2022-09-28T23:31:50+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 quite a bit, but the trend is slightly down Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change ------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 4,566,082,536 -25.0% GOOD T10421(normal) ghc/alloc 111,994,304 116,148,544 +3.7% BAD T10421a(normal) ghc/alloc 79,150,034 83,423,664 +5.4% T10547(normal) ghc/alloc 28,211,501 28,177,960 -0.1% T12545(normal) ghc/alloc 1,633,149,272 1,614,005,512 -1.2% T13253(normal) ghc/alloc 343,592,469 347,635,808 +1.2% T14052(ghci) ghc/alloc 3,681,055,512 3,749,063,688 +1.8% T15304(normal) ghc/alloc 1,295,512,578 1,277,067,608 -1.4% T16577(normal) ghc/alloc 8,050,423,421 8,291,093,504 +3.0% BAD T17516(normal) ghc/alloc 1,800,051,592 1,840,575,008 +2.3% T17836(normal) ghc/alloc 829,913,981 812,805,232 -2.1% T17836b(normal) ghc/alloc 45,437,680 45,057,120 -0.8% T18223(normal) ghc/alloc 734,732,288 646,329,352 -12.0% GOOD T3064(normal) ghc/alloc 180,023,717 182,061,608 +1.1% T9630(normal) ghc/alloc 1,523,682,706 1,492,863,632 -2.0% GOOD T9961(normal) ghc/alloc 358,760,821 368,223,992 +2.6% BAD geo. mean -0.3% minimum -25.0% maximum +5.4% Metric Decrease: LargeRecord T18223 T9630 Metric Increase: T10421 T16577 T9961 - - - - - 30 changed files: - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - + compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Rename.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c20396faef0cc3c18e57c977ac439a00d19e16ed...8651488dd9e0159844772334a2d9edb6b3e01a55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c20396faef0cc3c18e57c977ac439a00d19e16ed...8651488dd9e0159844772334a2d9edb6b3e01a55 You're receiving 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 Sep 28 22:43:30 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 18:43:30 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] Make rewrite rules "win" over inlining Message-ID: <6334ce1290681_2c975751464838493@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: a6009bbc by Simon Peyton Jones at 2022-09-28T23:43:10+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 quite a bit, but the trend is slightly down Metrics: compile_time/bytes allocated ------------------------------------- Baseline Test Metric value New value Change ------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,084,071,354 4,566,082,536 -25.0% GOOD T10421(normal) ghc/alloc 111,994,304 116,148,544 +3.7% BAD T10421a(normal) ghc/alloc 79,150,034 83,423,664 +5.4% T10547(normal) ghc/alloc 28,211,501 28,177,960 -0.1% T12545(normal) ghc/alloc 1,633,149,272 1,614,005,512 -1.2% T13253(normal) ghc/alloc 343,592,469 347,635,808 +1.2% T14052(ghci) ghc/alloc 3,681,055,512 3,749,063,688 +1.8% T15304(normal) ghc/alloc 1,295,512,578 1,277,067,608 -1.4% T16577(normal) ghc/alloc 8,050,423,421 8,291,093,504 +3.0% BAD T17516(normal) ghc/alloc 1,800,051,592 1,840,575,008 +2.3% T17836(normal) ghc/alloc 829,913,981 812,805,232 -2.1% T17836b(normal) ghc/alloc 45,437,680 45,057,120 -0.8% T18223(normal) ghc/alloc 734,732,288 646,329,352 -12.0% GOOD T3064(normal) ghc/alloc 180,023,717 182,061,608 +1.1% T9630(normal) ghc/alloc 1,523,682,706 1,492,863,632 -2.0% GOOD T9961(normal) ghc/alloc 358,760,821 368,223,992 +2.6% BAD geo. mean -0.3% minimum -25.0% maximum +5.4% Metric Decrease: LargeRecord T18223 T9630 Metric Increase: T10421 T16577 T9961 - - - - - 8 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - testsuite/tests/lib/integer/Makefile - + testsuite/tests/simplCore/should_compile/T21851.hs - + testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851a.hs - testsuite/tests/simplCore/should_compile/T6056.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1919,7 +1919,9 @@ wrapJoinCont env cont thing_inside -------------------- -trimJoinCont :: Id -> Maybe JoinArity -> SimplCont -> SimplCont +trimJoinCont :: Id -- Used only in error message + -> Maybe JoinArity + -> SimplCont -> SimplCont -- Drop outer context from join point invocation (jump) -- See Note [Join points and case-of-case] @@ -2017,6 +2019,17 @@ outside. Surprisingly tricky! Variables * * ************************************************************************ + +Note [zapSubstEnv] +~~~~~~~~~~~~~~~~~~ +When simplifying something that has already been simplified, be sure to +zap the SubstEnv. This is VITAL. Consider + let x = e in + let y = \z -> ...x... in + \ x -> ...y... + +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!! -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2035,86 +2048,28 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont = case substId env var of - ContEx tvs cvs ids e -> - let env' = setSubstEnv env tvs cvs ids - in simplExprF env' e cont - -- Don't trim; haven't already simplified e, - -- so the cont is not embodied in e - - DoneId var1 -> do - logger <- getLogger - let cont' = trimJoinCont var (isJoinId_maybe var1) cont - completeCall logger env var1 cont' - - DoneEx e mb_join -> - let env' = zapSubstEnv env - cont' = trimJoinCont var mb_join cont - in simplExprF env' e cont' - -- Note [zapSubstEnv] - -- ~~~~~~~~~~~~~~~~~~ - -- The template is already simplified, so don't re-substitute. - -- This is VITAL. Consider - -- let x = e in - -- let y = \z -> ...x... in - -- \ x -> ...y... - -- 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!! - ---------------------------------------------------------- --- Dealing with a call site - -completeCall :: Logger -> SimplEnv -> OutId -> SimplCont -> SimplM (SimplFloats, OutExpr) -completeCall logger env var cont - | Just expr <- callSiteInline logger uf_opts case_depth var active_unf - lone_variable arg_infos interesting_cont - -- Inline the variable's RHS - = do { checkedTick (UnfoldingDone var) - ; dump_inline expr cont - ; let env1 = zapSubstEnv env - ; simplExprF env1 expr cont } - - | otherwise - -- Don't inline; instead rebuild the call - = do { rule_base <- getSimplRules - ; let rules = getRules rule_base var - info = mkArgInfo env var rules - n_val_args call_cont - ; rebuildCall env info cont } + ContEx tvs cvs ids e -> simplExprF env' e cont + -- Don't trimJoinCont; haven't already simplified e, + -- so the cont is not embodied in e + where + env' = setSubstEnv env tvs cvs ids - where - uf_opts = seUnfoldingOpts env - case_depth = seCaseDepth env - (lone_variable, arg_infos, call_cont) = contArgs cont - n_val_args = length arg_infos - interesting_cont = interestingCallContext env call_cont - active_unf = activeUnfolding (seMode env) var + DoneId var1 -> + do { rule_base <- getSimplRules + ; let cont' = trimJoinCont var1 (isJoinId_maybe var1) cont + info = mkArgInfo env rule_base var1 cont' + ; rebuildCall env info cont' } - log_inlining doc - = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify) - Opt_D_dump_inlinings - "" FormatText doc + DoneEx e mb_join -> simplExprF env' e cont' + where + cont' = trimJoinCont var mb_join cont + env' = zapSubstEnv env -- See Note [zapSubstEnv] - dump_inline unfolding cont - | not (logHasDumpFlag logger Opt_D_dump_inlinings) = return () - | not (logHasDumpFlag logger Opt_D_verbose_core2core) - = when (isExternalName (idName var)) $ - log_inlining $ - sep [text "Inlining done:", nest 4 (ppr var)] - | otherwise - = log_inlining $ - sep [text "Inlining done: " <> ppr var, - nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), - text "Cont: " <+> ppr cont])] +--------------------------------------------------------- +-- Dealing with a call site -rebuildCall :: SimplEnv - -> ArgInfo - -> SimplCont +rebuildCall :: SimplEnv -> ArgInfo -> SimplCont -> SimplM (SimplFloats, OutExpr) --- We decided not to inline, so --- - simplify the arguments --- - try rewrite rules --- - and rebuild ---------- Bottoming applications -------------- rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_dmds = [] }) cont @@ -2137,27 +2092,48 @@ rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_dmds = [] }) con res = argInfoExpr fun rev_args cont_ty = contResultType cont ----------- Try rewrite RULES -------------- --- See Note [Trying rewrite rules] +---------- Try inlining, if ai_rewrite = TryInlining -------- +-- In the TryInlining case we try inlining immediately, before simplifying +-- any (more) arguments. Why? See Note [Rewrite rules and inlining]. +-- +-- If there are rewrite rules we'll skip this case until we have +-- simplified enough args to satisfy nr_wanted==0 in the TryRules case below +-- Then we'll try the rules, and if that fails, we'll do TryInlining +rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args + , ai_rewrite = TryInlining }) cont + = do { logger <- getLogger + ; let full_cont = pushSimplifiedRevArgs env rev_args cont + ; mb_inline <- tryInlining env logger fun full_cont + ; case mb_inline of + Just expr -> do { checkedTick (UnfoldingDone fun) + ; let env1 = zapSubstEnv env + ; simplExprF env1 expr full_cont } + Nothing -> rebuildCall env (info { ai_rewrite = TryNothing }) cont + } + +---------- Try rewrite RULES, if ai_rewrite = TryRules -------------- +-- See Note [Rewrite rules and inlining] +-- See also Note [Trying rewrite rules] rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args - , ai_rules = Just (nr_wanted, rules) }) cont + , ai_rewrite = TryRules nr_wanted rules }) cont | nr_wanted == 0 || no_more_args - , let info' = info { ai_rules = Nothing } = -- We've accumulated a simplified call in -- so try rewrite rules; see Note [RULES apply to simplified arguments] -- See also Note [Rules for recursive functions] do { mb_match <- tryRules env rules fun (reverse rev_args) cont ; case mb_match of Just (env', rhs, cont') -> simplExprF env' rhs cont' - Nothing -> rebuildCall env info' cont } + Nothing -> rebuildCall env (info { ai_rewrite = TryInlining }) cont } where + -- If we have run out of arguments, just try the rules; there might + -- be some with lower arity. Casts get in the way -- they aren't + -- allowed on rule LHSs no_more_args = case cont of ApplyToTy {} -> False ApplyToVal {} -> False _ -> True - ----------- Simplify applications and casts -------------- +---------- Simplify type applications and casts -------------- rebuildCall env info (CastIt co cont) = rebuildCall env (addCastTo info co) cont @@ -2202,6 +2178,7 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) call' = mkApps (Var fun_id) [mkTyArg rr', mkTyArg ty', arg'] ; return (emptyFloats env, call') } +---------- Simplify value arguments -------------------- rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty @@ -2237,6 +2214,42 @@ rebuildCall env fun_info rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) cont = rebuild env (argInfoExpr fun rev_args) cont +----------------------------------- +tryInlining :: SimplEnv -> Logger -> OutId -> SimplCont -> SimplM (Maybe OutExpr) +tryInlining env logger var cont + | Just expr <- callSiteInline logger uf_opts case_depth var active_unf + lone_variable arg_infos interesting_cont + = do { dump_inline expr cont + ; return (Just expr) } + + | otherwise + = return Nothing + + where + uf_opts = seUnfoldingOpts env + case_depth = seCaseDepth env + (lone_variable, arg_infos, call_cont) = contArgs cont + interesting_cont = interestingCallContext env call_cont + active_unf = activeUnfolding (seMode env) var + + log_inlining doc + = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify) + Opt_D_dump_inlinings + "" FormatText doc + + dump_inline unfolding cont + | not (logHasDumpFlag logger Opt_D_dump_inlinings) = return () + | not (logHasDumpFlag logger Opt_D_verbose_core2core) + = when (isExternalName (idName var)) $ + log_inlining $ + sep [text "Inlining done:", nest 4 (ppr var)] + | otherwise + = log_inlining $ + sep [text "Inlining done: " <> ppr var, + nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), + text "Cont: " <+> ppr cont])] + + {- Note [Trying rewrite rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider an application (f e1 e2 e3) where the e1,e2,e3 are not yet @@ -2272,6 +2285,38 @@ makes a particularly big difference when superclass selectors are involved: op ($p1 ($p2 (df d))) We want all this to unravel in one sweep. +Note [Rewrite rules and inlining] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general we try to arrange that inlining is disabled (via a pragma) if +a rewrite rule should apply, so that the rule has a decent chance to fire +before we inline the function. + +But it turns out that (especially when type-class specialisation or +SpecConstr is involved) it is very helpful for the the rewrite rule to +"win" over inlining when both are active at once: see #21851, #22097. + +The simplifier arranges to do this, as follows. In effect, the ai_rewrite +field of the ArgInfo record is the state of a little state-machine: + +* mkArgInfo sets the ai_rewrite field to TryRules if there are any rewrite + rules avaialable for that function. + +* rebuildCall simplifies arguments until enough are simplified to match the + rule with greatest arity. See Note [RULES apply to simplified arguments] + and the first field of `TryRules`. + + But no more! As soon as we have simplified enough arguments to satisfy the + maximum-arity rules, we try the rules; see Note [Trying rewrite rules]. + +* Once we have tried rules (or immediately if there are no rules) set + ai_rewrite to TryInlining, and the Simplifier will try to inline the + function. We want to try this immediately (before simplifying any (more) + arguments). Why? Consider + f BIG where f = \x{OneOcc}. ...x... + If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, + and we'll simplify BIG once, at x's occurrence, rather than twice. + + Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Because RULES apply to simplified arguments, there's a danger of repeatedly @@ -2327,7 +2372,8 @@ See Note [No free join points in arityType] in GHC.Core.Opt.Arity -} tryRules :: SimplEnv -> [CoreRule] - -> Id -> [ArgSpec] + -> Id + -> [ArgSpec] -- In /normal, forward/ order -> SimplCont -> SimplM (Maybe (SimplEnv, CoreExpr, SimplCont)) @@ -3668,7 +3714,7 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty | otherwise = do { join_bndr <- newJoinId [arg_bndr] res_ty ; let arg_info = ArgInfo { ai_fun = join_bndr - , ai_rules = Nothing, ai_args = [] + , ai_rewrite = TryNothing, ai_args = [] , ai_encl = False, ai_dmds = repeat topDmd , ai_discs = repeat 0 } ; return ( addJoinFloats (emptyFloats env) $ ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -30,9 +30,10 @@ module GHC.Core.Opt.Simplify.Utils ( interestingCallContext, -- ArgInfo - ArgInfo(..), ArgSpec(..), mkArgInfo, + ArgInfo(..), ArgSpec(..), RewriteCall(..), mkArgInfo, addValArgTo, addCastTo, addTyArgTo, - argInfoExpr, argInfoAppArgs, pushSimplifiedArgs, + argInfoExpr, argInfoAppArgs, + pushSimplifiedArgs, pushSimplifiedRevArgs, isStrictArgInfo, lazyArgContext, abstractFloats, @@ -52,6 +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.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make @@ -210,6 +212,7 @@ data SimplCont type StaticEnv = SimplEnv -- Just the static part is relevant +-- See Note [DupFlag invariants] data DupFlag = NoDup -- Unsimplified, might be big | Simplified -- Simplified | OkToDup -- Simplified and small @@ -226,8 +229,9 @@ perhapsSubstTy dup env ty {- Note [StaticEnv invariant] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We pair up an InExpr or InAlts with a StaticEnv, which establishes the -lexical scope for that InExpr. When we simplify that InExpr/InAlts, we -use +lexical scope for that InExpr. + +When we simplify that InExpr/InAlts, we use - Its captured StaticEnv - Overriding its InScopeSet with the larger one at the simplification point. @@ -244,13 +248,14 @@ isn't big enough. Note [DupFlag invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~ -In both (ApplyToVal dup _ env k) - and (Select dup _ _ env k) +In both ApplyToVal { se_dup = dup, se_env = env, se_cont = k} + and Select { se_dup = dup, se_env = env, se_cont = k} the following invariants hold (a) if dup = OkToDup, then continuation k is also ok-to-dup - (b) if dup = OkToDup or Simplified, the subst-env is empty - (and hence no need to re-simplify) + (b) if dup = OkToDup or Simplified, the subst-env is empty, + or at least is always ignored; the payload is + already an OutThing -} instance Outputable DupFlag where @@ -309,7 +314,8 @@ data ArgInfo ai_fun :: OutId, -- The function ai_args :: [ArgSpec], -- ...applied to these args (which are in *reverse* order) - ai_rules :: FunRules, -- Rules for this function + ai_rewrite :: RewriteCall, -- What transformation to try next for this call + -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration ai_encl :: Bool, -- Flag saying whether this function -- or an enclosing one has rules (recursively) @@ -325,6 +331,12 @@ data ArgInfo -- Always infinite } +data RewriteCall -- What rewriting to try next for this call + -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration + = TryRules FullArgCount [CoreRule] + | TryInlining + | TryNothing + data ArgSpec = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal @@ -349,20 +361,20 @@ instance Outputable ArgSpec where addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo addValArgTo ai arg hole_ty - | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai + | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rewrite = rew } <- ai -- Pop the top demand and and discounts off , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } - = ai { ai_args = arg_spec : ai_args ai - , ai_dmds = dmds - , ai_discs = discs - , ai_rules = decRules rules } + = ai { ai_args = arg_spec : ai_args ai + , ai_dmds = dmds + , ai_discs = discs + , ai_rewrite = decArgCount rew } | otherwise = pprPanic "addValArgTo" (ppr ai $$ ppr arg) -- There should always be enough demands and discounts addTyArgTo :: ArgInfo -> OutType -> OutType -> ArgInfo -addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai - , ai_rules = decRules (ai_rules ai) } +addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai + , ai_rewrite = decArgCount (ai_rewrite ai) } where arg_spec = TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } @@ -381,19 +393,22 @@ argInfoAppArgs (CastBy {} : _) = [] -- Stop at a cast argInfoAppArgs (ValArg { as_arg = arg } : as) = arg : argInfoAppArgs as argInfoAppArgs (TyArg { as_arg_ty = ty } : as) = Type ty : argInfoAppArgs as -pushSimplifiedArgs :: SimplEnv -> [ArgSpec] -> SimplCont -> SimplCont -pushSimplifiedArgs _env [] k = k -pushSimplifiedArgs env (arg : args) k - = case arg of - TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } - -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty } - -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest } - CastBy c -> CastIt c rest - where - rest = pushSimplifiedArgs env args k - -- The env has an empty SubstEnv +pushSimplifiedArgs, pushSimplifiedRevArgs + :: SimplEnv + -> [ArgSpec] -- In normal, forward order for pushSimplifiedArgs, + -- in /reverse/ order for pushSimplifiedRevArgs + -> SimplCont -> SimplCont +pushSimplifiedArgs env args cont = foldr (pushSimplifiedArg env) cont args +pushSimplifiedRevArgs env args cont = foldl (\k a -> pushSimplifiedArg env a k) cont args + +pushSimplifiedArg :: SimplEnv -> ArgSpec -> SimplCont -> SimplCont +pushSimplifiedArg _env (TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty }) cont + = ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = cont } +pushSimplifiedArg env (ValArg { as_arg = arg, as_hole_ty = hole_ty }) cont + = ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified + -- The SubstEnv will be ignored since sc_dup=Simplified + , sc_hole_ty = hole_ty, sc_cont = cont } +pushSimplifiedArg _ (CastBy c) cont = CastIt c cont argInfoExpr :: OutId -> [ArgSpec] -> OutExpr -- NB: the [ArgSpec] is reversed so that the first arg @@ -406,18 +421,14 @@ argInfoExpr fun rev_args go (TyArg { as_arg_ty = ty } : as) = go as `App` Type ty go (CastBy co : as) = mkCast (go as) co +decArgCount :: RewriteCall -> RewriteCall +decArgCount (TryRules n rules) = TryRules (n-1) rules +decArgCount rew = rew -type FunRules = Maybe (Int, [CoreRule]) -- Remaining rules for this function - -- Nothing => No rules - -- Just (n, rules) => some rules, requiring at least n more type/value args - -decRules :: FunRules -> FunRules -decRules (Just (n, rules)) = Just (n-1, rules) -decRules Nothing = Nothing - -mkFunRules :: [CoreRule] -> FunRules -mkFunRules [] = Nothing -mkFunRules rs = Just (n_required, rs) +mkTryRules :: [CoreRule] -> RewriteCall +-- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration +mkTryRules [] = TryInlining +mkTryRules rs = TryRules n_required rs where n_required = maximum (map ruleArity rs) @@ -516,6 +527,7 @@ contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k + ------------------- countArgs :: SimplCont -> Int -- Count all arguments, including types, coercions, @@ -525,6 +537,14 @@ countArgs (ApplyToVal { sc_cont = cont }) = 1 + countArgs cont countArgs (CastIt _ cont) = countArgs cont countArgs _ = 0 +countValArgs :: SimplCont -> Int +-- Count value arguments only +countValArgs (ApplyToTy { sc_cont = cont }) = 1 + countValArgs cont +countValArgs (ApplyToVal { sc_cont = cont }) = 1 + countValArgs cont +countValArgs (CastIt _ cont) = countValArgs cont +countValArgs _ = 0 + +------------------- contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont) -- Summarises value args, discards type args and coercions -- The returned continuation of the call is only used to @@ -579,29 +599,26 @@ contEvalContext k = case k of -- and case binder dmds, see addCaseBndrDmd. No priority right now. ------------------- -mkArgInfo :: SimplEnv - -> Id - -> [CoreRule] -- Rules for function - -> Int -- Number of value args - -> SimplCont -- Context of the call - -> ArgInfo - -mkArgInfo env fun rules n_val_args call_cont +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_rules = fun_rules + , ai_rewrite = fun_rules , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rules = fun_rules - , ai_encl = interestingArgContext rules call_cont + , ai_rewrite = fun_rules + , ai_encl = notNull rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - fun_rules = mkFunRules rules + rules = getRules rule_base fun + fun_rules = mkTryRules rules + n_val_args = countValArgs cont vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 @@ -814,7 +831,7 @@ interestingCallContext env cont -- a build it's *great* to inline it here. So we must ensure that -- the context for (f x) is not totally uninteresting. -interestingArgContext :: [CoreRule] -> SimplCont -> Bool +contHasRules :: SimplCont -> Bool -- If the argument has form (f x y), where x,y are boring, -- and f is marked INLINE, then we don't want to inline f. -- But if the context of the argument is @@ -822,33 +839,29 @@ interestingArgContext :: [CoreRule] -> SimplCont -> Bool -- where g has rules, then we *do* want to inline f, in case it -- exposes a rule that might fire. Similarly, if the context is -- h (g (f x x)) --- where h has rules, then we do want to inline f; hence the --- call_cont argument to interestingArgContext +-- where h has rules, then we do want to inline f. So contHasRules +-- tries to see if the context of the f-call is a call to a function +-- with rules. -- --- The ai-rules flag makes this happen; if it's +-- The ai_encl flag makes this happen; if it's -- set, the inliner gets just enough keener to inline f -- regardless of how boring f's arguments are, if it's marked INLINE -- -- The alternative would be to *always* inline an INLINE function, -- regardless of how boring its context is; but that seems overkill -- For example, it'd mean that wrapper functions were always inlined --- --- The call_cont passed to interestingArgContext is the context of --- the call itself, e.g. g in the example above -interestingArgContext rules call_cont - = notNull rules || enclosing_fn_has_rules +contHasRules cont + = go cont where - enclosing_fn_has_rules = go call_cont - - go (Select {}) = False - go (ApplyToVal {}) = False -- Shouldn't really happen - go (ApplyToTy {}) = False -- Ditto - go (StrictArg { sc_fun = fun }) = ai_encl fun - go (StrictBind {}) = False -- ?? - go (CastIt _ c) = go c - go (Stop _ RuleArgCtxt _) = True - go (Stop _ _ _) = False - go (TickIt _ c) = go c + go (ApplyToVal { sc_cont = cont }) = go cont + go (ApplyToTy { sc_cont = cont }) = go cont + go (CastIt _ cont) = go cont + go (StrictArg { sc_fun = fun }) = ai_encl fun + go (Stop _ RuleArgCtxt _) = True + go (TickIt _ c) = go c + go (Select {}) = False + go (StrictBind {}) = False -- ?? + go (Stop _ _ _) = False {- Note [Interesting arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/lib/integer/Makefile ===================================== @@ -11,8 +11,9 @@ CHECK2 = grep -q -- '$1' folding.simpl || \ .PHONY: integerConstantFolding integerConstantFolding: - '$(TEST_HC)' -Wall -v0 -O --make integerConstantFolding -fforce-recomp -ddump-simpl > folding.simpl + '$(TEST_HC)' -Wall -v0 -O --make integerConstantFolding -fforce-recomp -ddump-simpl -dno-debug-output > folding.simpl # All the 100nnn values should be constant-folded away +# -dno-debug-output suppresses a "Glomming" message ! grep -q '\<100[0-9][0-9][0-9]\>' folding.simpl || { echo "Unfolded values found"; grep '\<100[0-9][0-9][0-9]\>' folding.simpl; } $(call CHECK,\<200007\>,plusInteger) $(call CHECK,\<683234160\>,timesInteger) @@ -64,8 +65,9 @@ IntegerConversionRules: .PHONY: naturalConstantFolding naturalConstantFolding: - '$(TEST_HC)' -Wall -v0 -O --make naturalConstantFolding -fforce-recomp -ddump-simpl > folding.simpl + '$(TEST_HC)' -Wall -v0 -O --make naturalConstantFolding -fforce-recomp -ddump-simpl -dno-debug-output > folding.simpl # All the 100nnn values should be constant-folded away +# -dno-debug-output suppresses a "Glomming" message ! grep -q '\<100[0-9][0-9][0-9]\>' folding.simpl || { echo "Unfolded values found"; grep '\<100[0-9][0-9][0-9]\>' folding.simpl; } # Bit arithmetic $(call CHECK,\<532\>,andNatural) ===================================== testsuite/tests/simplCore/should_compile/T21851.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -ddump-simpl #-} + +module T21851 (g') where +import T21851a + +g :: Num a => a -> a +g x = fst (f x) +{-# NOINLINE[99] g #-} + +g' :: Int -> Int +g' = g + +-- We should see a call to a /specialised/ verion of `f`, +-- something like +-- g' = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -0,0 +1,19 @@ +[1 of 2] Compiling T21851a ( T21851a.hs, T21851a.o ) +[2 of 2] Compiling T21851 ( T21851.hs, T21851.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 7, types: 10, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 6, types: 8, coercions: 0, joins: 0/0} +g' :: Int -> Int +[GblId, + Arity=1, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] +g' + = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + + + ===================================== testsuite/tests/simplCore/should_compile/T21851a.hs ===================================== @@ -0,0 +1,5 @@ +module T21851a where + +f :: Num b => b -> (b, b) -- note: recursive to prevent inlining +f x = (x + 1, snd (f x)) -- on such a small example +{-# SPECIALIZE f :: Int -> (Int, Int) #-} ===================================== testsuite/tests/simplCore/should_compile/T6056.stderr ===================================== @@ -1,4 +1,4 @@ Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) -Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) +Rule fired: SPEC/T6056 smallerAndRest @Int (T6056) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -430,3 +430,5 @@ test('T22028', normal, compile, ['-O -ddump-rule-firings']) test('T22114', normal, compile, ['-O']) test('T21286', normal, multimod_compile, ['T21286', '-O -ddump-rule-firings']) +# One module, T21851.hs, has OPTIONS_GHC -ddump-simpl +test('T21851', [grep_errmsg(r'case.*w\$sf') ], multimod_compile, ['T21851', '-O -dno-typeable-binds -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a6009bbc22049cce35ddebcb3aed22f6737aac83 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a6009bbc22049cce35ddebcb3aed22f6737aac83 You're receiving 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 Sep 28 22:55:23 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 28 Sep 2022 18:55:23 -0400 Subject: [Git][ghc/ghc][wip/T21623] 9 commits: Apply some tricks to speed up core lint. Message-ID: <6334d0dbd2699_2c97575143c8446f9@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 6642e892 by Simon Peyton Jones at 2022-09-28T23:26:39+01: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 - - - - - 60388ccc by Simon Peyton Jones at 2022-09-28T23:54:58+01:00 Wibbles - - - - - 18 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/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs - compiler/GHC/Core/DataCon.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/83c2c74a1800e1fb9535413fa18976b84ad6295e...60388ccc9989a1f2bb59678b19eb2566e9a5173c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/83c2c74a1800e1fb9535413fa18976b84ad6295e...60388ccc9989a1f2bb59678b19eb2566e9a5173c You're receiving 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 Sep 29 00:21:58 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 20:21:58 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Improve aggressive specialisation Message-ID: <6334e52673a9_2c9757514288507f3@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - efbf22c2 by M Farkas-Dyck at 2022-09-28T20:21:44-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - ba417041 by Bodigrim at 2022-09-28T20:21:47-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 30 changed files: - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/C.hs - compiler/GHC/HsToCore/Match/Constructor.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Names.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee99a72eb6f5ade78f6424359b36f3319fdf040f...ba417041c4254947254307013e95a23ef4dde13a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee99a72eb6f5ade78f6424359b36f3319fdf040f...ba417041c4254947254307013e95a23ef4dde13a You're receiving 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 Sep 29 02:52:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 22:52:13 -0400 Subject: [Git][ghc/ghc][master] Clean up `findWiredInUnit`. In particular, avoid `head`. Message-ID: <6335085dec531_2c9757514788668ce@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 1 changed file: - compiler/GHC/Unit/State.hs Changes: ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -1105,31 +1105,29 @@ findWiredInUnits logger prec_map pkgs vis_map = do -- available. -- findWiredInUnit :: [UnitInfo] -> UnitId -> IO (Maybe (UnitId, UnitInfo)) - findWiredInUnit pkgs wired_pkg = - let all_ps = [ p | p <- pkgs, p `matches` wired_pkg ] - all_exposed_ps = - [ p | p <- all_ps - , Map.member (mkUnit p) vis_map ] in - case all_exposed_ps of - [] -> case all_ps of - [] -> notfound - many -> pick (head (sortByPreference prec_map many)) - many -> pick (head (sortByPreference prec_map many)) + findWiredInUnit pkgs wired_pkg = firstJustsM [try all_exposed_ps, try all_ps, notfound] where + all_ps = [ p | p <- pkgs, p `matches` wired_pkg ] + all_exposed_ps = [ p | p <- all_ps, Map.member (mkUnit p) vis_map ] + + try ps = case sortByPreference prec_map ps of + p:_ -> Just <$> pick p + _ -> pure Nothing + notfound = do debugTraceMsg logger 2 $ text "wired-in package " <> ftext (unitIdFS wired_pkg) <> text " not found." return Nothing - pick :: UnitInfo -> IO (Maybe (UnitId, UnitInfo)) + pick :: UnitInfo -> IO (UnitId, UnitInfo) pick pkg = do debugTraceMsg logger 2 $ text "wired-in package " <> ftext (unitIdFS wired_pkg) <> text " mapped to " <> ppr (unitId pkg) - return (Just (wired_pkg, pkg)) + return (wired_pkg, pkg) mb_wired_in_pkgs <- mapM (findWiredInUnit pkgs) wiredInUnitIds View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bc0020fa0871aff23d26b0116c1d4e43b8a3e9a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bc0020fa0871aff23d26b0116c1d4e43b8a3e9a9 You're receiving 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 Sep 29 02:52:48 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 28 Sep 2022 22:52:48 -0400 Subject: [Git][ghc/ghc][master] Eliminate headFS, use unconsFS instead Message-ID: <633508801935c_2c97572ed3bc7886745d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - 3 changed files: - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Utils/Lexeme.hs Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -82,7 +82,6 @@ module GHC.Data.FastString lengthFS, nullFS, appendFS, - headFS, concatFS, consFS, nilFS, @@ -609,11 +608,6 @@ appendFS fs1 fs2 = mkFastStringShortByteString concatFS :: [FastString] -> FastString concatFS = mkFastStringShortByteString . mconcat . map fs_sbs -headFS :: FastString -> Char -headFS fs - | SBS.null $ fs_sbs fs = panic "headFS: Empty FastString" -headFS fs = head $ unpackFS fs - consFS :: Char -> FastString -> FastString consFS c fs = mkFastString (c : unpackFS fs) ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -519,7 +519,9 @@ parenSymOcc occ doc | isSymOcc occ = parens doc startsWithUnderscore :: OccName -> Bool -- ^ Haskell 98 encourages compilers to suppress warnings about unused -- names in a pattern if they start with @_@: this implements that test -startsWithUnderscore occ = headFS (occNameFS occ) == '_' +startsWithUnderscore occ = case unconsFS (occNameFS occ) of + Just ('_', _) -> True + _ -> False {- ************************************************************************ ===================================== compiler/GHC/Utils/Lexeme.hs ===================================== @@ -67,19 +67,17 @@ isLexId cs = isLexConId cs || isLexVarId cs isLexSym cs = isLexConSym cs || isLexVarSym cs ------------- -isLexConId cs -- Prefix type or data constructors - | nullFS cs = False -- e.g. "Foo", "[]", "(,)" - | cs == (fsLit "[]") = True - | otherwise = startsConId (headFS cs) - -isLexVarId cs -- Ordinary prefix identifiers - | nullFS cs = False -- e.g. "x", "_x" - | otherwise = startsVarId (headFS cs) - -isLexConSym cs -- Infix type or data constructors - | nullFS cs = False -- e.g. ":-:", ":", "->" - | cs == (fsLit "->") = True - | otherwise = startsConSym (headFS cs) +isLexConId cs = case unconsFS cs of -- Prefix type or data constructors + Nothing -> False -- e.g. "Foo", "[]", "(,)" + Just (c, _) -> cs == fsLit "[]" || startsConId c + +isLexVarId cs = case unconsFS cs of -- Ordinary prefix identifiers + Nothing -> False -- e.g. "x", "_x" + Just (c, _) -> startsVarId c + +isLexConSym cs = case unconsFS cs of -- Infix type or data constructors + Nothing -> False -- e.g. ":-:", ":", "->" + Just (c, _) -> cs == fsLit "->" || startsConSym c isLexVarSym fs -- Infix identifiers e.g. "+" | fs == (fsLit "~R#") = True View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a2eec98d9f5c3f5d735042f0d7bb65d0dbb3323 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a2eec98d9f5c3f5d735042f0d7bb65d0dbb3323 You're receiving 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 Sep 29 07:42:39 2022 From: gitlab at gitlab.haskell.org (Luite Stegeman (@luite)) Date: Thu, 29 Sep 2022 03:42:39 -0400 Subject: [Git][ghc/ghc][wip/ghci-primcall] move note to prepare for docs in different place Message-ID: <63354c6f91f06_2c975753ffac890073@gitlab.mail> Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC Commits: 66466845 by Luite Stegeman at 2022-09-29T09:42:01+02:00 move note to prepare for docs in different place §§ - - - - - 2 changed files: - rts/StgMiscClosures.cmm - testsuite/tests/linters/notes.stdout Changes: ===================================== rts/StgMiscClosures.cmm ===================================== @@ -407,8 +407,6 @@ INFO_TABLE_RET( stg_ret_t, RET_BCO ) /* - Note [GHCi prim calling convention] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The stg_primcall frame is used by the bytecode interpreter to call a Cmm function. The frame contains an args_info word that contains ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -55,7 +55,6 @@ ref hadrian/src/Expression.hs:130:30: Note [Linking ghc-bin against threa ref libraries/base/GHC/ST.hs:134:7: Note [Definition of runRW#] ref linters/lint-notes/Notes.hs:32:29: Note [" <> T.unpack x <> "] ref linters/lint-notes/Notes.hs:69:22: Note [...] -ref rts/StgMiscClosures.cmm:410:4: Note [GHCi prim calling convention] ref testsuite/config/ghc:243:10: Note [WayFlags] ref testsuite/driver/testlib.py:153:10: Note [Why is there no stage1 setup function?] ref testsuite/driver/testlib.py:157:2: Note [Why is there no stage1 setup function?] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66466845060d02dbf9202241b7bf878d8d931060 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/66466845060d02dbf9202241b7bf878d8d931060 You're receiving 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 Sep 29 08:31:18 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 29 Sep 2022 04:31:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/revert-parallel-xz Message-ID: <633557d6a653f_2c9757514148942c9@gitlab.mail> Bryan R pushed new branch wip/revert-parallel-xz at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/revert-parallel-xz You're receiving 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 Sep 29 09:36:29 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 29 Sep 2022 05:36:29 -0400 Subject: [Git][ghc/ghc][wip/T21623] Unused import Message-ID: <6335671deac78_2c97575147889958c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 44872709 by Simon Peyton Jones at 2022-09-29T10:38:29+01:00 Unused import - - - - - 1 changed file: - compiler/GHC/Core/Type.hs Changes: ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -289,7 +289,6 @@ import GHC.Utils.Panic.Plain import GHC.Data.FastString import Control.Monad ( guard ) -import qualified Data.Semigroup as S import GHC.Data.Maybe ( orElse, isJust ) -- $type_classification View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44872709da3afe3776e036799edd9e7082be7421 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44872709da3afe3776e036799edd9e7082be7421 You're receiving 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 Sep 29 10:51:11 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 29 Sep 2022 06:51:11 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Disable compact tests Message-ID: <6335789f3ff27_2c97575148c92278b@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: e8c8ddd6 by Sylvain Henry at 2022-09-29T12:54:26+02:00 Disable compact tests - - - - - 1 changed file: - libraries/ghc-compact/tests/all.T Changes: ===================================== libraries/ghc-compact/tests/all.T ===================================== @@ -1,4 +1,7 @@ -setTestOpts(extra_ways(['sanity', 'compacting_gc'])) +setTestOpts( + [extra_ways(['sanity', 'compacting_gc']), + js_skip # compact API not supported by the JS backend + ]) test('compact_simple', normal, compile_and_run, ['']) test('compact_loop', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8c8ddd6a8436310d1d459f3a13211eeb5808cbd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8c8ddd6a8436310d1d459f3a13211eeb5808cbd You're receiving 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 Sep 29 12:58:23 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 29 Sep 2022 08:58:23 -0400 Subject: [Git][ghc/ghc][wip/T21623] 6 commits: Clean up `findWiredInUnit`. In particular, avoid `head`. Message-ID: <6335966f93045_2c975742bcfe20950930@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - bf652a16 by Simon Peyton Jones at 2022-09-29T14:00:32+01: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 - - - - - 189126ce by Simon Peyton Jones at 2022-09-29T14:00:32+01:00 Wibbles - - - - - 775422ff by Simon Peyton Jones at 2022-09-29T14:00:32+01:00 Unused import - - - - - 0aab4365 by Simon Peyton Jones at 2022-09-29T14:00:32+01:00 Better boxingCon_maybe - - - - - 16 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 - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44872709da3afe3776e036799edd9e7082be7421...0aab4365d4dbc78941dce0bd83ec6ac3f0eae02d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/44872709da3afe3776e036799edd9e7082be7421...0aab4365d4dbc78941dce0bd83ec6ac3f0eae02d You're receiving 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 Sep 29 13:58:06 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Thu, 29 Sep 2022 09:58:06 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/nr/wasm-translation-prototypes Message-ID: <6335a46e5b857_2c97572ed3bc78971125@gitlab.mail> Norman Ramsey pushed new branch wip/nr/wasm-translation-prototypes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/nr/wasm-translation-prototypes You're receiving 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 Sep 29 14:18:42 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 29 Sep 2022 10:18:42 -0400 Subject: [Git][ghc/ghc][wip/T22084] 2 commits: Don't keep exit join points so much Message-ID: <6335a94267eb5_2c9757dfd409731d0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22084 at Glasgow Haskell Compiler / GHC Commits: 8eaa813d by Simon Peyton Jones at 2022-09-28T09:37:42+01: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 arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). It's not a big deal, but it shaves 0.1% off compile times. - - - - - ac9987f3 by Simon Peyton Jones at 2022-09-29T15:20:01+01:00 Inline used-once non-recursive join points very aggressively - - - - - 9 changed files: - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - + testsuite/tests/simplCore/should_compile/T21148.hs - + testsuite/tests/simplCore/should_compile/T21148.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Exitify.hs ===================================== @@ -433,6 +433,7 @@ inlining. Exit join points, recognizable using `isExitJoinId` are join points with an occurrence in a recursive group, and can be recognized (after the occurrence analyzer ran!) using `isExitJoinId`. + This function detects joinpoints with `occ_in_lam (idOccinfo id) == True`, because the lambdas of a non-recursive join point are not considered for `occ_in_lam`. For example, in the following code, `j1` is /not/ marked @@ -446,6 +447,29 @@ To prevent inlining, we check for isExitJoinId * In `simplLetUnfolding` we simply give exit join points no unfolding, which prevents inlining in `postInlineUnconditionally` and call sites. +But see Note [Be selective about not-inlining exit join points] + +Note [Be selective about not-inlining exit join points] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If we follow "do not inline exit join points" mantra throughout, +some bad things happen. + +* We can lose CPR information: see #21148 + +* We get useless clutter (#22084) that + - makes the program bigger (including duplicated code #20739), and + - adds extra jumps (and maybe stack saves) at runtime + +So instead we follow "do not inline exit join points" for a /single run/ +of the simplifier, right after Exitification. That should give a +sufficient chance for used-once things to inline, but subsequent runs +will inline them back in. (Annoyingly, as things stand, only with -O2 +is there a subsequent run, but that might change, and it's not a huge +deal anyway.) + +This is controlled by the Simplifier's sm_keep_exits flag; see +GHC.Core.Opt.Pipeline. + Note [Placement of the exitification pass] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I (Joachim) experimented with multiple positions for the Exitification pass in ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -15,7 +15,7 @@ import GHC.Driver.Plugins ( withPlugins, installCoreToDos ) import GHC.Driver.Env import GHC.Driver.Config.Core.Lint ( endPass ) import GHC.Driver.Config.Core.Opt.LiberateCase ( initLiberateCaseOpts ) -import GHC.Driver.Config.Core.Opt.Simplify ( initSimplifyOpts, initSimplMode, initGentleSimplMode ) +import GHC.Driver.Config.Core.Opt.Simplify ( initSimplifyOpts, initSimplMode ) import GHC.Driver.Config.Core.Opt.WorkWrap ( initWorkWrapOpts ) import GHC.Driver.Config.Core.Rules ( initRuleOpts ) import GHC.Platform.Ways ( hasWay, Way(WayProf) ) @@ -28,6 +28,7 @@ import GHC.Core.Utils ( dumpIdInfoOfProgram ) import GHC.Core.Lint ( lintAnnots ) import GHC.Core.Lint.Interactive ( interactiveInScope ) import GHC.Core.Opt.Simplify ( simplifyExpr, simplifyPgm ) +import GHC.Core.Opt.Simplify.Env( SimplMode(..) ) import GHC.Core.Opt.Simplify.Monad import GHC.Core.Opt.Monad import GHC.Core.Opt.Pipeline.Types @@ -154,32 +155,45 @@ getCoreToDo dflags rule_base extra_vars maybe_strictness_before _ = CoreDoNothing - simpl_phase phase name iter - = CoreDoPasses - $ [ maybe_strictness_before phase - , CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter - (initSimplMode dflags phase name) rule_base - , maybe_rule_check phase ] + ---------------------------- + base_simpl_mode :: SimplMode + base_simpl_mode = initSimplMode dflags - -- Run GHC's internal simplification phase, after all rules have run. - -- See Note [Compiler phases] in GHC.Types.Basic - simplify name = simpl_phase FinalPhase name max_iter - - -- initial simplify: mk specialiser happy: minimum effort please + -- gentle_mode: make specialiser happy: minimum effort please -- See Note [Inline in InitialPhase] -- See Note [RULEs enabled in InitialPhase] - simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter - (initGentleSimplMode dflags) rule_base + gentle_mode = base_simpl_mode { sm_names = ["Gentle"] + , sm_phase = InitialPhase + , sm_case_case = False } + + simpl_mode phase name + = base_simpl_mode { sm_names = [name], sm_phase = phase } + + keep_exits :: SimplMode -> SimplMode + -- See Note [Be selective about not-inlining exit join points] + -- in GHC.Core.Opt.Exitify + keep_exits mode = mode { sm_keep_exits = True } + + ---------------------------- + run_simplifier mode iter + = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode rule_base + simpl_phase phase name iter = CoreDoPasses $ + [ maybe_strictness_before phase + , run_simplifier (simpl_mode phase name) iter + , maybe_rule_check phase ] + + -- Run GHC's internal simplification phase, after all rules have run. + -- See Note [Compiler phases] in GHC.Types.Basic + simpl_gently = run_simplifier gentle_mode max_iter + simplify_final name = run_simplifier ( simpl_mode FinalPhase name) max_iter + simpl_keep_exits name = run_simplifier (keep_exits $ simpl_mode FinalPhase name) max_iter + + ---------------------------- dmd_cpr_ww = if ww_on then [CoreDoDemand,CoreDoCpr,CoreDoWorkerWrapper] else [CoreDoDemand,CoreDoCpr] - demand_analyser = (CoreDoPasses ( - dmd_cpr_ww ++ - [simplify "post-worker-wrapper"] - )) - -- Static forms are moved to the top level with the FloatOut pass. -- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable. static_ptrs_float_outwards = @@ -269,14 +283,16 @@ getCoreToDo dflags rule_base extra_vars runWhen call_arity $ CoreDoPasses [ CoreDoCallArity - , simplify "post-call-arity" + , simplify_final "post-call-arity" ], -- Strictness analysis - runWhen strictness demand_analyser, + runWhen strictness $ CoreDoPasses + (dmd_cpr_ww ++ [simplify_final "post-worker-wrapper"]), runWhen exitification CoreDoExitify, -- See Note [Placement of the exitification pass] + -- in GHC.Core.Opt.Exitify runWhen full_laziness $ CoreDoFloatOutwards FloatOutSwitches { @@ -298,7 +314,17 @@ getCoreToDo dflags rule_base extra_vars runWhen do_float_in CoreDoFloatInwards, - simplify "final", -- Final tidy-up + -- Final tidy-up run of the simplifier + simpl_keep_exits "final tidy up", + -- Keep exit join point because this is the first + -- Simplifier run after Exitify. Subsequent runs will + -- re-inline those exit join points; their work is done. + -- See Note [Be selective about not-inlining exit join points] + -- in GHC.Core.Opt.Exitify + -- + -- Annoyingly, we only /have/ a subsequent run with -O2. With + -- plain -O we'll still have those exit join points hanging around. + -- Oh well. maybe_rule_check FinalPhase, @@ -308,31 +334,31 @@ getCoreToDo dflags rule_base extra_vars -- Case-liberation for -O2. This should be after -- strictness analysis and the simplification which follows it. runWhen liberate_case $ CoreDoPasses - [ CoreLiberateCase, simplify "post-liberate-case" ], + [ CoreLiberateCase, simplify_final "post-liberate-case" ], -- Run the simplifier after LiberateCase to vastly -- reduce the possibility of shadowing -- Reason: see Note [Shadowing] in GHC.Core.Opt.SpecConstr runWhen spec_constr $ CoreDoPasses - [ CoreDoSpecConstr, simplify "post-spec-constr"], + [ CoreDoSpecConstr, simplify_final "post-spec-constr"], -- See Note [Simplify after SpecConstr] maybe_rule_check FinalPhase, runWhen late_specialise $ CoreDoPasses - [ CoreDoSpecialising, simplify "post-late-spec"], + [ CoreDoSpecialising, simplify_final "post-late-spec"], -- LiberateCase can yield new CSE opportunities because it peels -- off one layer of a recursive function (concretely, I saw this -- in wheel-sieve1), and I'm guessing that SpecConstr can too -- And CSE is a very cheap pass. So it seems worth doing here. runWhen ((liberate_case || spec_constr) && cse) $ CoreDoPasses - [ CoreCSE, simplify "post-final-cse" ], + [ CoreCSE, simplify_final "post-final-cse" ], --------- End of -O2 passes -------------- runWhen late_dmd_anal $ CoreDoPasses ( - dmd_cpr_ww ++ [simplify "post-late-ww"] + dmd_cpr_ww ++ [simplify_final "post-late-ww"] ), -- Final run of the demand_analyser, ensures that one-shot thunks are ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -248,13 +248,16 @@ data SimplMode = SimplMode -- See comments in GHC.Core.Opt.Simplify.Monad , sm_uf_opts :: !UnfoldingOpts -- ^ Unfolding options , sm_case_case :: !Bool -- ^ Whether case-of-case is enabled , sm_pre_inline :: !Bool -- ^ Whether pre-inlining is enabled - , sm_float_enable :: !FloatEnable -- ^ Whether to enable floating out + , sm_keep_exits :: !Bool -- ^ True <=> keep ExitJoinIds + -- See Note [Do not inline exit join points] + -- in GHC.Core.Opt.Exitify + , sm_float_enable :: !FloatEnable -- ^ Whether to enable floating out , sm_do_eta_reduction :: !Bool - , sm_arity_opts :: !ArityOpts - , sm_rule_opts :: !RuleOpts - , sm_case_folding :: !Bool - , sm_case_merge :: !Bool - , sm_co_opt_opts :: !OptCoercionOpts -- ^ Coercion optimiser options + , sm_arity_opts :: !ArityOpts + , sm_rule_opts :: !RuleOpts + , sm_case_folding :: !Bool + , sm_case_merge :: !Bool + , sm_co_opt_opts :: !OptCoercionOpts -- ^ Coercion optimiser options } instance Outputable SimplMode where ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1320,11 +1320,11 @@ preInlineUnconditionally -- Reason: we don't want to inline single uses, or discard dead bindings, -- for unlifted, side-effect-ful bindings preInlineUnconditionally env top_lvl bndr rhs rhs_env - | not pre_inline_unconditionally = Nothing + | not pre_inline = Nothing | not active = Nothing | isTopLevel top_lvl && isDeadEndId bndr = Nothing -- Note [Top-level bottoming Ids] | isCoVar bndr = Nothing -- Note [Do not inline CoVars unconditionally] - | isExitJoinId bndr = Nothing -- Note [Do not inline exit join points] + | keep_exits, isExitJoinId bndr = Nothing -- Note [Do not inline exit join points] -- in module Exitify | not (one_occ (idOccInfo bndr)) = Nothing | not (isStableUnfolding unf) = Just $! (extend_subst_with rhs) @@ -1334,19 +1334,31 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env , Just inl <- maybeUnfoldingTemplate unf = Just $! (extend_subst_with inl) | otherwise = Nothing where + mode = seMode env + phase = sm_phase mode + keep_exits = sm_keep_exits mode + pre_inline = sm_pre_inline mode + unf = idUnfolding bndr extend_subst_with inl_rhs = extendIdSubst env bndr $! (mkContEx rhs_env inl_rhs) one_occ IAmDead = True -- Happens in ((\x.1) v) + one_occ OneOcc{ occ_n_br = 1 , occ_in_lam = NotInsideLam } = isNotTopLevel top_lvl || early_phase + one_occ OneOcc{ occ_n_br = 1 , occ_in_lam = IsInsideLam , occ_int_cxt = IsInteresting } = canInlineInLam rhs - one_occ _ = False - pre_inline_unconditionally = sePreInline env - active = isActive (sePhase env) (inlinePragmaActivation inline_prag) + one_occ OneOcc{ occ_n_br = 1 } -- Inline join point that are used once, even inside + | isJoinId bndr = True -- lambdas (which are presumably other join points) + -- Also for join points the IsInteresting doesn't matter; a nullary + -- join point is just the same as an arity-2 one. + + one_occ _ = False + + active = isActive phase (inlinePragmaActivation inline_prag) -- See Note [pre/postInlineUnconditionally in gentle mode] inline_prag = idInlinePragma bndr @@ -1378,7 +1390,7 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env -- not ticks. Counting ticks cannot be duplicated, and non-counting -- ticks around a Lam will disappear anyway. - early_phase = sePhase env /= FinalPhase + early_phase = phase /= FinalPhase -- If we don't have this early_phase test, consider -- x = length [1,2,3] -- The full laziness pass carefully floats all the cons cells to ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1512,8 +1512,10 @@ scExpr' env (Case scrut b ty alts) scrut_occ = case con of DataAlt dc -- See Note [Do not specialise evals] | not (single_alt && all deadArgOcc arg_occs) - -> ScrutOcc (unitUFM dc arg_occs) - _ -> UnkOcc + -> -- pprTrace "sc_alt1" (ppr b' $$ ppr con $$ ppr bs $$ ppr arg_occs) $ + ScrutOcc (unitUFM dc arg_occs) + _ -> -- pprTrace "sc_alt1" (ppr b' $$ ppr con $$ ppr bs $$ ppr arg_occs) $ + UnkOcc ; return (usg', b_occ `combineOcc` scrut_occ, Alt con bs2 rhs') } ===================================== compiler/GHC/Driver/Config/Core/Opt/Simplify.hs ===================================== @@ -2,7 +2,6 @@ module GHC.Driver.Config.Core.Opt.Simplify ( initSimplifyExprOpts , initSimplifyOpts , initSimplMode - , initGentleSimplMode ) where import GHC.Prelude @@ -27,12 +26,13 @@ import GHC.Types.Var ( Var ) initSimplifyExprOpts :: DynFlags -> InteractiveContext -> SimplifyExprOpts initSimplifyExprOpts dflags ic = SimplifyExprOpts { se_fam_inst = snd $ ic_instances ic - , se_mode = (initSimplMode dflags InitialPhase "GHCi") - { sm_inline = False - -- Do not do any inlining, in case we expose some - -- unboxed tuple stuff that confuses the bytecode + + , se_mode = (initSimplMode dflags) { sm_names = ["GHCi"] + , sm_inline = False } + -- sm_inline: do not do any inlining, in case we expose + -- some unboxed tuple stuff that confuses the bytecode -- interpreter - } + , se_top_env_cfg = TopEnvConfig { te_history_size = historySize dflags , te_tick_factor = simplTickFactor dflags @@ -57,31 +57,25 @@ initSimplifyOpts dflags extra_vars iterations mode rule_base = let } in opts -initSimplMode :: DynFlags -> CompilerPhase -> String -> SimplMode -initSimplMode dflags phase name = SimplMode - { sm_names = [name] - , sm_phase = phase - , sm_rules = gopt Opt_EnableRewriteRules dflags - , sm_eta_expand = gopt Opt_DoLambdaEtaExpansion dflags - , sm_cast_swizzle = True - , sm_inline = True - , sm_uf_opts = unfoldingOpts dflags - , sm_case_case = True - , sm_pre_inline = gopt Opt_SimplPreInlining dflags - , sm_float_enable = floatEnable dflags +initSimplMode :: DynFlags -> SimplMode +initSimplMode dflags = SimplMode + { sm_names = ["Unknown simplifier run"] -- Always overriden + , sm_phase = InitialPhase + , sm_rules = gopt Opt_EnableRewriteRules dflags + , sm_eta_expand = gopt Opt_DoLambdaEtaExpansion dflags + , sm_pre_inline = gopt Opt_SimplPreInlining dflags , sm_do_eta_reduction = gopt Opt_DoEtaReduction dflags - , sm_arity_opts = initArityOpts dflags - , sm_rule_opts = initRuleOpts dflags - , sm_case_folding = gopt Opt_CaseFolding dflags - , sm_case_merge = gopt Opt_CaseMerge dflags - , sm_co_opt_opts = initOptCoercionOpts dflags - } - -initGentleSimplMode :: DynFlags -> SimplMode -initGentleSimplMode dflags = (initSimplMode dflags InitialPhase "Gentle") - { -- Don't do case-of-case transformations. - -- This makes full laziness work better - sm_case_case = False + , sm_uf_opts = unfoldingOpts dflags + , sm_float_enable = floatEnable dflags + , sm_arity_opts = initArityOpts dflags + , sm_rule_opts = initRuleOpts dflags + , sm_case_folding = gopt Opt_CaseFolding dflags + , sm_case_merge = gopt Opt_CaseMerge dflags + , sm_co_opt_opts = initOptCoercionOpts dflags + , sm_cast_swizzle = True + , sm_inline = True + , sm_case_case = True + , sm_keep_exits = False } floatEnable :: DynFlags -> FloatEnable ===================================== testsuite/tests/simplCore/should_compile/T21148.hs ===================================== @@ -0,0 +1,12 @@ +module T211148 where + +-- The point of this test is that f should get a (nested) +-- CPR property, with a worker of type +-- $wf :: Int# -> State# RealWorld -> (# State# RealWorld, Int# #) + +{-# NOINLINE f #-} +-- The NOINLINE makes GHC do a worker/wrapper split +-- even though f is small +f :: Int -> IO Int +f x = return $! sum [0..x] + ===================================== testsuite/tests/simplCore/should_compile/T21148.stderr ===================================== @@ -0,0 +1 @@ + \ No newline at end of file ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -429,3 +429,4 @@ test('T21763', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) test('T21763a', only_ways(['optasm']), compile, ['-O2 -ddump-rules']) test('T22028', normal, compile, ['-O -ddump-rule-firings']) test('T22114', normal, compile, ['-O']) +test('T21148', [grep_errmsg(r'Cpr=') ], compile, ['-O -ddump-simpl']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bef9a55228552e85e26bba5ce782bbeb9404391c...ac9987f3ee3288fd2d0e4d5f6068323f9d9ccdd8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bef9a55228552e85e26bba5ce782bbeb9404391c...ac9987f3ee3288fd2d0e4d5f6068323f9d9ccdd8 You're receiving 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 Sep 29 14:20:10 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 29 Sep 2022 10:20:10 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Add support for JS files passed on the command line Message-ID: <6335a99a56508_2c97572ed3bc7897369c@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 5f549189 by Sylvain Henry at 2022-09-29T16:23:06+02:00 Add support for JS files passed on the command line - - - - - 7 changed files: - compiler/GHC/Driver/Pipeline.hs - − compiler/GHC/StgToJS/Linker/Dynamic.hs - compiler/GHC/StgToJS/Linker/Linker.hs - compiler/GHC/Utils/Monad.hs - compiler/ghc.cabal.in - testsuite/tests/ffi/should_run/all.T - + testsuite/tests/ffi/should_run/fptr01_js.js Changes: ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -79,7 +79,7 @@ import GHC.Linker.Static import GHC.Linker.Static.Utils import GHC.Linker.Types -import GHC.StgToJS.Linker.Dynamic +import GHC.StgToJS.Linker.Linker import GHC.Utils.Outputable import GHC.Utils.Error @@ -105,8 +105,6 @@ import GHC.Types.SrcLoc import GHC.Types.SourceFile import GHC.Types.SourceError -import GHC.StgToJS.Linker.Types ( newGhcjsEnv ) - import GHC.Unit import GHC.Unit.Env --import GHC.Unit.Finder @@ -445,11 +443,10 @@ link' logger tmpfs dflags unit_env batch_attempt_linking mHscMessager hpt case ghcLink dflags of LinkBinary | isJS -> do - js_env <- liftIO newGhcjsEnv let lc_cfg = mempty let extra_js = mempty let cfg = initStgToJSConfig dflags - jsLinkBinary js_env lc_cfg cfg extra_js logger tmpfs dflags unit_env obj_files pkg_deps + jsLinkBinary lc_cfg cfg extra_js logger tmpfs dflags unit_env obj_files pkg_deps | otherwise -> linkBinary logger tmpfs dflags unit_env obj_files pkg_deps LinkStaticLib -> linkStaticLib logger dflags unit_env obj_files pkg_deps LinkDynLib -> linkDynLibCheck logger tmpfs dflags unit_env obj_files pkg_deps @@ -572,11 +569,10 @@ doLink hsc_env o_files = do NoLink -> return () LinkBinary | isJS -> do - js_env <- liftIO newGhcjsEnv let lc_cfg = mempty let extra_js = mempty let cfg = initStgToJSConfig dflags - jsLinkBinary js_env lc_cfg cfg extra_js logger tmpfs dflags unit_env o_files [] + jsLinkBinary lc_cfg cfg extra_js logger tmpfs dflags unit_env o_files [] | otherwise -> linkBinary logger tmpfs dflags unit_env o_files [] LinkStaticLib -> linkStaticLib logger dflags unit_env o_files [] LinkDynLib -> linkDynLibCheck logger tmpfs dflags unit_env o_files [] ===================================== compiler/GHC/StgToJS/Linker/Dynamic.hs deleted ===================================== @@ -1,115 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE LambdaCase #-} - ------------------------------------------------------------------------------ --- | --- Module : GHC.StgToJS.Linker.Dynamic --- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file LICENSE) --- --- Maintainer : Jeffrey Young --- Luite Stegeman --- Sylvain Henry --- Josh Meredith --- Stability : experimental --- --- Various utilities for building and loading dynamic libraries, to make --- Template Haskell work in GHCJS ------------------------------------------------------------------------------ - -module GHC.StgToJS.Linker.Dynamic - ( jsLinkBinary - , jsLinkLib - ) -where - -import GHC.Driver.Session - -import GHC.StgToJS.Types -import GHC.StgToJS.Linker.Archive -import GHC.StgToJS.Linker.Types -import GHC.StgToJS.Linker.Utils -import qualified GHC.StgToJS.Linker.Linker as JSLink - -import GHC.Linker.Types - -import GHC.Unit.Module -import GHC.Unit.Module.ModIface - -import GHC.Types.Unique.DFM -import GHC.Types.Basic - -import GHC.Unit.Home.ModInfo -import GHC.Unit.Env - -import Prelude - -import Control.Monad - -import qualified Data.ByteString as BS -import Data.List ( nub ) - -import System.FilePath -import GHC.Platform.Ways -import GHC.Utils.Logger -import GHC.Utils.TmpFs (TmpFs) - ---------------------------------------------------------------------------------- --- Link libraries - -jsLinkLib :: JSLinkConfig - -> [FilePath] -- ^ extra JS files - -> DynFlags - -> Logger - -> HomePackageTable - -> IO SuccessFlag -jsLinkLib settings jsFiles dflags _logger hpt - | Just jsLib <- lcLinkJsLib settings = do - let profSuff | WayProf `elem` ways dflags = "_p" - | otherwise = "" - libFileName = ("lib" ++ jsLib ++ profSuff) <.> "js_a" - inOutputDir file = - maybe file - (file) - (lcJsLibOutputDir settings `mplus` objectDir dflags) - outputFile = inOutputDir libFileName - jsFiles' = nub (lcJsLibSrcs settings ++ jsFiles) - meta = Meta (opt_P dflags) - jsEntries <- forM jsFiles' $ \file -> - (JsSource file,) <$> BS.readFile file - objEntries <- forM (eltsUDFM hpt) $ \hmi -> do - let mod_name = moduleName . mi_module . hm_iface $ hmi - files = maybe [] (\l -> [ o | DotO o <- linkableUnlinked l]) (hm_linkable hmi) - -- fixme archive does not handle multiple files for a module yet - forM files (fmap ((Object mod_name,)) . BS.readFile) - writeArchive outputFile meta (concat objEntries ++ jsEntries) - -- we don't use shared js_so libraries ourselves, but Cabal expects that we - -- generate one when building with --dynamic-too. Just write an empty file - when (gopt Opt_BuildDynamicToo dflags || WayDyn `elem` ways dflags) $ do - let sharedLibFileName = - "lib" ++ jsLib ++ "-ghcjs" ++ getCompilerVersion ++ profSuff <.> "js_so" - sharedOutputFile = inOutputDir sharedLibFileName - -- keep strip happy - BS.writeFile sharedOutputFile =<< BS.readFile (topDir dflags "empty.o") - return Succeeded - | otherwise = - return Succeeded - -jsLinkBinary :: GhcjsEnv - -> JSLinkConfig - -> StgToJSConfig - -> [FilePath] - -> Logger - -> TmpFs - -> DynFlags - -> UnitEnv - -> [FilePath] - -> [UnitId] - -> IO () -jsLinkBinary env lc_cfg cfg jsFiles logger tmpfs dflags u_env objs dep_pkgs = - void $ JSLink.link env lc_cfg cfg logger tmpfs dflags u_env exe mempty dep_pkgs objs' jsFiles isRoot mempty - where - objs' = map ObjFile objs - isRoot _ = True - exe = jsExeFileName dflags ===================================== compiler/GHC/StgToJS/Linker/Linker.hs ===================================== @@ -21,7 +21,7 @@ ----------------------------------------------------------------------------- module GHC.StgToJS.Linker.Linker - ( link + ( jsLinkBinary ) where @@ -95,6 +95,8 @@ import GHC.Utils.Logger (Logger, logVerbAtLeast) import GHC.Utils.TmpFs (TmpFs) import GHC.Utils.Binary import GHC.Utils.Ppr (Style(..), renderStyle, Mode(..)) +import GHC.Utils.CliOption +import GHC.Utils.Monad import GHC.Linker.Static.Utils (exeFileName) @@ -119,6 +121,31 @@ newtype ArchiveState = ArchiveState { loadedArchives :: IORef (Map FilePath Ar.A emptyArchiveState :: IO ArchiveState emptyArchiveState = ArchiveState <$> newIORef M.empty +jsLinkBinary + :: JSLinkConfig + -> StgToJSConfig + -> [FilePath] + -> Logger + -> TmpFs + -> DynFlags + -> UnitEnv + -> [FilePath] + -> [UnitId] + -> IO () +jsLinkBinary lc_cfg cfg js_srcs logger tmpfs dflags u_env objs dep_pkgs = do + -- additional objects to link are passed as FileOption ldInputs... + let cmdline_objs = [ f | FileOption _ f <- ldInputs dflags ] + -- discriminate JavaScript sources from real object files. + (cmdline_js_srcs, cmdline_js_objs) <- partitionM isJsFile cmdline_objs + let + objs' = map ObjFile (objs ++ cmdline_js_objs) + js_srcs' = js_srcs ++ cmdline_js_srcs + isRoot _ = True + exe = jsExeFileName dflags + + env <- newGhcjsEnv + void $ link env lc_cfg cfg logger tmpfs dflags u_env exe mempty dep_pkgs objs' js_srcs' isRoot mempty + -- | link and write result to disk (jsexe directory) link :: GhcjsEnv -> JSLinkConfig @@ -195,7 +222,7 @@ readShimsArchive ar_file = do where readEntry :: Ar.ArchiveEntry -> IO (Maybe B.ByteString) readEntry ar_entry - | isJsFile ar_entry = pure $ Just (Ar.filedata ar_entry) + | isJsArchiveEntry ar_entry = pure $ Just (Ar.filedata ar_entry) | otherwise = pure Nothing @@ -214,7 +241,7 @@ link' :: GhcjsEnv -> (ExportedFun -> Bool) -- ^ functions from the objects to use as roots (include all their deps) -> Set ExportedFun -- ^ extra symbols to link in -> IO LinkResult -link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRootFun extraStaticDeps +link' env lc_cfg cfg logger unit_env target _include pkgs objFiles jsFiles isRootFun extraStaticDeps = do let ue_state = ue_units $ unit_env (objDepsMap, objRequiredUnits) <- loadObjDeps objFiles @@ -295,7 +322,7 @@ link' env lc_cfg cfg logger unit_env target _include pkgs objFiles _jsFiles isRo -- retrieve code for dependencies code <- collectDeps dep_map dep_units all_deps - (outJs, metaSize, compactorState, stats) <- renderLinker lc_cfg cfg (baseCompactorState base) rts_wired_functions code + (outJs, metaSize, compactorState, stats) <- renderLinker lc_cfg cfg (baseCompactorState base) rts_wired_functions code jsFiles let base' = Base compactorState (nub $ basePkgs base ++ bundle_diff) (all_deps `S.union` baseUnits base) @@ -334,8 +361,9 @@ renderLinker -> CompactorState -> Set ExportedFun -> [ModuleCode] -- ^ linked code per module + -> [FilePath] -- ^ additional JS files -> IO (FilePath -> IO (), Int64, CompactorState, LinkerStats) -renderLinker settings cfg renamer_state rtsDeps code = do +renderLinker settings cfg renamer_state rtsDeps code jsFiles = do -- extract ModuleCode fields required to make a LinkedUnit let code_to_linked_unit c = LinkedUnit @@ -348,9 +376,12 @@ renderLinker settings cfg renamer_state rtsDeps code = do let (renamer_state', compacted, meta) = compact settings cfg renamer_state (map ((\(LexicalFastString f) -> f) . funSymbol) $ S.toList rtsDeps) (map code_to_linked_unit code) + + js_files_contents <- mconcat <$> mapM BL.readFile jsFiles + let render_all fp = do - BL.writeFile fp rendered_all + BL.writeFile fp (rendered_all <> js_files_contents) -- render result into JS code rendered_all = mconcat [mconcat rendered_mods, rendered_meta, rendered_exports] @@ -776,14 +807,22 @@ loadArchiveDeps' archives = do let !deps = objDeps obj pure $ Just (deps, ArchiveFile ar_file) --- | Predicate to check that an entry in Ar is a JS payload -isJsFile :: Ar.ArchiveEntry -> Bool -isJsFile = checkEntryHeader "//JavaScript" +-- | Predicate to check that an entry in Ar is a JS source +isJsArchiveEntry :: Ar.ArchiveEntry -> Bool +isJsArchiveEntry entry = isJsBS (Ar.filedata entry) + +-- | Predicate to check that a file is a JS source +isJsFile :: FilePath -> IO Bool +isJsFile fp = isJsBS <$> B.readFile fp + +isJsBS :: B.ByteString -> Bool +isJsBS bs = B.take (B.length jsHeader) bs == jsHeader + where + -- Header added to JS sources to discriminate them from other object files. + -- They all have .o extension but JS sources have this header. + jsHeader :: B.ByteString + jsHeader = "//JavaScript" --- | Ensure that the entry header to the Archive object is sound. -checkEntryHeader :: B.ByteString -> Ar.ArchiveEntry -> Bool -checkEntryHeader header entry = - B.take (B.length header) (Ar.filedata entry) == header prepareLoadedDeps :: [(Deps, DepsLocation)] ===================================== compiler/GHC/Utils/Monad.hs ===================================== @@ -21,6 +21,7 @@ module GHC.Utils.Monad , maybeMapM , whenM, unlessM , filterOutM + , partitionM ) where ------------------------------------------------------------------------------- @@ -237,6 +238,14 @@ filterOutM :: (Applicative m) => (a -> m Bool) -> [a] -> m [a] filterOutM p = foldr (\ x -> liftA2 (\ flg -> if flg then id else (x:)) (p x)) (pure []) +-- | Monadic version of @partition@ +partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a]) +partitionM _ [] = pure ([], []) +partitionM f (x:xs) = do + res <- f x + (as,bs) <- partitionM f xs + pure ([x | res]++as, [x | not res]++bs) + {- Note [The one-shot state monad trick] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Summary: many places in GHC use a state monad, and we really want those ===================================== compiler/ghc.cabal.in ===================================== @@ -662,7 +662,6 @@ Library GHC.StgToJS.UnitUtils GHC.StgToJS.Utils GHC.StgToJS.Linker.Compactor - GHC.StgToJS.Linker.Dynamic GHC.StgToJS.Linker.Linker GHC.StgToJS.Linker.Types GHC.StgToJS.Linker.Utils ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -110,7 +110,8 @@ test('T2469', normal, compile_and_run, ['-optc-std=gnu99']) test('T2594', [omit_ways(['ghci'])], compile_and_run, ['T2594_c.c']) -test('fptr01', [omit_ways(['ghci'])], compile_and_run, ['fptr01_c.c']) +test('fptr01', [omit_ways(['ghci'])], compile_and_run, + [ 'fptr01_js.js' if arch("js") else 'fptr01_c.c']) test('fptr02', normal, compile_and_run, ['']) test('fptrfail01', [omit_ways(['ghci']), exit_code(1)], compile_and_run, ===================================== testsuite/tests/ffi/should_run/fptr01_js.js ===================================== @@ -0,0 +1,15 @@ +function h$f(i) { + console.log( "f" + i + "\n"); +} + +function h$g(i) { + console.log( "g" + i + "\n"); +} + +function h$h(i) { + console.log( "h" + i + "\n"); +} + +function h$f_env(env,i) { + console.log( "f_env " + env + " " + i + "\n"); +} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f549189115e33d07a3581b8ffd9dd7a51b58b69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f549189115e33d07a3581b8ffd9dd7a51b58b69 You're receiving 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 Sep 29 15:03:45 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 29 Sep 2022 11:03:45 -0400 Subject: [Git][ghc/ghc][wip/T22231] 10 commits: Apply some tricks to speed up core lint. Message-ID: <6335b3d18cbb8_2c97575141498649f@gitlab.mail> Sebastian Graf pushed to branch wip/T22231 at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - a513b21d by Sebastian Graf at 2022-09-29T17:03:37+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 - - - - - 30 changed files: - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - + compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore.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/75ae893f7cf870d4f9acb97274affacd8ecef28c...a513b21de25a4b569a5cf52fa18a8d8d159c797a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75ae893f7cf870d4f9acb97274affacd8ecef28c...a513b21de25a4b569a5cf52fa18a8d8d159c797a You're receiving 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 Sep 29 15:04:29 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 29 Sep 2022 11:04:29 -0400 Subject: [Git][ghc/ghc][wip/T22231] Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Message-ID: <6335b3fd836d6_2c975742bcfe5c9869f4@gitlab.mail> Sebastian Graf pushed to branch wip/T22231 at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - docs/users_guide/using-optimisation.rst - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity04.stderr - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity06.stderr - testsuite/tests/arityanal/should_compile/Arity08.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity15.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/determinism/determ004/determ004.hs - testsuite/tests/simplCore/should_compile/OpaqueNoSpecialise.stderr - testsuite/tests/simplCore/should_compile/T13156.hs - testsuite/tests/simplCore/should_compile/T14152.stderr - testsuite/tests/simplCore/should_compile/T14152a.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T19890.stderr - testsuite/tests/simplCore/should_compile/T21694b.stderr - testsuite/tests/simplCore/should_compile/T21948.stderr - testsuite/tests/simplCore/should_compile/T21960.stderr - testsuite/tests/simplCore/should_compile/T7785.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a535172d13b30c94766751d0bc21a494b8858ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a535172d13b30c94766751d0bc21a494b8858ed You're receiving 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 Sep 29 15:14:51 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 29 Sep 2022 11:14:51 -0400 Subject: [Git][ghc/ghc][wip/T22084] 13 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <6335b66b7e99f_2c975742bcfe709876b@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22084 at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - 9117a48f by Simon Peyton Jones at 2022-09-29T16:08:15+01: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 arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). It's not a big deal, but it shaves 0.1% off compile times. - - - - - 87f32247 by Simon Peyton Jones at 2022-09-29T16:14:52+01:00 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.) This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. - - - - - 30 changed files: - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/Pipeline.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/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac9987f3ee3288fd2d0e4d5f6068323f9d9ccdd8...87f32247e4beef49e010e5bfc0aa7a12329fd173 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac9987f3ee3288fd2d0e4d5f6068323f9d9ccdd8...87f32247e4beef49e010e5bfc0aa7a12329fd173 You're receiving 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 Sep 29 15:29:01 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 29 Sep 2022 11:29:01 -0400 Subject: [Git][ghc/ghc][wip/andreask/stgLintFix] 16 commits: Add fragmentation statistic to GHC.Stats Message-ID: <6335b9bde09a1_2c975742bcfe7099848e@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/stgLintFix at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - c7be73fc by Andreas Klebinger at 2022-09-29T15:28:59+00:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/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/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5caedd50db499638420207a5a871b7d3f43f189f...c7be73fc761501317244999e262b08616ed03955 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5caedd50db499638420207a5a871b7d3f43f189f...c7be73fc761501317244999e262b08616ed03955 You're receiving 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 Sep 29 15:30:05 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Thu, 29 Sep 2022 11:30:05 -0400 Subject: [Git][ghc/ghc][wip/jsem] 3 commits: WIP: testing framework Message-ID: <6335b9fdaa5bc_2c975742bd2a1c1000867@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: d91292f0 by sheaf at 2022-09-29T14:36:39+02:00 WIP: testing framework - - - - - f3ae35b2 by Matthew Pickering at 2022-09-29T14:46:07+02:00 hadrian: Use --make mode rather than -c for compiling libraries Experiment, this will probably be faster when we have -jsem - - - - - 9644da47 by Matthew Pickering at 2022-09-29T17:29:43+02:00 wip: jsem - - - - - 19 changed files: - compiler/GHC/Utils/IO/Semaphore.hs - hadrian/cabal.project - hadrian/hadrian.cabal - hadrian/src/Builder.hs - hadrian/src/Context.hs - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Hadrian/Oracles/Cabal/Rules.hs - + hadrian/src/Hadrian/Semaphore.hs - + hadrian/src/Hadrian/Semaphore/System.hs - hadrian/src/Main.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Library.hs - hadrian/src/Rules/Nofib.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/Ghc.hs - hadrian/src/Settings/Packages.hs - + testsuite/tests/driver/jsem/Main.hs Changes: ===================================== compiler/GHC/Utils/IO/Semaphore.hs ===================================== @@ -34,7 +34,7 @@ import qualified System.Win32.Types as Win32 #else import qualified System.Posix.Semaphore as Posix ( Semaphore, OpenSemFlags(..) - , semOpen, semWait, semTryWait + , semOpen, semThreadWait, semTryWait , semGetValue, semPost, semUnlink ) import qualified System.Posix.Files as Posix ( stdFileMode ) @@ -71,6 +71,29 @@ data Semaphore = #endif } +-- | Create a new semaphore with the given name and initial amount of +-- available resources. +-- +-- Throws an error if a semaphore by this name already exists. +createSemaphore :: SemaphoreName -> Int -> IO Semaphore +createSemaphore nm@(SemaphoreName sem_name) init_toks = do +#if defined(mingw32_HOST_OS) + let toks = fromIntegral init_toks + (sem, exists) <- Win32.createSemaphore Nothing toks toks (Just sem_name) + when exists $ + Win32.errorWin ("jsem: semaphore " ++ sem_name ++ " already exists") +#else + let flags = + Posix.OpenSemFlags + { Posix.semCreate = True + , Posix.semExclusive = True } + sem <- Posix.semOpen sem_name flags Posix.stdFileMode init_toks +#endif + return $ + Semaphore + { semaphore = sem + , semaphoreName = nm } + -- | Open a semaphore with the given name. -- -- If no such semaphore exists, throws an error. @@ -96,7 +119,7 @@ waitOnSemaphore (Semaphore { semaphore = sem }) = #if defined(mingw32_HOST_OS) void $ Win32.waitForSingleObject (Win32.semaphoreHandle sem) Win32.iNFINITE #else - Posix.semWait sem + Posix.semThreadWait sem #endif -- | Try to obtain a token from the semaphore, without blocking. @@ -126,29 +149,6 @@ releaseSemaphore (Semaphore { semaphore = sem }) n = return res #endif --- | Create a new semaphore with the given name and initial amount of --- available resources. --- --- Throws an error if a semaphore by this name already exists. -createSemaphore :: SemaphoreName -> Int -> IO Semaphore -createSemaphore nm@(SemaphoreName sem_name) init_toks = do -#if defined(mingw32_HOST_OS) - let toks = fromIntegral init_toks - (sem, exists) <- Win32.createSemaphore Nothing toks toks (Just sem_name) - when exists $ - Win32.errorWin ("jsem: semaphore " ++ sem_name ++ " already exists") -#else - let flags = - Posix.OpenSemFlags - { Posix.semCreate = True - , Posix.semExclusive = True } - sem <- Posix.semOpen sem_name flags Posix.stdFileMode init_toks -#endif - return $ - Semaphore - { semaphore = sem - , semaphoreName = nm } - -- | Destroy the given semaphore. destroySemaphore :: Semaphore -> IO () destroySemaphore sem = ===================================== hadrian/cabal.project ===================================== @@ -1,4 +1,5 @@ packages: ./ + , ../libraries/Win32 -- This essentially freezes the build plan for hadrian index-state: 2022-09-10T18:46:55Z ===================================== hadrian/hadrian.cabal ===================================== @@ -67,6 +67,8 @@ executable hadrian , Hadrian.Package , Hadrian.Target , Hadrian.Utilities + , Hadrian.Semaphore + , Hadrian.Semaphore.System , Oracles.Flag , Oracles.Flavour , Oracles.Setting @@ -153,6 +155,7 @@ executable hadrian , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 + , exceptions , filepath , time , mtl == 2.2.* @@ -161,6 +164,13 @@ executable hadrian , transformers >= 0.4 && < 0.6 , unordered-containers >= 0.2.1 && < 0.3 , text >= 1.2 && < 3 + , time + + if os(windows) + build-depends: Win32 + else + build-depends: unix + ghc-options: -Wall -Wincomplete-record-updates -Wredundant-constraints ===================================== hadrian/src/Builder.hs ===================================== @@ -3,7 +3,7 @@ module Builder ( -- * Data types ArMode (..), CcMode (..), ConfigurationInfo (..), DependencyType (..), GhcMode (..), GhcPkgMode (..), HaddockMode (..), TestMode(..), SphinxMode (..), - TarMode (..), GitMode (..), Builder (..), Win32TarballsMode(..), + TarMode (..), GitMode (..), Builder (..), Win32TarballsMode(..), MakeOrOneShot(..), -- * Builder properties builderProvenance, systemBuilderPath, builderPath, isSpecified, needBuilders, @@ -41,6 +41,7 @@ import Packages import GHC.IO.Encoding (getFileSystemEncoding) import qualified Data.ByteString as BS import qualified GHC.Foreign as GHC +import Hadrian.Semaphore ( getJsemSemaphore, withSemaphore ) -- | C compiler can be used in two different modes: -- * Compile or preprocess a source file. @@ -61,7 +62,8 @@ instance NFData DependencyType -- * Compile a C source file. -- * Extract source dependencies by passing @-M@ command line argument. -- * Link object files & static libraries into an executable. -data GhcMode = CompileHs + +data GhcMode = CompileHs MakeOrOneShot | CompileCWithGhc | CompileCppWithGhc | FindHsDependencies @@ -69,10 +71,16 @@ data GhcMode = CompileHs | ToolArgs deriving (Eq, Generic, Show) +data MakeOrOneShot = GhcMake | GhcOneShot deriving (Eq, Generic, Show) + instance Binary GhcMode instance Hashable GhcMode instance NFData GhcMode +instance Binary MakeOrOneShot +instance Hashable MakeOrOneShot +instance NFData MakeOrOneShot + -- | To configure a package we need two pieces of information, which we choose -- to record separately for convenience. -- @@ -383,6 +391,12 @@ instance H.Builder Builder where when (code /= ExitSuccess) $ do fail "tests failed" + Ghc (CompileHs GhcMake) _ -> do + sem <- getJsemSemaphore + Exit code <- withSemaphore sem $ cmd [path] buildArgs + when (code /= ExitSuccess) $ do + fail "build failed" + _ -> cmd' [path] buildArgs -- TODO: Some builders are required only on certain platforms. For example, ===================================== hadrian/src/Context.hs ===================================== @@ -148,7 +148,6 @@ pkgStampFile c at Context{..} = do let extension = waySuffix way pkgFile c "stamp-" extension - -- | Given a 'Context' and a 'FilePath' to a source file, compute the 'FilePath' -- to its object file. For example: -- * "Task.c" -> "_build/stage1/rts/Task.thr_o" ===================================== hadrian/src/Expression.hs ===================================== @@ -79,6 +79,13 @@ instance BuilderPredicate a => BuilderPredicate (GhcMode -> a) where Ghc c _ -> builder (f c) _ -> return False +instance BuilderPredicate a => BuilderPredicate (MakeOrOneShot -> a) where + builder f = do + b <- getBuilder + case b of + Ghc (CompileHs mode) _ -> builder (f mode) + _ -> return False + instance BuilderPredicate a => BuilderPredicate (FilePath -> a) where builder f = do b <- getBuilder ===================================== hadrian/src/Flavour.hs ===================================== @@ -112,7 +112,7 @@ werror = addArgs (builder Ghc ? notStage0 ? arg "-Werror") -- | Build C and Haskell objects with debugging information. enableDebugInfo :: Flavour -> Flavour enableDebugInfo = addArgs $ notStage0 ? mconcat - [ builder (Ghc CompileHs) ? arg "-g3" + [ builder (Ghc . CompileHs) ? arg "-g3" , builder (Cc CompileC) ? arg "-g3" , builder (Cabal Setup) ? arg "--disable-library-stripping" , builder (Cabal Setup) ? arg "--disable-executable-stripping" @@ -122,7 +122,7 @@ enableDebugInfo = addArgs $ notStage0 ? mconcat enableTickyGhc :: Flavour -> Flavour enableTickyGhc = addArgs $ stage1 ? mconcat - [ builder (Ghc CompileHs) ? ticky + [ builder (Ghc . CompileHs) ? ticky , builder (Ghc LinkHs) ? ticky ] where @@ -139,7 +139,7 @@ enableTickyGhc = enableLinting :: Flavour -> Flavour enableLinting = addArgs $ stage1 ? mconcat - [ builder (Ghc CompileHs) ? lint + [ builder (Ghc . CompileHs) ? lint ] where lint = mconcat @@ -150,7 +150,7 @@ enableLinting = enableHaddock :: Flavour -> Flavour enableHaddock = addArgs $ stage1 ? mconcat - [ builder (Ghc CompileHs) ? haddock + [ builder (Ghc . CompileHs) ? haddock ] where haddock = mconcat @@ -171,7 +171,7 @@ splitSectionsIf pkgPredicate = addArgs $ do osx <- expr isOsxTarget not osx ? -- osx doesn't support split sections pkgPredicate pkg ? -- Only apply to these packages - builder (Ghc CompileHs) ? arg "-split-sections" + builder (Ghc . CompileHs) ? arg "-split-sections" -- | Like 'splitSectionsIf', but with a fixed predicate: use -- split sections for all packages but the GHC library. @@ -182,7 +182,7 @@ splitSections = splitSectionsIf (/=ghc) enableThreadSanitizer :: Flavour -> Flavour enableThreadSanitizer = addArgs $ mconcat - [ builder (Ghc CompileHs) ? arg "-optc-fsanitize=thread" + [ builder (Ghc . CompileHs) ? arg "-optc-fsanitize=thread" , builder (Ghc CompileCWithGhc) ? (arg "-optc-fsanitize=thread" <> arg "-DTSAN_ENABLED") , builder (Ghc LinkHs) ? arg "-optl-fsanitize=thread" , builder (Cc CompileC) ? (arg "-fsanitize=thread" <> arg "-DTSAN_ENABLED") @@ -225,19 +225,19 @@ disableProfiledLibs flavour = -- recompilation. omitPragmas :: Flavour -> Flavour omitPragmas = addArgs - $ notStage0 ? builder (Ghc CompileHs) ? package compiler + $ notStage0 ? builder (Ghc . CompileHs) ? package compiler ? arg "-fomit-interface-pragmas" -- | Build stage2 dependencies with options to enable IPE debugging -- information. enableIPE :: Flavour -> Flavour enableIPE = addArgs - $ notStage0 ? builder (Ghc CompileHs) + $ notStage0 ? builder (Ghc . CompileHs) ? pure ["-finfo-table-map", "-fdistinct-constructor-tables"] enableLateCCS :: Flavour -> Flavour enableLateCCS = addArgs - $ notStage0 ? builder (Ghc CompileHs) + $ notStage0 ? builder (Ghc . CompileHs) ? ((Profiling `wayUnit`) <$> getWay) ? arg "-fprof-late" @@ -286,7 +286,7 @@ fullyStatic flavour = - an executable (where their position is not at the beginning of - the file). -} - , builder (Ghc CompileHs) ? pure [ "-fPIC", "-static" ] + , builder (Ghc . CompileHs) ? pure [ "-fPIC", "-static" ] , builder (Ghc CompileCWithGhc) ? pure [ "-fPIC", "-optc", "-static"] , builder (Ghc LinkHs) ? pure [ "-optl", "-static" ] ] @@ -302,7 +302,7 @@ collectTimings = -- that has been causing the allocation. So we want -v. -- On the other hand, -v doesn't work with -ddump-to-file, so we need -- -ddump-timings. - addArgs $ notStage0 ? builder (Ghc CompileHs) ? + addArgs $ notStage0 ? builder (Ghc . CompileHs) ? pure ["-ddump-to-file", "-ddump-timings", "-v"] -- | Build ghc with debug rts (i.e. -debug) in and after this stage @@ -513,7 +513,7 @@ builderSetting = [ ("c", CompileCWithGhc) , ("cpp", CompileCppWithGhc) , ("deps", FindHsDependencies) - , ("hs", CompileHs) + , ("hs", CompileHs GhcMake) , ("link", LinkHs) , ("toolargs", ToolArgs) ] ===================================== hadrian/src/Hadrian/Oracles/Cabal/Rules.hs ===================================== @@ -58,7 +58,7 @@ cabalOracle = do putVerbose $ "| PackageConfiguration oracle: configuring " ++ quote (pkgName pkg) ++ " (" ++ show stage ++ ")..." -- Configure the package with the GHC corresponding to the given stage - hcPath <- builderPath (Ghc CompileHs stage) + hcPath <- builderPath (Ghc (CompileHs GhcMake) stage) hcPkgPath <- builderPath (GhcPkg undefined stage) -- N.B. the hcPath parameter of `configure` is broken when given an -- empty ProgramDb. To work around this we manually construct an ===================================== hadrian/src/Hadrian/Semaphore.hs ===================================== @@ -0,0 +1,41 @@ +module Hadrian.Semaphore where + +import Hadrian.Semaphore.System +import Hadrian.Utilities +import Development.Shake + +data GlobalSemaphore = NoSemaphore | GlobalSemaphore FilePath Semaphore + +getJsemSemaphore :: Action GlobalSemaphore +getJsemSemaphore = userSetting NoSemaphore + +globalSemaphore :: a -> (FilePath -> Semaphore -> a) -> GlobalSemaphore -> a +globalSemaphore def _ NoSemaphore = def +globalSemaphore _ f (GlobalSemaphore fp sem) = f fp sem + +initialiseSemaphore :: Int -> IO GlobalSemaphore +initialiseSemaphore n = do + let sem_path = "hadrian_semaphore" + -- Can fail if the semaphore has not been created + --_ <- try_ $ semUnlink sem_path + sem <- createSemaphore (SemaphoreName sem_path) n + return (GlobalSemaphore sem_path sem) + +unlinkSemaphore :: GlobalSemaphore -> IO () +unlinkSemaphore NoSemaphore = return () +unlinkSemaphore (GlobalSemaphore _ sem) = destroySemaphore sem + +-- | Wrap an action which requires the semaphore with wait/post +withSemaphore :: GlobalSemaphore -> Action a -> Action a +withSemaphore sem act = + globalSemaphore act (\_ sem -> actionBracket (wait sem) (\_ -> post sem) (\_ -> act)) sem + where + wait s = do + n <- getSemaphoreValue s + liftIO $ print ("WAITING:" ++ show n) + waitOnSemaphore s + liftIO $ print "WAITED" + + post s = do + liftIO $ print "POST" + releaseSemaphore s 1 ===================================== hadrian/src/Hadrian/Semaphore/System.hs ===================================== @@ -0,0 +1,176 @@ +{-# LANGUAGE CPP #-} + +module Hadrian.Semaphore.System + ( -- * System semaphores + Semaphore(..), SemaphoreName(..) + , createSemaphore, openSemaphore + , waitOnSemaphore, tryWaitOnSemaphore + , getSemaphoreValue + , releaseSemaphore + , destroySemaphore + + -- * Abstract semaphores + , AbstractSem(..) + , withAbstractSem + ) where + +import Control.Monad + +import qualified Control.Monad.Catch as MC + +#if defined(mingw32_HOST_OS) +import qualified System.Win32.Event as Win32 + ( waitForSingleObject, wAIT_OBJECT_0 ) +import qualified System.Win32.File as Win32 + ( closeHandle ) +import qualified System.Win32.Process as Win32 + ( iNFINITE ) +import qualified System.Win32.Semaphore as Win32 + ( Semaphore(..), sEMAPHORE_ALL_ACCESS + , createSemaphore, openSemaphore, releaseSemaphore ) +import qualified System.Win32.Types as Win32 + ( errorWin ) +#else +import qualified System.Posix.Semaphore as Posix + ( Semaphore, OpenSemFlags(..) + , semOpen, semThreadWait, semTryWait + , semGetValue, semPost, semUnlink ) +import qualified System.Posix.Files as Posix + ( stdFileMode ) +#endif + +--------------------------------------- +-- Abstract semaphores + +-- | Abstraction over the operations of a semaphore, +-- allowing usage with -jN or a jobserver. +data AbstractSem = AbstractSem { acquireSem :: IO () + , releaseSem :: IO () + } + +withAbstractSem :: AbstractSem -> IO b -> IO b +withAbstractSem sem = MC.bracket_ (acquireSem sem) (releaseSem sem) + +--------------------------------------- +-- System-specific semaphores + +newtype SemaphoreName = + SemaphoreName { getSemaphoreName :: String } + deriving Eq + +-- | A semaphore (POSIX or Win32). +data Semaphore = + Semaphore + { semaphoreName :: !SemaphoreName + , semaphore :: +#if defined(mingw32_HOST_OS) + !Win32.Semaphore +#else + !Posix.Semaphore +#endif + } + +-- | Create a new semaphore with the given name and initial amount of +-- available resources. +-- +-- Throws an error if a semaphore by this name already exists. +createSemaphore :: SemaphoreName -> Int -> IO Semaphore +createSemaphore nm@(SemaphoreName sem_name) init_toks = do +#if defined(mingw32_HOST_OS) + let toks = fromIntegral init_toks + (sem, exists) <- Win32.createSemaphore Nothing toks toks (Just sem_name) + when exists $ + Win32.errorWin ("jsem: semaphore " ++ sem_name ++ " already exists") +#else + let flags = + Posix.OpenSemFlags + { Posix.semCreate = True + , Posix.semExclusive = True } + sem <- Posix.semOpen sem_name flags Posix.stdFileMode init_toks +#endif + return $ + Semaphore + { semaphore = sem + , semaphoreName = nm } + +-- | Open a semaphore with the given name. +-- +-- If no such semaphore exists, throws an error. +openSemaphore :: SemaphoreName -> IO Semaphore +openSemaphore nm@(SemaphoreName sem_name) = do +#if defined(mingw32_HOST_OS) + sem <- Win32.openSemaphore Win32.sEMAPHORE_ALL_ACCESS True sem_name +#else + let + flags = Posix.OpenSemFlags + { Posix.semCreate = False + , Posix.semExclusive = False } + sem <- Posix.semOpen sem_name flags Posix.stdFileMode 0 +#endif + return $ + Semaphore + { semaphore = sem + , semaphoreName = nm } + +-- | Indefinitely wait on a semaphore. +waitOnSemaphore :: Semaphore -> IO () +waitOnSemaphore (Semaphore { semaphore = sem }) = +#if defined(mingw32_HOST_OS) + void $ Win32.waitForSingleObject (Win32.semaphoreHandle sem) Win32.iNFINITE +#else + Posix.semThreadWait sem +#endif + +-- | Try to obtain a token from the semaphore, without blocking. +-- +-- Immediately returns 'False' if no resources are available. +tryWaitOnSemaphore :: Semaphore -> IO Bool +tryWaitOnSemaphore (Semaphore { semaphore = sem }) = +#if defined(mingw32_HOST_OS) + (== Win32.wAIT_OBJECT_0) <$> Win32.waitForSingleObject (Win32.semaphoreHandle sem) 0 +#else + Posix.semTryWait sem +#endif + +-- | Release a semaphore: add @n@ to its internal counter, +-- and return the semaphore's count before the operation. +-- +-- NB: the returned value should only be used for debugging, +-- not for the main jobserver logic. +releaseSemaphore :: Semaphore -> Int -> IO Int +releaseSemaphore (Semaphore { semaphore = sem }) n = +#if defined(mingw32_HOST_OS) + fromIntegral <$> Win32.releaseSemaphore sem (fromIntegral n) +#else + do + res <- Posix.semGetValue sem + replicateM_ n (Posix.semPost sem) + return res +#endif + +-- | Destroy the given semaphore. +destroySemaphore :: Semaphore -> IO () +destroySemaphore sem = +#if defined(mingw32_HOST_OS) + Win32.closeHandle (Win32.semaphoreHandle $ semaphore sem) +#else + Posix.semUnlink (getSemaphoreName $ semaphoreName sem) +#endif + +-- | Query the current semaphore value (how many tokens it has available). +getSemaphoreValue :: Semaphore -> IO Int +getSemaphoreValue (Semaphore { semaphore = sem }) = +#if defined(mingw32_HOST_OS) + do + wait_res <- Win32.waitForSingleObject (Win32.semaphoreHandle sem) (fromInteger 0) + if wait_res == Win32.wAIT_OBJECT_0 + -- We were able to immediately acquire a resource from the semaphore: + -- release it immediately, thus obtaining the total number of available + -- resources. + then + (+1) . fromIntegral <$> Win32.releaseSemaphore sem 1 + else + return 0 +#else + Posix.semGetValue sem +#endif ===================================== hadrian/src/Main.hs ===================================== @@ -26,6 +26,7 @@ import qualified Rules.Selftest import qualified Rules.SourceDist import qualified Rules.Test import qualified UserSettings +import Hadrian.Semaphore main :: IO () main = do @@ -114,24 +115,31 @@ main = do -- command line options (which happens in shakeArgsOptionsWith, but -- isn't exposed to the user) to the exception handler, which uses the -- verbosity and colour information to decide how much of the error to display. - shake_opts_var <- newIORef options + shake_opts_var <- newIORef (options, NoSemaphore) handleShakeException shake_opts_var $ shakeArgsOptionsWith options CommandLine.optDescrs $ \shake_opts _ targets -> do - writeIORef shake_opts_var shake_opts + sem <- initialiseSemaphore (shakeThreads shake_opts) + let extra' = insertExtra sem (shakeExtra shake_opts) + writeIORef shake_opts_var (shake_opts, sem) let targets' = filter (not . null) $ removeKVs targets Environment.setupEnvironment - return . Just $ (shake_opts, if null targets' + return . Just $ (shake_opts { shakeExtra = extra' }, if null targets' then rules else want targets' >> withoutActions rules) -handleShakeException :: IORef ShakeOptions -> IO a -> IO a +handleShakeException :: IORef (ShakeOptions, GlobalSemaphore) -> IO a -> IO a handleShakeException shake_opts_var shake_run = do args <- getArgs -- Using withArgs here is a bit of a hack but the API doesn't allow another way -- See https://github.com/ndmitchell/shake/issues/811 -- Passing --exception means shake throws an exception rather than -- catching ShakeException and displaying the error itself to the user. - catch (withArgs ("--exception" : args) $ shake_run) $ \(_e :: ShakeException) -> do - shake_opts <- readIORef shake_opts_var + let cleanup_sem = do + (_, sem) <- readIORef shake_opts_var + unlinkSemaphore sem + let action = (withArgs ("--exception" : args) $ shake_run) + `finally` cleanup_sem + catch action $ \(_e :: ShakeException) -> do + (shake_opts, _) <- readIORef shake_opts_var let FailureColour col = lookupExtra red (shakeExtra shake_opts) esc = if shakeColor shake_opts then escape col else id ===================================== hadrian/src/Rules/Compile.hs ===================================== @@ -206,21 +206,39 @@ compileHsObjectAndHi rs objpath = do b@(BuildPath _root stage _path _o) <- parsePath (parseBuildObject root) "" objpath let ctx = objectContext b - way = C.way ctx - ctxPath <- contextPath ctx - (src, deps) <- lookupDependencies (ctxPath -/- ".dependencies") objpath - need (src:deps) - - -- The .dependencies file lists indicating inputs. ghc will - -- generally read more *.hi and *.hi-boot files (direct inputs). - -- Allow such reads (see https://gitlab.haskell.org/ghc/ghc/wikis/Developing-Hadrian#haskell-object-files-and-hi-inputs) - -- Note that this may allow too many *.hi and *.hi-boot files, but - -- calculating the exact set of direct inputs is not feasible. - trackAllow [ "**/*." ++ hisuf way - , "**/*." ++ hibootsuf way - ] + -- Ideally we want to use --make to build with stage0 but we need to use -jsem + -- to recover build-time performance so we only do it for stage1 at the moment. + if isStage0 stage + then compileWithOneShot ctx + else compileWithMake ctx - buildWithResources rs $ target ctx (Ghc CompileHs stage) [src] [objpath] + where + compileWithMake ctx = do + -- Need the stamp file, which triggers a rebuild via make + stamp <- pkgStampFile ctx + let way = C.way ctx + lib_ways <- interpretInContext ctx getLibraryWays + -- In this situation -dynamic-too will produce both ways + unless (way == dynamic && vanilla `elem` lib_ways) $ + need [stamp] + + compileWithOneShot ctx = do + let way = C.way ctx + stage = C.stage ctx + ctxPath <- contextPath ctx + (src, deps) <- lookupDependencies (ctxPath -/- ".dependencies") objpath + need (src:deps) + + -- The .dependencies file lists indicating inputs. ghc will + -- generally read more *.hi and *.hi-boot files (direct inputs). + -- Allow such reads (see https://gitlab.haskell.org/ghc/ghc/wikis/Developing-Hadrian#haskell-object-files-and-hi-inputs) + -- Note that this may allow too many *.hi and *.hi-boot files, but + -- calculating the exact set of direct inputs is not feasible. + trackAllow [ "**/*." ++ hisuf way + , "**/*." ++ hibootsuf way + ] + + buildWithResources rs $ target ctx (Ghc (CompileHs GhcOneShot) stage) [src] [objpath] compileNonHsObject :: [(Resource, Int)] -> SourceLang -> FilePath -> Action () compileNonHsObject rs lang path = do @@ -232,7 +250,7 @@ compileNonHsObject rs lang path = do builder = case lang of C -> Ghc CompileCWithGhc Cxx-> Ghc CompileCppWithGhc - _ -> Ghc CompileHs + _ -> Ghc (CompileHs GhcOneShot) src <- case lang of Asm -> obj2src "S" (const False) ctx path C -> obj2src "c" (const False) ctx path ===================================== hadrian/src/Rules/Library.hs ===================================== @@ -17,9 +17,9 @@ import Target import Utilities import Data.Time.Clock import Rules.Generate (generatedDependencies) +import Hadrian.Oracles.Cabal (readPackageData) import Oracles.Flag - -- * Library 'Rules' libraryRules :: Rules () @@ -52,6 +52,46 @@ registerStaticLib root archivePath = do let ctx = Context stage (unsafeFindPackageByName name) w Final need . (:[]) =<< pkgConfFile ctx +buildPackage :: FilePath -> FilePath -> Action () +buildPackage root fp = do + l@(BuildPath _ stage _ (PkgStamp _ _ way)) <- parsePath (parseStampPath root) "<.stamp parser>" fp + let ctx = stampContext l + srcs <- hsSources ctx + gens <- interpretInContext ctx generatedDependencies + + lib_targets <- libraryTargets True ctx + + -- Write the current time into the file so the file always changes if + -- we restamp it because a dependency changes. + + depPkgs <- packageDependencies <$> readPackageData (package ctx) + -- Stage packages are those we have in this stage. + stagePkgs <- stagePackages stage + -- We'll need those packages in our package database. + deps <- sequence [ pkgConfFile (ctx { package = pkg }) + | pkg <- depPkgs, pkg `elem` stagePkgs ] + need deps + let needs + | isStage0 stage + = srcs ++ gens ++ lib_targets + | otherwise + = srcs ++ gens + need needs + unless (null srcs || isStage0 stage) $ do + build $ target ctx (Ghc (CompileHs GhcMake) stage) srcs [] + time <- liftIO $ getCurrentTime + liftIO $ writeFile fp (show time) + ways <- interpretInContext ctx getLibraryWays + let hasVanilla = elem vanilla ways + hasDynamic = elem dynamic ways + support <- platformSupportsSharedLibs + when ((hasVanilla && hasDynamic) && + support && way == vanilla) $ do + stamp <- (pkgStampFile (ctx { way = dynamic })) + liftIO $ writeFile stamp (show time) + + + -- | Build a static library ('LibA') under the given build root, whose path is -- the second argument. buildStaticLib :: FilePath -> FilePath -> Action () @@ -132,32 +172,6 @@ files etc. -} -buildPackage :: FilePath -> FilePath -> Action () -buildPackage root fp = do - l@(BuildPath _ _ _ (PkgStamp _ _ way)) <- parsePath (parseStampPath root) "<.stamp parser>" fp - let ctx = stampContext l - srcs <- hsSources ctx - gens <- interpretInContext ctx generatedDependencies - - lib_targets <- libraryTargets True ctx - - need (srcs ++ gens ++ lib_targets) - - -- Write the current time into the file so the file always changes if - -- we restamp it because a dependency changes. - time <- liftIO $ getCurrentTime - liftIO $ writeFile fp (show time) - ways <- interpretInContext ctx getLibraryWays - let hasVanilla = elem vanilla ways - hasDynamic = elem dynamic ways - support <- platformSupportsSharedLibs - when ((hasVanilla && hasDynamic) && - support && way == vanilla) $ do - stamp <- (pkgStampFile (ctx { way = dynamic })) - liftIO $ writeFile stamp (show time) - - - -- * Helpers -- | Return all Haskell and non-Haskell object files for the given 'Context'. @@ -231,6 +245,8 @@ data LibDyn = LibDyn String [Integer] Way DynLibExt deriving (Eq, Show) -- | > HS-[_].o data LibGhci = LibGhci String [Integer] Way deriving (Eq, Show) +data PkgStamp = PkgStamp String [Integer] Way deriving (Eq, Show) + -- | Get the 'Context' corresponding to the build path for a given static library. libAContext :: BuildPath LibA -> Context libAContext (BuildPath _ stage pkgpath (LibA pkgname _ way)) = @@ -259,14 +275,6 @@ stampContext (BuildPath _ stage _ (PkgStamp pkgname _ way)) = where pkg = unsafeFindPackageByName pkgname -data PkgStamp = PkgStamp String [Integer] Way deriving (Eq, Show) - - --- | Parse a path to a ghci library to be built, making sure the path starts --- with the given build root. -parseStampPath :: FilePath -> Parsec.Parsec String () (BuildPath PkgStamp) -parseStampPath root = parseBuildPath root parseStamp - -- | Parse a path to a registered ghc-pkg static library to be built, making -- sure the path starts with the given build root. @@ -290,6 +298,11 @@ parseBuildLibGhci :: FilePath -> Parsec.Parsec String () (BuildPath LibGhci) parseBuildLibGhci root = parseBuildPath root parseLibGhciFilename Parsec. "build path for a ghci library" +-- | Parse a path to a ghci library to be built, making sure the path starts +-- with the given build root. +parseStampPath :: FilePath -> Parsec.Parsec String () (BuildPath PkgStamp) +parseStampPath root = parseBuildPath root parseStamp + -- | Parse a path to a dynamic library to be built, making sure the path starts -- with the given build root. parseBuildLibDyn :: FilePath -> String -> Parsec.Parsec String () (BuildPath LibDyn) @@ -331,6 +344,7 @@ parseLibDynFilename ext = do _ <- Parsec.string ("." ++ ext) return (LibDyn pkgname pkgver way $ if ext == "so" then So else Dylib) +-- | Parse the filename of a static library to be built into a 'LibA' value. parseStamp :: Parsec.Parsec String () PkgStamp parseStamp = do _ <- Parsec.string "stamp-" ===================================== hadrian/src/Rules/Nofib.hs ===================================== @@ -28,7 +28,7 @@ nofibRules = do makePath <- builderPath (Make "nofib") top <- topDirectory - ghcPath <- builderPath (Ghc CompileHs Stage2) + ghcPath <- builderPath (Ghc (CompileHs GhcMake) Stage2) -- some makefiles in nofib rely on a $MAKE -- env var being defined @@ -53,4 +53,4 @@ needNofibDeps = do unlitPath <- programPath (vanillaContext Stage1 unlit) mtlPath <- pkgConfFile (vanillaContext Stage1 mtl ) need [ unlitPath, mtlPath ] - needBuilders [Ghc CompileHs Stage2] + needBuilders [Ghc (CompileHs GhcMake) Stage2] ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -290,7 +290,6 @@ needTestsuitePackages stg = do cross <- flag CrossCompiling when (not cross) $ needIservBins stg root <- buildRoot - liftIO $ print stg -- require the shims for testing stage1 when (stg == stage0InTree) $ do -- Windows not supported as the wrapper scripts don't work on windows.. we could ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -113,9 +113,9 @@ commonCabalArgs stage = do , arg $ "${pkgroot}/../../doc/html/libraries/" ++ package_id -- These trigger a need on each dependency, so every important to need - -- them in parallel or it linearises the build of Ghc and GhcPkg - , withStageds [Ghc CompileHs, GhcPkg Update, Cc CompileC, Ar Pack] - , withBuilderArgs (Ghc CompileHs stage) + -- them in parallel or it linearises the build of Ghc and GhcPkg + , withStageds [Ghc (CompileHs GhcMake), GhcPkg Update, Cc CompileC, Ar Pack] + , withBuilderArgs (Ghc (CompileHs GhcMake) stage) , withBuilderArgs (GhcPkg Update stage) , bootPackageDatabaseArgs , libraryArgs ===================================== hadrian/src/Settings/Builders/Ghc.hs ===================================== @@ -14,6 +14,7 @@ import Rules.Libffi (libffiName) import qualified Data.Set as Set import System.Directory import Data.Version.Extra +import Hadrian.Semaphore ( getJsemSemaphore, globalSemaphore ) ghcBuilderArgs :: Args ghcBuilderArgs = mconcat @@ -41,28 +42,40 @@ toolArgs = do , map ("-optP" ++) <$> getContextData cppOpts ] + compileAndLinkHs :: Args -compileAndLinkHs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do +compileAndLinkHs = (builder (Ghc . CompileHs) ||^ builder (Ghc LinkHs)) ? do ways <- getLibraryWays useColor <- shakeColor <$> expr getShakeOptions let hasVanilla = elem vanilla ways hasDynamic = elem dynamic ways mconcat [ arg "-Wall" , arg "-Wcompat" - , not useColor ? builder (Ghc CompileHs) ? + , not useColor ? builder (Ghc . CompileHs) ? -- N.B. Target.trackArgument ignores this argument from the -- input hash to avoid superfluous recompilation, avoiding -- #18672. arg "-fdiagnostics-color=never" - , (hasVanilla && hasDynamic) ? builder (Ghc CompileHs) ? + , (hasVanilla && hasDynamic) ? builder (Ghc . CompileHs) ? platformSupportsSharedLibs ? way vanilla ? arg "-dynamic-too" , commonGhcArgs , ghcLinkArgs , defaultGhcWarningsArgs - , builder (Ghc CompileHs) ? arg "-c" + , builder (Ghc (CompileHs GhcOneShot)) ? mconcat [ + arg "-c" ] + , builder (Ghc (CompileHs GhcMake)) ? do + jsem <- expr getJsemSemaphore + mconcat + ([ arg "--make" + , arg "-no-link" + ] + ++ globalSemaphore [] (\name _ -> [ arg "-jsem", arg name ]) jsem) , getInputs - , arg "-o", arg =<< getOutput ] + , notM (builder (Ghc (CompileHs GhcMake))) ? mconcat + [arg "-o", arg =<< getOutput] + ] + compileC :: Args compileC = builder (Ghc CompileCWithGhc) ? do ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -13,7 +13,6 @@ packageArgs :: Args packageArgs = do stage <- getStage path <- getBuildPath - root <- getBuildRoot compilerPath <- expr $ buildPath (vanillaContext stage compiler) let -- Do not bind the result to a Boolean: this forces the configure rule @@ -51,7 +50,13 @@ packageArgs = do , package compiler ? mconcat [ builder Alex ? arg "--latin1" - , builder (Ghc CompileHs) ? mconcat + -- These files take a very long time to compile with -O1, + -- so we use -O0 for them just in Stage0 to speed up the + -- build but not affect Stage1+ executables + , builder (Ghc (CompileHs GhcOneShot)) ? inputs ["**/GHC/Hs/Instances.hs", "**/GHC/Driver/Session.hs"] ? stage0 ? + pure ["-O0"] + + , builder (Ghc . CompileHs) ? mconcat [ debugAssertions stage ? arg "-DDEBUG" , inputs ["**/GHC.hs", "**/GHC/Driver/Make.hs"] ? arg "-fprof-auto" @@ -59,12 +64,7 @@ packageArgs = do pure ["-fno-ignore-interface-pragmas", "-fcmm-sink"] -- Enable -haddock and -Winvalid-haddock for the compiler , arg "-haddock" - , notStage0 ? arg "-Winvalid-haddock" - -- These files take a very long time to compile with -O1, - -- so we use -O0 for them just in Stage0 to speed up the - -- build but not affect Stage1+ executables - , inputs ["**/GHC/Hs/Instances.hs", "**/GHC/Driver/Session.hs"] ? stage0 ? - pure ["-O0"] ] + , notStage0 ? arg "-Winvalid-haddock" ] , builder (Cabal Setup) ? mconcat [ arg "--disable-library-for-ghci" ===================================== testsuite/tests/driver/jsem/Main.hs ===================================== @@ -0,0 +1,243 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeApplications #-} + +module Main ( main ) where + +-- base +import Control.Concurrent + ( forkIO, threadDelay, killThread + , newEmptyMVar, takeMVar, putMVar ) +import Control.Monad + ( (>=>), forM, when ) +import Data.Foldable + ( fold, forM_ ) +import System.Console.GetOpt + ( OptDescr(..), ArgDescr(..), ArgOrder(..) + , getOpt ) +import System.Environment + ( getArgs, getExecutablePath ) +import Text.Read + ( readMaybe ) + +-- ghc +import GHC.Driver.MakeSem + ( runJSemAbstractSem ) +import GHC.Utils.IO.Semaphore + ( Semaphore, SemaphoreName(..) + , createSemaphore, destroySemaphore + , waitOnSemaphore, releaseSemaphore + , getSemaphoreValue + , AbstractSem(..), withAbstractSem + ) +import GHC.Utils.Logger + ( Logger, initLogger, logDumpMsg ) +import GHC.Utils.Outputable + ( ppr, empty ) + +-- exceptions +import Control.Monad.Catch + ( SomeException, onException + , bracket, bracket_, mask + , try, throwM ) + +-- process +import System.Process + ( callProcess ) + +-- stm +import Control.Concurrent.STM + ( atomically + , newTVarIO, readTVar, stateTVar ) + +-- containers +import Data.Tree + ( Tree(..), unfoldTree ) + +-------------------------------------------------------------------------------- + +withNewSem :: Logger -> Int -> SemaphoreName -> (Semaphore -> IO a) -> IO a +withNewSem logger n nm act = bracket enter exit act + where + enter = createSemaphore nm n + exit sem = do + v <- getSemaphoreValue sem + logDumpMsg logger "exit" (ppr v) + destroySemaphore sem + +runWithAbstractSem :: Logger + -> SemaphoreName -> Maybe Int + -> (AbstractSem -> IO a) -> IO a +runWithAbstractSem logger nm mb_sz act = + case mb_sz of + Nothing -> runJSemAbstractSem logger nm act + Just n -> withNewSem logger n nm \ sem -> + let + acquire = do + logDumpMsg logger "acquire {" empty + waitOnSemaphore sem + logDumpMsg logger "acquire }" empty + release = do + logDumpMsg logger "release {" empty + let toks_release = 1 + toks_before <- releaseSemaphore sem toks_release + logDumpMsg logger "release }" (ppr $ toks_before + toks_release) + in act (AbstractSem { acquireSem = acquire + , releaseSem = release }) + +type Job a = Tree a + +semChecker :: Int -> (a -> IO ()) -> IO (a -> IO (), IO ()) +semChecker n act = do + tv <- newTVarIO 0 + let + check b msg = unless b . throwM . userError $ msg + woggle f = do + r <- atomically $ stateTVar tv $ \x -> (f x, x) + check (r >= 0 && r <= n) $ "semChecker:sem out of bounds:" <> show r + + enter = woggle (+ 1) + exit = woggle (subtract 1) + + check_final = readTVar tv >>= \x -> check (x == 0) $ "semChecker:check_final:" <> show x + pure (\a -> bracket_ enter exit (act a), atomically check_final) + +-- | Executes job and blocks until it completes. +-- Throws exception on failure +-- All threads forked are joined before return +runJob :: AbstractSem -> (a -> IO ()) -> (Job a -> IO ()) -> Job a -> IO () +runJob sem act_leaf act (Node { rootLabel, subForest }) = + mask $ \unmask -> withAbstractSem sem $ do + rs <- forM subForest $ \a -> do + mv <- newEmptyMVar + tid <- forkIO $ try @_ @SomeException (unmask $ act a) >>= putMVar mv + pure (mv, tid) + let + workload = do + act_leaf rootLabel + forM_ rs $ \(mv,_) -> takeMVar mv >>= either throwM pure + unmask workload `onException` forM rs (\(_,tid) -> killThread tid) + + +runJobLocal :: AbstractSem -> (a -> IO ()) -> Job a -> IO () +runJobLocal sem act j = runJob sem act (runJobLocal sem act) j + +runJobSubprocess :: Show a => Options -> AbstractSem -> (a -> IO ()) -> Job a -> IO () +runJobSubprocess ( Options { exeName = exe + , semName = sem_nm + , semSize = sz } ) + sem act j0 + = runJob sem act go j0 + where + go j = + withAbstractSem sem $ + callProcess exe + [ "-n " <> getSemaphoreName sem_nm + , "-s " <> show sz + , "-j " <> show j ] + +--runJobWithSem :: Int -> Semaphore -> (a -> IO ()) -> Job a -> IO () +--runJobWithSem semSize s act j +-- = bracket (semChecker semSize act) (\(_,x) -> x) $ \(sem_checker,_) -> do +-- let ab_sem = undefined s +-- runJob s sem_checker j + + +main :: IO () +main = do + opts@( Options{ semName + , semSize + , job + , delegate } ) <- getOptions + + logger <- initLogger + + (sem_checker, check_final) <- let + act_leaf = threadDelay + in semChecker semSize act_leaf + + runWithAbstractSem logger semName (Just semSize) $ \sem -> do + let + go j | delegate = runJobSubprocess opts sem sem_checker j + | otherwise = runJobLocal sem sem_checker j + runJob sem sem_checker go job + check_final + +------------------------------------------- +-- Command line argument handling. + +data Options = Options + { isLeader :: !Bool -- TODO: unused + , semName :: !SemaphoreName + , job :: !(Job Int) + , semSize :: !Int + , delegate :: !Bool + , exeName :: !FilePath + } + +defaultOptions :: IO Options +defaultOptions = do + exe_nm <- getExecutablePath + pure $ + Options + { isLeader = False + , semName = SemaphoreName "jsemsem" + , job = pure 1 + , semSize = 10 + , delegate = True + , exeName = exe_nm + } + +newtype OptionsBuilder = + OptionsBuilder { buildOptions :: Options -> IO Options } + +instance Semigroup OptionsBuilder where + OptionsBuilder x <> OptionsBuilder y = OptionsBuilder $ x >=> y + +instance Monoid OptionsBuilder where + mempty = OptionsBuilder pure + +setSemName :: String -> OptionsBuilder +setSemName sem_nm = OptionsBuilder $ \ o -> + pure $ o { semName = SemaphoreName sem_nm } + +setJobToDo :: String -> OptionsBuilder +setJobToDo job_str = OptionsBuilder $ \ o -> + case readMaybe job_str of + Nothing -> throwM $ userError $ "failed to parse job: " <> job_str + Just j -> pure $ o { job = j } + +setSemSize :: String -> OptionsBuilder +setSemSize sz_str = OptionsBuilder $ \ o -> + case readMaybe sz_str of + Nothing -> throwM $ userError $ "failed to parse size: " <> sz_str + Just sz -> pure $ o { semSize = sz } + +topJob :: Int -> Job Int +topJob n = unfoldTree go n where + go x | x <= 1 = (0, []) + | otherwise = (x `div` 2, take n (repeat x)) + +topJobOptionsBuilder :: OptionsBuilder +topJobOptionsBuilder = OptionsBuilder $ \ o -> + pure $ o { job = topJob 5, isLeader = True } + +options :: [OptDescr OptionsBuilder] +options = [sem_name, sem_size, job, topjob] + where + sem_name = Option ['n'] ["sem-name"] (ReqArg setSemName "SEMNAME") "name of the semaphore" + job = Option ['j'] ["job"] (ReqArg setJobToDo "JOB" ) "job to do" + topjob = Option ['t'] ["topjob"] (NoArg topJobOptionsBuilder ) "default top job" + sem_size = Option ['s'] ["sem-size"] (ReqArg setSemSize "SEMSIZE") "number of slots in the semaphore" + +getOptions :: IO Options +getOptions = do + args <- getArgs + case getOpt RequireOrder options args of + ([os],[],[]) -> defaultOptions >>= buildOptions os + (_,uos,errs) -> throwM $ userError $ fold $ + [ "Parsing options failed:" ] + <> [ "unrecognised option:" <> o | o <- uos ] + <> [ "error: " <> e | e <- errs ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6367d03cc2a45f412bf5f8ae80e3e7669836808b...9644da47cd44eaeadb97ac0ba6ad8ae99e201983 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6367d03cc2a45f412bf5f8ae80e3e7669836808b...9644da47cd44eaeadb97ac0ba6ad8ae99e201983 You're receiving 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 Sep 29 15:35:01 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 29 Sep 2022 11:35:01 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] 3 commits: Clean up `findWiredInUnit`. In particular, avoid `head`. Message-ID: <6335bb25cf5e7_2c975751400100124b@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: 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`. - - - - - 683c166b by Simon Peyton Jones at 2022-09-29T16:37:03+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, with (sadly) a 0.5% upward trend. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ------------------------------------- Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +4.4% BAD T10421a(normal) +6.1% T10547(normal) +1.8% T11195(normal) +1.2% T11303b(normal) +1.2% T11822(normal) +1.0% T13253(normal) +1.7% T15304(normal) -1.3% T16577(normal) +3.3% BAD T17516(normal) +2.4% T17977b(normal) +1.2% T5837(normal) +1.6% T8095(normal) -1.2% T9198(normal) +1.1% T9961(normal) +2.8% BAD hard_hole_fits(normal) +1.0% geo. mean +0.5% minimum -1.7% maximum +6.1% Metric Increase: T10421 T16577 T9961 - - - - - 15 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Utils/Lexeme.hs - testsuite/tests/lib/integer/Makefile - + testsuite/tests/simplCore/should_compile/T21851.hs - + testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851a.hs - + testsuite/tests/simplCore/should_compile/T22097.hs - + testsuite/tests/simplCore/should_compile/T22097.stderr - + testsuite/tests/simplCore/should_compile/T22097a.hs - testsuite/tests/simplCore/should_compile/T6056.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1919,7 +1919,9 @@ wrapJoinCont env cont thing_inside -------------------- -trimJoinCont :: Id -> Maybe JoinArity -> SimplCont -> SimplCont +trimJoinCont :: Id -- Used only in error message + -> Maybe JoinArity + -> SimplCont -> SimplCont -- Drop outer context from join point invocation (jump) -- See Note [Join points and case-of-case] @@ -2017,6 +2019,17 @@ outside. Surprisingly tricky! Variables * * ************************************************************************ + +Note [zapSubstEnv] +~~~~~~~~~~~~~~~~~~ +When simplifying something that has already been simplified, be sure to +zap the SubstEnv. This is VITAL. Consider + let x = e in + let y = \z -> ...x... in + \ x -> ...y... + +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!! -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2035,86 +2048,28 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont = case substId env var of - ContEx tvs cvs ids e -> - let env' = setSubstEnv env tvs cvs ids - in simplExprF env' e cont - -- Don't trim; haven't already simplified e, - -- so the cont is not embodied in e - - DoneId var1 -> do - logger <- getLogger - let cont' = trimJoinCont var (isJoinId_maybe var1) cont - completeCall logger env var1 cont' - - DoneEx e mb_join -> - let env' = zapSubstEnv env - cont' = trimJoinCont var mb_join cont - in simplExprF env' e cont' - -- Note [zapSubstEnv] - -- ~~~~~~~~~~~~~~~~~~ - -- The template is already simplified, so don't re-substitute. - -- This is VITAL. Consider - -- let x = e in - -- let y = \z -> ...x... in - -- \ x -> ...y... - -- 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!! - ---------------------------------------------------------- --- Dealing with a call site - -completeCall :: Logger -> SimplEnv -> OutId -> SimplCont -> SimplM (SimplFloats, OutExpr) -completeCall logger env var cont - | Just expr <- callSiteInline logger uf_opts case_depth var active_unf - lone_variable arg_infos interesting_cont - -- Inline the variable's RHS - = do { checkedTick (UnfoldingDone var) - ; dump_inline expr cont - ; let env1 = zapSubstEnv env - ; simplExprF env1 expr cont } - - | otherwise - -- Don't inline; instead rebuild the call - = do { rule_base <- getSimplRules - ; let rules = getRules rule_base var - info = mkArgInfo env var rules - n_val_args call_cont - ; rebuildCall env info cont } + ContEx tvs cvs ids e -> simplExprF env' e cont + -- Don't trimJoinCont; haven't already simplified e, + -- so the cont is not embodied in e + where + env' = setSubstEnv env tvs cvs ids - where - uf_opts = seUnfoldingOpts env - case_depth = seCaseDepth env - (lone_variable, arg_infos, call_cont) = contArgs cont - n_val_args = length arg_infos - interesting_cont = interestingCallContext env call_cont - active_unf = activeUnfolding (seMode env) var + DoneId var1 -> + do { rule_base <- getSimplRules + ; let cont' = trimJoinCont var1 (isJoinId_maybe var1) cont + info = mkArgInfo env rule_base var1 cont' + ; rebuildCall env info cont' } - log_inlining doc - = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify) - Opt_D_dump_inlinings - "" FormatText doc + DoneEx e mb_join -> simplExprF env' e cont' + where + cont' = trimJoinCont var mb_join cont + env' = zapSubstEnv env -- See Note [zapSubstEnv] - dump_inline unfolding cont - | not (logHasDumpFlag logger Opt_D_dump_inlinings) = return () - | not (logHasDumpFlag logger Opt_D_verbose_core2core) - = when (isExternalName (idName var)) $ - log_inlining $ - sep [text "Inlining done:", nest 4 (ppr var)] - | otherwise - = log_inlining $ - sep [text "Inlining done: " <> ppr var, - nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), - text "Cont: " <+> ppr cont])] +--------------------------------------------------------- +-- Dealing with a call site -rebuildCall :: SimplEnv - -> ArgInfo - -> SimplCont +rebuildCall :: SimplEnv -> ArgInfo -> SimplCont -> SimplM (SimplFloats, OutExpr) --- We decided not to inline, so --- - simplify the arguments --- - try rewrite rules --- - and rebuild ---------- Bottoming applications -------------- rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_dmds = [] }) cont @@ -2137,27 +2092,48 @@ rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args, ai_dmds = [] }) con res = argInfoExpr fun rev_args cont_ty = contResultType cont ----------- Try rewrite RULES -------------- --- See Note [Trying rewrite rules] +---------- Try inlining, if ai_rewrite = TryInlining -------- +-- In the TryInlining case we try inlining immediately, before simplifying +-- any (more) arguments. Why? See Note [Rewrite rules and inlining]. +-- +-- If there are rewrite rules we'll skip this case until we have +-- simplified enough args to satisfy nr_wanted==0 in the TryRules case below +-- Then we'll try the rules, and if that fails, we'll do TryInlining +rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args + , ai_rewrite = TryInlining }) cont + = do { logger <- getLogger + ; let full_cont = pushSimplifiedRevArgs env rev_args cont + ; mb_inline <- tryInlining env logger fun full_cont + ; case mb_inline of + Just expr -> do { checkedTick (UnfoldingDone fun) + ; let env1 = zapSubstEnv env + ; simplExprF env1 expr full_cont } + Nothing -> rebuildCall env (info { ai_rewrite = TryNothing }) cont + } + +---------- Try rewrite RULES, if ai_rewrite = TryRules -------------- +-- See Note [Rewrite rules and inlining] +-- See also Note [Trying rewrite rules] rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args - , ai_rules = Just (nr_wanted, rules) }) cont + , ai_rewrite = TryRules nr_wanted rules }) cont | nr_wanted == 0 || no_more_args - , let info' = info { ai_rules = Nothing } = -- We've accumulated a simplified call in -- so try rewrite rules; see Note [RULES apply to simplified arguments] -- See also Note [Rules for recursive functions] do { mb_match <- tryRules env rules fun (reverse rev_args) cont ; case mb_match of Just (env', rhs, cont') -> simplExprF env' rhs cont' - Nothing -> rebuildCall env info' cont } + Nothing -> rebuildCall env (info { ai_rewrite = TryInlining }) cont } where + -- If we have run out of arguments, just try the rules; there might + -- be some with lower arity. Casts get in the way -- they aren't + -- allowed on rule LHSs no_more_args = case cont of ApplyToTy {} -> False ApplyToVal {} -> False _ -> True - ----------- Simplify applications and casts -------------- +---------- Simplify type applications and casts -------------- rebuildCall env info (CastIt co cont) = rebuildCall env (addCastTo info co) cont @@ -2202,6 +2178,7 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) call' = mkApps (Var fun_id) [mkTyArg rr', mkTyArg ty', arg'] ; return (emptyFloats env, call') } +---------- Simplify value arguments -------------------- rebuildCall env fun_info (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_dup = dup_flag, sc_hole_ty = fun_ty @@ -2237,6 +2214,42 @@ rebuildCall env fun_info rebuildCall env (ArgInfo { ai_fun = fun, ai_args = rev_args }) cont = rebuild env (argInfoExpr fun rev_args) cont +----------------------------------- +tryInlining :: SimplEnv -> Logger -> OutId -> SimplCont -> SimplM (Maybe OutExpr) +tryInlining env logger var cont + | Just expr <- callSiteInline logger uf_opts case_depth var active_unf + lone_variable arg_infos interesting_cont + = do { dump_inline expr cont + ; return (Just expr) } + + | otherwise + = return Nothing + + where + uf_opts = seUnfoldingOpts env + case_depth = seCaseDepth env + (lone_variable, arg_infos, call_cont) = contArgs cont + interesting_cont = interestingCallContext env call_cont + active_unf = activeUnfolding (seMode env) var + + log_inlining doc + = liftIO $ logDumpFile logger (mkDumpStyle alwaysQualify) + Opt_D_dump_inlinings + "" FormatText doc + + dump_inline unfolding cont + | not (logHasDumpFlag logger Opt_D_dump_inlinings) = return () + | not (logHasDumpFlag logger Opt_D_verbose_core2core) + = when (isExternalName (idName var)) $ + log_inlining $ + sep [text "Inlining done:", nest 4 (ppr var)] + | otherwise + = log_inlining $ + sep [text "Inlining done: " <> ppr var, + nest 4 (vcat [text "Inlined fn: " <+> nest 2 (ppr unfolding), + text "Cont: " <+> ppr cont])] + + {- Note [Trying rewrite rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider an application (f e1 e2 e3) where the e1,e2,e3 are not yet @@ -2272,6 +2285,38 @@ makes a particularly big difference when superclass selectors are involved: op ($p1 ($p2 (df d))) We want all this to unravel in one sweep. +Note [Rewrite rules and inlining] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In general we try to arrange that inlining is disabled (via a pragma) if +a rewrite rule should apply, so that the rule has a decent chance to fire +before we inline the function. + +But it turns out that (especially when type-class specialisation or +SpecConstr is involved) it is very helpful for the the rewrite rule to +"win" over inlining when both are active at once: see #21851, #22097. + +The simplifier arranges to do this, as follows. In effect, the ai_rewrite +field of the ArgInfo record is the state of a little state-machine: + +* mkArgInfo sets the ai_rewrite field to TryRules if there are any rewrite + rules avaialable for that function. + +* rebuildCall simplifies arguments until enough are simplified to match the + rule with greatest arity. See Note [RULES apply to simplified arguments] + and the first field of `TryRules`. + + But no more! As soon as we have simplified enough arguments to satisfy the + maximum-arity rules, we try the rules; see Note [Trying rewrite rules]. + +* Once we have tried rules (or immediately if there are no rules) set + ai_rewrite to TryInlining, and the Simplifier will try to inline the + function. We want to try this immediately (before simplifying any (more) + arguments). Why? Consider + f BIG where f = \x{OneOcc}. ...x... + If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, + and we'll simplify BIG once, at x's occurrence, rather than twice. + + Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Because RULES apply to simplified arguments, there's a danger of repeatedly @@ -2327,7 +2372,8 @@ See Note [No free join points in arityType] in GHC.Core.Opt.Arity -} tryRules :: SimplEnv -> [CoreRule] - -> Id -> [ArgSpec] + -> Id + -> [ArgSpec] -- In /normal, forward/ order -> SimplCont -> SimplM (Maybe (SimplEnv, CoreExpr, SimplCont)) @@ -3668,7 +3714,7 @@ mkDupableStrictBind env arg_bndr join_rhs res_ty | otherwise = do { join_bndr <- newJoinId [arg_bndr] res_ty ; let arg_info = ArgInfo { ai_fun = join_bndr - , ai_rules = Nothing, ai_args = [] + , ai_rewrite = TryNothing, ai_args = [] , ai_encl = False, ai_dmds = repeat topDmd , ai_discs = repeat 0 } ; return ( addJoinFloats (emptyFloats env) $ ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -30,9 +30,10 @@ module GHC.Core.Opt.Simplify.Utils ( interestingCallContext, -- ArgInfo - ArgInfo(..), ArgSpec(..), mkArgInfo, + ArgInfo(..), ArgSpec(..), RewriteCall(..), mkArgInfo, addValArgTo, addCastTo, addTyArgTo, - argInfoExpr, argInfoAppArgs, pushSimplifiedArgs, + argInfoExpr, argInfoAppArgs, + pushSimplifiedArgs, pushSimplifiedRevArgs, isStrictArgInfo, lazyArgContext, abstractFloats, @@ -52,6 +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.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make @@ -210,6 +212,7 @@ data SimplCont type StaticEnv = SimplEnv -- Just the static part is relevant +-- See Note [DupFlag invariants] data DupFlag = NoDup -- Unsimplified, might be big | Simplified -- Simplified | OkToDup -- Simplified and small @@ -226,8 +229,9 @@ perhapsSubstTy dup env ty {- Note [StaticEnv invariant] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We pair up an InExpr or InAlts with a StaticEnv, which establishes the -lexical scope for that InExpr. When we simplify that InExpr/InAlts, we -use +lexical scope for that InExpr. + +When we simplify that InExpr/InAlts, we use - Its captured StaticEnv - Overriding its InScopeSet with the larger one at the simplification point. @@ -244,13 +248,14 @@ isn't big enough. Note [DupFlag invariants] ~~~~~~~~~~~~~~~~~~~~~~~~~ -In both (ApplyToVal dup _ env k) - and (Select dup _ _ env k) +In both ApplyToVal { se_dup = dup, se_env = env, se_cont = k} + and Select { se_dup = dup, se_env = env, se_cont = k} the following invariants hold (a) if dup = OkToDup, then continuation k is also ok-to-dup - (b) if dup = OkToDup or Simplified, the subst-env is empty - (and hence no need to re-simplify) + (b) if dup = OkToDup or Simplified, the subst-env is empty, + or at least is always ignored; the payload is + already an OutThing -} instance Outputable DupFlag where @@ -309,7 +314,8 @@ data ArgInfo ai_fun :: OutId, -- The function ai_args :: [ArgSpec], -- ...applied to these args (which are in *reverse* order) - ai_rules :: FunRules, -- Rules for this function + ai_rewrite :: RewriteCall, -- What transformation to try next for this call + -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration ai_encl :: Bool, -- Flag saying whether this function -- or an enclosing one has rules (recursively) @@ -325,6 +331,12 @@ data ArgInfo -- Always infinite } +data RewriteCall -- What rewriting to try next for this call + -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration + = TryRules FullArgCount [CoreRule] + | TryInlining + | TryNothing + data ArgSpec = ValArg { as_dmd :: Demand -- Demand placed on this argument , as_arg :: OutExpr -- Apply to this (coercion or value); c.f. ApplyToVal @@ -349,20 +361,20 @@ instance Outputable ArgSpec where addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo addValArgTo ai arg hole_ty - | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rules = rules } <- ai + | ArgInfo { ai_dmds = dmd:dmds, ai_discs = _:discs, ai_rewrite = rew } <- ai -- Pop the top demand and and discounts off , let arg_spec = ValArg { as_arg = arg, as_hole_ty = hole_ty, as_dmd = dmd } - = ai { ai_args = arg_spec : ai_args ai - , ai_dmds = dmds - , ai_discs = discs - , ai_rules = decRules rules } + = ai { ai_args = arg_spec : ai_args ai + , ai_dmds = dmds + , ai_discs = discs + , ai_rewrite = decArgCount rew } | otherwise = pprPanic "addValArgTo" (ppr ai $$ ppr arg) -- There should always be enough demands and discounts addTyArgTo :: ArgInfo -> OutType -> OutType -> ArgInfo -addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai - , ai_rules = decRules (ai_rules ai) } +addTyArgTo ai arg_ty hole_ty = ai { ai_args = arg_spec : ai_args ai + , ai_rewrite = decArgCount (ai_rewrite ai) } where arg_spec = TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } @@ -381,19 +393,22 @@ argInfoAppArgs (CastBy {} : _) = [] -- Stop at a cast argInfoAppArgs (ValArg { as_arg = arg } : as) = arg : argInfoAppArgs as argInfoAppArgs (TyArg { as_arg_ty = ty } : as) = Type ty : argInfoAppArgs as -pushSimplifiedArgs :: SimplEnv -> [ArgSpec] -> SimplCont -> SimplCont -pushSimplifiedArgs _env [] k = k -pushSimplifiedArgs env (arg : args) k - = case arg of - TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty } - -> ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = rest } - ValArg { as_arg = arg, as_hole_ty = hole_ty } - -> ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified - , sc_hole_ty = hole_ty, sc_cont = rest } - CastBy c -> CastIt c rest - where - rest = pushSimplifiedArgs env args k - -- The env has an empty SubstEnv +pushSimplifiedArgs, pushSimplifiedRevArgs + :: SimplEnv + -> [ArgSpec] -- In normal, forward order for pushSimplifiedArgs, + -- in /reverse/ order for pushSimplifiedRevArgs + -> SimplCont -> SimplCont +pushSimplifiedArgs env args cont = foldr (pushSimplifiedArg env) cont args +pushSimplifiedRevArgs env args cont = foldl (\k a -> pushSimplifiedArg env a k) cont args + +pushSimplifiedArg :: SimplEnv -> ArgSpec -> SimplCont -> SimplCont +pushSimplifiedArg _env (TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty }) cont + = ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = cont } +pushSimplifiedArg env (ValArg { as_arg = arg, as_hole_ty = hole_ty }) cont + = ApplyToVal { sc_arg = arg, sc_env = env, sc_dup = Simplified + -- The SubstEnv will be ignored since sc_dup=Simplified + , sc_hole_ty = hole_ty, sc_cont = cont } +pushSimplifiedArg _ (CastBy c) cont = CastIt c cont argInfoExpr :: OutId -> [ArgSpec] -> OutExpr -- NB: the [ArgSpec] is reversed so that the first arg @@ -406,18 +421,14 @@ argInfoExpr fun rev_args go (TyArg { as_arg_ty = ty } : as) = go as `App` Type ty go (CastBy co : as) = mkCast (go as) co +decArgCount :: RewriteCall -> RewriteCall +decArgCount (TryRules n rules) = TryRules (n-1) rules +decArgCount rew = rew -type FunRules = Maybe (Int, [CoreRule]) -- Remaining rules for this function - -- Nothing => No rules - -- Just (n, rules) => some rules, requiring at least n more type/value args - -decRules :: FunRules -> FunRules -decRules (Just (n, rules)) = Just (n-1, rules) -decRules Nothing = Nothing - -mkFunRules :: [CoreRule] -> FunRules -mkFunRules [] = Nothing -mkFunRules rs = Just (n_required, rs) +mkTryRules :: [CoreRule] -> RewriteCall +-- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration +mkTryRules [] = TryInlining +mkTryRules rs = TryRules n_required rs where n_required = maximum (map ruleArity rs) @@ -516,6 +527,7 @@ contHoleScaling (StrictArg { sc_fun_ty = fun_ty, sc_cont = k }) contHoleScaling (ApplyToTy { sc_cont = k }) = contHoleScaling k contHoleScaling (ApplyToVal { sc_cont = k }) = contHoleScaling k contHoleScaling (TickIt _ k) = contHoleScaling k + ------------------- countArgs :: SimplCont -> Int -- Count all arguments, including types, coercions, @@ -525,6 +537,14 @@ countArgs (ApplyToVal { sc_cont = cont }) = 1 + countArgs cont countArgs (CastIt _ cont) = countArgs cont countArgs _ = 0 +countValArgs :: SimplCont -> Int +-- Count value arguments only +countValArgs (ApplyToTy { sc_cont = cont }) = 1 + countValArgs cont +countValArgs (ApplyToVal { sc_cont = cont }) = 1 + countValArgs cont +countValArgs (CastIt _ cont) = countValArgs cont +countValArgs _ = 0 + +------------------- contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont) -- Summarises value args, discards type args and coercions -- The returned continuation of the call is only used to @@ -579,29 +599,26 @@ contEvalContext k = case k of -- and case binder dmds, see addCaseBndrDmd. No priority right now. ------------------- -mkArgInfo :: SimplEnv - -> Id - -> [CoreRule] -- Rules for function - -> Int -- Number of value args - -> SimplCont -- Context of the call - -> ArgInfo - -mkArgInfo env fun rules n_val_args call_cont +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_rules = fun_rules + , ai_rewrite = fun_rules , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rules = fun_rules - , ai_encl = interestingArgContext rules call_cont + , ai_rewrite = fun_rules + , ai_encl = notNull rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - fun_rules = mkFunRules rules + rules = getRules rule_base fun + fun_rules = mkTryRules rules + n_val_args = countValArgs cont vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 @@ -814,7 +831,7 @@ interestingCallContext env cont -- a build it's *great* to inline it here. So we must ensure that -- the context for (f x) is not totally uninteresting. -interestingArgContext :: [CoreRule] -> SimplCont -> Bool +contHasRules :: SimplCont -> Bool -- If the argument has form (f x y), where x,y are boring, -- and f is marked INLINE, then we don't want to inline f. -- But if the context of the argument is @@ -822,33 +839,29 @@ interestingArgContext :: [CoreRule] -> SimplCont -> Bool -- where g has rules, then we *do* want to inline f, in case it -- exposes a rule that might fire. Similarly, if the context is -- h (g (f x x)) --- where h has rules, then we do want to inline f; hence the --- call_cont argument to interestingArgContext +-- where h has rules, then we do want to inline f. So contHasRules +-- tries to see if the context of the f-call is a call to a function +-- with rules. -- --- The ai-rules flag makes this happen; if it's +-- The ai_encl flag makes this happen; if it's -- set, the inliner gets just enough keener to inline f -- regardless of how boring f's arguments are, if it's marked INLINE -- -- The alternative would be to *always* inline an INLINE function, -- regardless of how boring its context is; but that seems overkill -- For example, it'd mean that wrapper functions were always inlined --- --- The call_cont passed to interestingArgContext is the context of --- the call itself, e.g. g in the example above -interestingArgContext rules call_cont - = notNull rules || enclosing_fn_has_rules +contHasRules cont + = go cont where - enclosing_fn_has_rules = go call_cont - - go (Select {}) = False - go (ApplyToVal {}) = False -- Shouldn't really happen - go (ApplyToTy {}) = False -- Ditto - go (StrictArg { sc_fun = fun }) = ai_encl fun - go (StrictBind {}) = False -- ?? - go (CastIt _ c) = go c - go (Stop _ RuleArgCtxt _) = True - go (Stop _ _ _) = False - go (TickIt _ c) = go c + go (ApplyToVal { sc_cont = cont }) = go cont + go (ApplyToTy { sc_cont = cont }) = go cont + go (CastIt _ cont) = go cont + go (StrictArg { sc_fun = fun }) = ai_encl fun + go (Stop _ RuleArgCtxt _) = True + go (TickIt _ c) = go c + go (Select {}) = False + go (StrictBind {}) = False -- ?? + go (Stop _ _ _) = False {- Note [Interesting arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -82,7 +82,6 @@ module GHC.Data.FastString lengthFS, nullFS, appendFS, - headFS, concatFS, consFS, nilFS, @@ -609,11 +608,6 @@ appendFS fs1 fs2 = mkFastStringShortByteString concatFS :: [FastString] -> FastString concatFS = mkFastStringShortByteString . mconcat . map fs_sbs -headFS :: FastString -> Char -headFS fs - | SBS.null $ fs_sbs fs = panic "headFS: Empty FastString" -headFS fs = head $ unpackFS fs - consFS :: Char -> FastString -> FastString consFS c fs = mkFastString (c : unpackFS fs) ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -519,7 +519,9 @@ parenSymOcc occ doc | isSymOcc occ = parens doc startsWithUnderscore :: OccName -> Bool -- ^ Haskell 98 encourages compilers to suppress warnings about unused -- names in a pattern if they start with @_@: this implements that test -startsWithUnderscore occ = headFS (occNameFS occ) == '_' +startsWithUnderscore occ = case unconsFS (occNameFS occ) of + Just ('_', _) -> True + _ -> False {- ************************************************************************ ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -1105,31 +1105,29 @@ findWiredInUnits logger prec_map pkgs vis_map = do -- available. -- findWiredInUnit :: [UnitInfo] -> UnitId -> IO (Maybe (UnitId, UnitInfo)) - findWiredInUnit pkgs wired_pkg = - let all_ps = [ p | p <- pkgs, p `matches` wired_pkg ] - all_exposed_ps = - [ p | p <- all_ps - , Map.member (mkUnit p) vis_map ] in - case all_exposed_ps of - [] -> case all_ps of - [] -> notfound - many -> pick (head (sortByPreference prec_map many)) - many -> pick (head (sortByPreference prec_map many)) + findWiredInUnit pkgs wired_pkg = firstJustsM [try all_exposed_ps, try all_ps, notfound] where + all_ps = [ p | p <- pkgs, p `matches` wired_pkg ] + all_exposed_ps = [ p | p <- all_ps, Map.member (mkUnit p) vis_map ] + + try ps = case sortByPreference prec_map ps of + p:_ -> Just <$> pick p + _ -> pure Nothing + notfound = do debugTraceMsg logger 2 $ text "wired-in package " <> ftext (unitIdFS wired_pkg) <> text " not found." return Nothing - pick :: UnitInfo -> IO (Maybe (UnitId, UnitInfo)) + pick :: UnitInfo -> IO (UnitId, UnitInfo) pick pkg = do debugTraceMsg logger 2 $ text "wired-in package " <> ftext (unitIdFS wired_pkg) <> text " mapped to " <> ppr (unitId pkg) - return (Just (wired_pkg, pkg)) + return (wired_pkg, pkg) mb_wired_in_pkgs <- mapM (findWiredInUnit pkgs) wiredInUnitIds ===================================== compiler/GHC/Utils/Lexeme.hs ===================================== @@ -67,19 +67,17 @@ isLexId cs = isLexConId cs || isLexVarId cs isLexSym cs = isLexConSym cs || isLexVarSym cs ------------- -isLexConId cs -- Prefix type or data constructors - | nullFS cs = False -- e.g. "Foo", "[]", "(,)" - | cs == (fsLit "[]") = True - | otherwise = startsConId (headFS cs) - -isLexVarId cs -- Ordinary prefix identifiers - | nullFS cs = False -- e.g. "x", "_x" - | otherwise = startsVarId (headFS cs) - -isLexConSym cs -- Infix type or data constructors - | nullFS cs = False -- e.g. ":-:", ":", "->" - | cs == (fsLit "->") = True - | otherwise = startsConSym (headFS cs) +isLexConId cs = case unconsFS cs of -- Prefix type or data constructors + Nothing -> False -- e.g. "Foo", "[]", "(,)" + Just (c, _) -> cs == fsLit "[]" || startsConId c + +isLexVarId cs = case unconsFS cs of -- Ordinary prefix identifiers + Nothing -> False -- e.g. "x", "_x" + Just (c, _) -> startsVarId c + +isLexConSym cs = case unconsFS cs of -- Infix type or data constructors + Nothing -> False -- e.g. ":-:", ":", "->" + Just (c, _) -> cs == fsLit "->" || startsConSym c isLexVarSym fs -- Infix identifiers e.g. "+" | fs == (fsLit "~R#") = True ===================================== testsuite/tests/lib/integer/Makefile ===================================== @@ -11,8 +11,9 @@ CHECK2 = grep -q -- '$1' folding.simpl || \ .PHONY: integerConstantFolding integerConstantFolding: - '$(TEST_HC)' -Wall -v0 -O --make integerConstantFolding -fforce-recomp -ddump-simpl > folding.simpl + '$(TEST_HC)' -Wall -v0 -O --make integerConstantFolding -fforce-recomp -ddump-simpl -dno-debug-output > folding.simpl # All the 100nnn values should be constant-folded away +# -dno-debug-output suppresses a "Glomming" message ! grep -q '\<100[0-9][0-9][0-9]\>' folding.simpl || { echo "Unfolded values found"; grep '\<100[0-9][0-9][0-9]\>' folding.simpl; } $(call CHECK,\<200007\>,plusInteger) $(call CHECK,\<683234160\>,timesInteger) @@ -64,8 +65,9 @@ IntegerConversionRules: .PHONY: naturalConstantFolding naturalConstantFolding: - '$(TEST_HC)' -Wall -v0 -O --make naturalConstantFolding -fforce-recomp -ddump-simpl > folding.simpl + '$(TEST_HC)' -Wall -v0 -O --make naturalConstantFolding -fforce-recomp -ddump-simpl -dno-debug-output > folding.simpl # All the 100nnn values should be constant-folded away +# -dno-debug-output suppresses a "Glomming" message ! grep -q '\<100[0-9][0-9][0-9]\>' folding.simpl || { echo "Unfolded values found"; grep '\<100[0-9][0-9][0-9]\>' folding.simpl; } # Bit arithmetic $(call CHECK,\<532\>,andNatural) ===================================== testsuite/tests/simplCore/should_compile/T21851.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -ddump-simpl #-} + +module T21851 (g') where +import T21851a + +g :: Num a => a -> a +g x = fst (f x) +{-# NOINLINE[99] g #-} + +g' :: Int -> Int +g' = g + +-- We should see a call to a /specialised/ verion of `f`, +-- something like +-- g' = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -0,0 +1,19 @@ +[1 of 2] Compiling T21851a ( T21851a.hs, T21851a.o ) +[2 of 2] Compiling T21851 ( T21851.hs, T21851.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 7, types: 10, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 6, types: 8, coercions: 0, joins: 0/0} +g' :: Int -> Int +[GblId, + Arity=1, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] +g' + = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } + + + ===================================== testsuite/tests/simplCore/should_compile/T21851a.hs ===================================== @@ -0,0 +1,5 @@ +module T21851a where + +f :: Num b => b -> (b, b) -- note: recursive to prevent inlining +f x = (x + 1, snd (f x)) -- on such a small example +{-# SPECIALIZE f :: Int -> (Int, Int) #-} ===================================== testsuite/tests/simplCore/should_compile/T22097.hs ===================================== @@ -0,0 +1,7 @@ +{-# OPTIONS_GHC -ddump-simpl #-} +{-# LANGUAGE TypeApplications #-} +module T22097 where +import T22097a ( isEven ) + +main :: IO () +main = print $ isEven @Int 10 ===================================== testsuite/tests/simplCore/should_compile/T22097.stderr ===================================== @@ -0,0 +1,46 @@ +[1 of 2] Compiling T22097a ( T22097a.hs, T22097a.o ) +[2 of 2] Compiling T22097 ( T22097.hs, T22097.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 15, types: 14, coercions: 3, joins: 0/0} + +-- RHS size: {terms: 5, types: 1, coercions: 0, joins: 0/0} +T22097.main2 :: String +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, + WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}] +T22097.main2 + = case T22097a.$wgoEven 10# of { (# #) -> GHC.Show.$fShowBool4 } + +-- RHS size: {terms: 6, types: 2, coercions: 0, joins: 0/0} +T22097.main1 + :: GHC.Prim.State# GHC.Prim.RealWorld + -> (# GHC.Prim.State# GHC.Prim.RealWorld, () #) +[GblId, + Arity=1, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 40 0}] +T22097.main1 + = \ (eta [OS=OneShot] :: GHC.Prim.State# GHC.Prim.RealWorld) -> + GHC.IO.Handle.Text.hPutStr2 + GHC.IO.Handle.FD.stdout T22097.main2 GHC.Types.True eta + +-- RHS size: {terms: 1, types: 0, coercions: 3, joins: 0/0} +main :: IO () +[GblId, + Arity=1, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] +main + = T22097.main1 + `cast` (Sym (GHC.Types.N:IO[0] <()>_R) + :: (GHC.Prim.State# GHC.Prim.RealWorld + -> (# GHC.Prim.State# GHC.Prim.RealWorld, () #)) + ~R# IO ()) + + + ===================================== testsuite/tests/simplCore/should_compile/T22097a.hs ===================================== @@ -0,0 +1,23 @@ +module T22097a + ( isEven, isOdd ) +where + +{-# SPECIALIZE isEven :: Int -> Bool #-} +isEven :: Integral a => a -> Bool +isEven = fst evenOdd + +{-# SPECIALIZE isOdd :: Int -> Bool #-} +isOdd :: Integral a => a -> Bool +isOdd = snd evenOdd + +evenOdd :: Integral a => (a -> Bool, a -> Bool) +evenOdd = (goEven, goOdd) + where + goEven n + | n < 0 = goEven (- n) + | n > 0 = goOdd (n - 1) + | otherwise = True + + goOdd n + | n < 0 = goOdd n + | otherwise = goEven n ===================================== testsuite/tests/simplCore/should_compile/T6056.stderr ===================================== @@ -1,4 +1,4 @@ Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) -Rule fired: SPEC/T6056 $wsmallerAndRest @Int (T6056) +Rule fired: SPEC/T6056 smallerAndRest @Int (T6056) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -430,3 +430,7 @@ test('T22028', normal, compile, ['-O -ddump-rule-firings']) test('T22114', normal, compile, ['-O']) test('T21286', normal, multimod_compile, ['T21286', '-O -ddump-rule-firings']) +# One module, T21851.hs, has OPTIONS_GHC -ddump-simpl +test('T21851', [grep_errmsg(r'case.*w\$sf') ], multimod_compile, ['T21851', '-O -dno-typeable-binds -dsuppress-uniques']) +# One module, T22097.hs, has OPTIONS_GHC -ddump-simpl +test('T22097', [grep_errmsg(r'case.*wgoEven') ], multimod_compile, ['T22097', '-O -dno-typeable-binds -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6009bbc22049cce35ddebcb3aed22f6737aac83...683c166b191bdea248e9eb069be3a748eb97aad4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a6009bbc22049cce35ddebcb3aed22f6737aac83...683c166b191bdea248e9eb069be3a748eb97aad4 You're receiving 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 Sep 29 16:34:40 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Thu, 29 Sep 2022 12:34:40 -0400 Subject: [Git][ghc/ghc][wip/nr/wasm-translation-prototypes] 4 commits: early Tx prototype with CmmLit Message-ID: <6335c920d00e2_2c97575140010107c5@gitlab.mail> Norman Ramsey pushed to branch wip/nr/wasm-translation-prototypes at Glasgow Haskell Compiler / GHC Commits: 067d1541 by Norman Ramsey at 2022-09-29T10:13:57-04:00 early Tx prototype with CmmLit - - - - - aae3a173 by Norman Ramsey at 2022-09-29T11:34:28-04:00 Tx builds with magic - - - - - 0d1fb92c by Norman Ramsey at 2022-09-29T12:32:52-04:00 a thing that compiles - - - - - 6deab9c1 by Norman Ramsey at 2022-09-29T12:34:25-04:00 clean binary and comparison - - - - - 3 changed files: - compiler/GHC/Wasm/IR.hs - + compiler/GHC/Wasm/Tx.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Wasm/IR.hs ===================================== @@ -2,9 +2,10 @@ {-# LANGUAGE DataKinds, GADTs, RankNTypes, TypeOperators, KindSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeFamilies, ConstraintKinds #-} module GHC.Wasm.IR - ( WasmIR(..), (<>), pattern WasmIf, wasmReturn + ( WasmIR(..), (<>), pattern WasmIf32, wasmReturn , BrTableInterval(..), inclusiveInterval , brTableLimit @@ -19,6 +20,8 @@ where import GHC.Prelude import Data.Kind +import Data.Type.Equality + import GHC.Data.FastString import GHC.Utils.Outputable hiding ((<>)) @@ -31,9 +34,9 @@ Description : Representation of control-flow portion of the WebAssembly instruct -- | WebAssembly type of a WebAssembly value that WebAssembly code -- could either expect on the evaluation stack or leave on the evaluation --- stack. At present we support only 32-bit values. +-- stack. -data WasmType = I32 | F32 +data WasmType = I32 | F32 | I64 | F64 deriving (Eq, Show) @@ -42,6 +45,16 @@ data WasmType = I32 | F32 data WasmTypeTag :: WasmType -> Type where TagI32 :: WasmTypeTag 'I32 TagF32 :: WasmTypeTag 'F32 + TagI64 :: WasmTypeTag 'I64 + TagF64 :: WasmTypeTag 'F64 + +instance TestEquality WasmTypeTag where + TagI32 `testEquality` TagI32 = Just Refl + TagI64 `testEquality` TagI64 = Just Refl + TagF32 `testEquality` TagF32 = Just Refl + TagF64 `testEquality` TagF64 = Just Refl + _ `testEquality` _ = Nothing + -- | List of WebAssembly types used to describe the sequence of WebAssembly -- values that a block of code may expect on the stack or leave on the stack. @@ -64,54 +77,63 @@ data WasmFunctionType pre post = -- | Representation of WebAssembly control flow. -- Normally written as -- @ --- WasmIR pre post +-- WasmIR bool pre post -- @ --- Type parameter `s` is the type of (unspecified) statements. --- It might be instantiated with an open Cmm block or with a sequence --- of Wasm instructions. --- Parameter `e` is the type of expressions. +-- Type parameter `bool` represents the Wasm type of Boolean results -- Parameter `pre` represents the values that are expected on the -- WebAssembly stack when the code runs, and `post` represents -- the state of the stack on completion. -data WasmIR :: [WasmType] -> [WasmType] -> Type where +data WasmIR :: WasmType -> [WasmType] -> [WasmType] -> Type where - WasmPush :: WasmTypeTag t -> WasmIR stack (t ': stack) -> WasmIR stack (t ': stack) + WasmPush :: WasmTypeTag t -> WasmIR bool stack (t ': stack) -> WasmIR bool stack (t ': stack) WasmBlock :: WasmFunctionType pre post - -> WasmIR pre post - -> WasmIR pre post + -> WasmIR bool pre post + -> WasmIR bool pre post WasmLoop :: WasmFunctionType pre post - -> WasmIR pre post - -> WasmIR pre post + -> WasmIR bool pre post + -> WasmIR bool pre post WasmIfTop :: WasmFunctionType pre post - -> WasmIR pre post - -> WasmIR pre post - -> WasmIR ('I32 ': pre) post + -> WasmIR bool pre post + -> WasmIR bool pre post + -> WasmIR bool (bool ': pre) post - WasmBr :: Int -> WasmIR dropped destination -- not typechecked - WasmFallthrough :: WasmIR dropped destination + WasmBr :: Int -> WasmIR bool dropped destination -- not typechecked + WasmFallthrough :: WasmIR bool dropped destination -- generates no code, but has the same type as a branch WasmBrTable :: e -> BrTableInterval -- for testing -> [Int] -- targets -> Int -- default target - -> WasmIR dropped destination + -> WasmIR bool dropped destination -- invariant: the table interval is contained -- within [0 .. pred (length targets)] WasmReturnTop :: WasmTypeTag t - -> WasmIR (t ': t1star) t2star -- as per type system + -> WasmIR bool (t ': t1star) t2star -- as per type system + + WasmActions :: s -> WasmIR bool stack stack -- basic block: one entry, one exit + WasmSeq :: WasmIR bool pre mid -> WasmIR bool mid post -> WasmIR bool pre post + + ---------------------------- + + WasmInt :: WasmTypeTag t -> Integer -> WasmIR bool pre (t : pre) + WasmFloat :: WasmTypeTag t -> Rational -> WasmIR bool pre (t : pre) + + WasmAdd :: WasmTypeTag t -> WasmIR bool (t : t : stack) (t : stack) + WasmSub :: WasmTypeTag t -> WasmIR bool (t : t : stack) (t : stack) + WasmS_Ge :: WasmTypeTag t -> WasmIR bool (t : t : stack) (bool : stack) -- signed >= + + WasmCCall :: SymName -> WasmIR bool pre post -- completely untyped + WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmIR bool (t : pre) pre + WasmLocalGet :: WasmTypeTag t -> Int -> WasmIR bool pre (t : pre) + WasmLocalSet :: WasmTypeTag t -> Int -> WasmIR bool (t : pre) pre - WasmActions :: s -> WasmIR stack stack -- basic block: one entry, one exit - WasmSeq :: WasmIR pre mid -> WasmIR mid post -> WasmIR pre post + WasmLift :: (pre' ~ (t : pre), post' ~ (t : post)) => + WasmTypeTag t -> WasmIR bool pre post -> WasmIR bool pre' post' - WasmAdd :: WasmTypeTag t -> WasmIR (t : t : stack) (t : stack) - WasmCCall :: SymName -> WasmIR pre post -- completely untyped - WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmIR (t : pre) pre - WasmLocalGet :: WasmTypeTag t -> Int -> WasmIR pre (t : pre) - WasmLocalSet :: WasmTypeTag t -> Int -> WasmIR (t : pre) pre data BrTableInterval @@ -139,27 +161,27 @@ inclusiveInterval lo hi BrTableInterval lo count | otherwise = panic "GHC.Wasm.ControlFlow: empty interval" -(<>) :: forall pre mid post - . WasmIR pre mid - -> WasmIR mid post - -> WasmIR pre post +(<>) :: forall bool pre mid post + . WasmIR bool pre mid + -> WasmIR bool mid post + -> WasmIR bool pre post (<>) = WasmSeq -- N.B. Fallthrough can't be optimized away because of type checking. -- Syntactic sugar. -pattern WasmIf :: WasmFunctionType pre post - -> WasmIR pre ('I32 : pre) - -> WasmIR pre post - -> WasmIR pre post - -> WasmIR pre post +pattern WasmIf32 :: WasmFunctionType pre post + -> WasmIR 'I32 pre ('I32 : pre) + -> WasmIR 'I32 pre post + -> WasmIR 'I32 pre post + -> WasmIR 'I32 pre post -pattern WasmIf ty e t f = +pattern WasmIf32 ty e t f = WasmPush TagI32 e `WasmSeq` WasmIfTop ty t f -- More syntactic sugar. -wasmReturn :: WasmTypeTag t -> WasmIR t1star (t : t1star) -> WasmIR t1star t2star +wasmReturn :: WasmTypeTag t -> WasmIR bool t1star (t : t1star) -> WasmIR bool t1star t2star wasmReturn tag e = WasmPush tag e `WasmSeq` WasmReturnTop tag ===================================== compiler/GHC/Wasm/Tx.hs ===================================== @@ -0,0 +1,118 @@ +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE DataKinds, GADTs, RankNTypes, TypeOperators, KindSignatures #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE MultiParamTypeClasses #-} + +module GHC.Wasm.Tx + ( tx + , CG(..) + ) +where + +import GHC.Prelude + +import Data.Type.Equality +--import Data.Kind + +import qualified GHC.Cmm.Type as CT +import GHC.Cmm.Expr +--import GHC.Data.FastString +--import GHC.Utils.Outputable hiding ((<>)) +import GHC.Utils.Panic +import GHC.Wasm.IR + +class Monad (codegen bool) => CG bool codegen where +-- platformWordSize :: m Int +-- asType :: WasmTypeTag t -> m () -- check that type is consistent +-- -- with platform word size +-- asInt :: WasmTypeTag t -> m () -- insist on the platofrm integer type + booleanWasmTypeTag :: codegen bool (WasmTypeTag bool) + +tx :: CG bool codegen + => CmmExpr + + -> (forall t . WasmTypeTag t -> WasmIR bool '[] (t : '[]) -> codegen bool r) + -> codegen bool r + -- combines type checking and translation +tx expr k = + case expr of + CmmLit (CmmInt n w) -> withIntWidthTag w $ \tag -> k tag (WasmInt tag n) + CmmLit (CmmFloat x w) -> withFloatWidthTag w $ \tag -> k tag (WasmFloat tag x) + + CmmMachOp (MO_Add w) es -> wasmBinary w es WasmAdd k + CmmMachOp (MO_Sub w) es -> wasmBinary w es WasmSub k + + CmmMachOp (MO_S_Ge w) es -> wasmCompare w es WasmS_Ge k + + _ -> panic "unimplemented" + +wasmBinary :: CG bool codegen + => CT.Width + -> [CmmExpr] + -> (forall t . WasmTypeTag t -> WasmIR bool (t : t : '[]) (t : '[])) + -> (forall t . WasmTypeTag t -> WasmIR bool '[] (t : '[]) -> codegen bool r) + -> codegen bool r + +wasmCompare :: forall bool codegen r . CG bool codegen + => CT.Width + -> [CmmExpr] + -> (forall t . WasmTypeTag t -> WasmIR bool (t : t : '[]) (bool : '[])) + -> ( WasmTypeTag bool -> WasmIR bool '[] (bool : '[]) -> codegen bool r) + -> codegen bool r + + +wasmBinary w es operator k = + binaryCPS es $ \tag code1 code2 -> + checkTagWidth tag w $ -- optional check + k tag (code1 <> WasmLift tag code2 <> operator tag) + + +wasmCompare w es operator k = + binaryCPS es $ \tag code1 code2 -> do + bool <- booleanWasmTypeTag + checkTagWidth bool w $ + k bool (code1 <> WasmLift tag code2 <> operator tag) + +binaryCPS + :: forall bool codegen a . CG bool codegen + => [CmmExpr] + -> (forall t . WasmTypeTag t + -> WasmIR bool '[] (t : '[]) + -> WasmIR bool '[] (t : '[]) + -> codegen bool a) + -> codegen bool a +binaryCPS [e1, e2] k = -- would dearly love to use do notation here + tx e1 $ \tag1 code1 -> + tx e2 $ \tag2 code2 -> + case tag1 `testEquality` tag2 of -- mandatory check + Just Refl -> k tag1 code1 code2 + Nothing -> panic "ill-typed Cmm" +binaryCPS _ _ = panic "wrong number of operands to machine operator in Cmm" + + +--whenEqual :: WasmTypeTag t -> WasmTypeTag t' -> (forall t . WasmTypeTag t -> a) -> a +-- -- trusted code +--whenEqual TagI32 TagI32 k = k TagI32 +--whenEqual TagF32 TagF32 k = k TagF32 +--whenEqual TagI64 TagI64 k = k TagI64 +--whenEqual TagF64 TagF64 k = k TagF64 +--whenEqual _ _ _ = panic "ill-typed Cmm in Wasm translation" + +checkTagWidth :: WasmTypeTag t -> CT.Width -> a -> a +checkTagWidth TagI32 CT.W32 a = a +checkTagWidth TagF32 CT.W32 a = a +checkTagWidth TagI64 CT.W64 a = a +checkTagWidth TagF64 CT.W64 a = a +checkTagWidth _ _ _ = panic "ill-typed Cmm (width mismatch)" + + +withIntWidthTag :: CT.Width -> (forall t . WasmTypeTag t -> a) -> a +withIntWidthTag CT.W32 k = k TagI32 +withIntWidthTag CT.W64 k = k TagI64 +withIntWidthTag w _ = panic $ "width " ++ show w ++ " not supported on wasm target" + +withFloatWidthTag :: CT.Width -> (forall t . WasmTypeTag t -> a) -> a +withFloatWidthTag CT.W32 k = k TagF32 +withFloatWidthTag CT.W64 k = k TagF64 +withFloatWidthTag w _ = panic $ "width " ++ show w ++ " not supported on wasm target" ===================================== compiler/ghc.cabal.in ===================================== @@ -809,6 +809,7 @@ Library GHC.Wasm.ControlFlow.FromCmm GHC.Wasm.ControlFlow.ToAsm GHC.Wasm.IR + GHC.Wasm.Tx Language.Haskell.Syntax Language.Haskell.Syntax.Basic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b48a635fd36b5ae4f07cc1ba332b9b56d954dd1...6deab9c16233434be431d717a7026ffaec1929dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b48a635fd36b5ae4f07cc1ba332b9b56d954dd1...6deab9c16233434be431d717a7026ffaec1929dd You're receiving 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 Sep 29 16:38:23 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Thu, 29 Sep 2022 12:38:23 -0400 Subject: [Git][ghc/ghc][wip/nr/wasm-translation-prototypes] added a unary operator Message-ID: <6335c9ff33bdb_2c975742cc31601010938@gitlab.mail> Norman Ramsey pushed to branch wip/nr/wasm-translation-prototypes at Glasgow Haskell Compiler / GHC Commits: a0648016 by Norman Ramsey at 2022-09-29T12:38:07-04:00 added a unary operator - - - - - 2 changed files: - compiler/GHC/Wasm/IR.hs - compiler/GHC/Wasm/Tx.hs Changes: ===================================== compiler/GHC/Wasm/IR.hs ===================================== @@ -125,6 +125,10 @@ data WasmIR :: WasmType -> [WasmType] -> [WasmType] -> Type where WasmSub :: WasmTypeTag t -> WasmIR bool (t : t : stack) (t : stack) WasmS_Ge :: WasmTypeTag t -> WasmIR bool (t : t : stack) (bool : stack) -- signed >= + WasmNot :: WasmTypeTag t -> WasmIR bool (t : stack) (t : stack) -- bitwise + + ----- + WasmCCall :: SymName -> WasmIR bool pre post -- completely untyped WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmIR bool (t : pre) pre WasmLocalGet :: WasmTypeTag t -> Int -> WasmIR bool pre (t : pre) ===================================== compiler/GHC/Wasm/Tx.hs ===================================== @@ -45,6 +45,8 @@ tx expr k = CmmMachOp (MO_S_Ge w) es -> wasmCompare w es WasmS_Ge k + CmmMachOp (MO_Not w) es -> wasmUnary w es WasmNot k + _ -> panic "unimplemented" wasmBinary :: CG bool codegen @@ -61,6 +63,15 @@ wasmCompare :: forall bool codegen r . CG bool codegen -> ( WasmTypeTag bool -> WasmIR bool '[] (bool : '[]) -> codegen bool r) -> codegen bool r +wasmUnary :: CG bool codegen + => CT.Width + -> [CmmExpr] + -> (forall t . WasmTypeTag t -> WasmIR bool (t : '[]) (t : '[])) + -> (forall t . WasmTypeTag t -> WasmIR bool '[] (t : '[]) -> codegen bool r) + -> codegen bool r + + + wasmBinary w es operator k = binaryCPS es $ \tag code1 code2 -> @@ -88,7 +99,11 @@ binaryCPS [e1, e2] k = -- would dearly love to use do notation here case tag1 `testEquality` tag2 of -- mandatory check Just Refl -> k tag1 code1 code2 Nothing -> panic "ill-typed Cmm" -binaryCPS _ _ = panic "wrong number of operands to machine operator in Cmm" +binaryCPS _ _ = panic "wrong number of operands to binary operator in Cmm" + +wasmUnary w [e] operator k = + tx e $ \tag code -> checkTagWidth tag w $ k tag (code <> operator tag) +wasmUnary _ _ _ _ = panic "wrong number of operands to unary operator in Cmm" --whenEqual :: WasmTypeTag t -> WasmTypeTag t' -> (forall t . WasmTypeTag t -> a) -> a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a06480168b15d7bcf115977279d47a45f2e350d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a06480168b15d7bcf115977279d47a45f2e350d6 You're receiving 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 Sep 29 16:40:16 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Thu, 29 Sep 2022 12:40:16 -0400 Subject: [Git][ghc/ghc][wip/nr/wasm-translation-prototypes] code cleanup Message-ID: <6335ca701187d_2c975742bd2a1c101118b@gitlab.mail> Norman Ramsey pushed to branch wip/nr/wasm-translation-prototypes at Glasgow Haskell Compiler / GHC Commits: 4c9c1cc1 by Norman Ramsey at 2022-09-29T12:40:02-04:00 code cleanup - - - - - 1 changed file: - compiler/GHC/Wasm/Tx.hs Changes: ===================================== compiler/GHC/Wasm/Tx.hs ===================================== @@ -71,12 +71,10 @@ wasmUnary :: CG bool codegen -> codegen bool r - - wasmBinary w es operator k = - binaryCPS es $ \tag code1 code2 -> - checkTagWidth tag w $ -- optional check - k tag (code1 <> WasmLift tag code2 <> operator tag) + binaryCPS es $ \tag code1 code2 -> + checkTagWidth tag w $ -- optional check + k tag (code1 <> WasmLift tag code2 <> operator tag) wasmCompare w es operator k = @@ -93,6 +91,7 @@ binaryCPS -> WasmIR bool '[] (t : '[]) -> codegen bool a) -> codegen bool a + binaryCPS [e1, e2] k = -- would dearly love to use do notation here tx e1 $ \tag1 code1 -> tx e2 $ \tag2 code2 -> @@ -105,14 +104,8 @@ wasmUnary w [e] operator k = tx e $ \tag code -> checkTagWidth tag w $ k tag (code <> operator tag) wasmUnary _ _ _ _ = panic "wrong number of operands to unary operator in Cmm" +---------------------------------------------------------------- ---whenEqual :: WasmTypeTag t -> WasmTypeTag t' -> (forall t . WasmTypeTag t -> a) -> a --- -- trusted code ---whenEqual TagI32 TagI32 k = k TagI32 ---whenEqual TagF32 TagF32 k = k TagF32 ---whenEqual TagI64 TagI64 k = k TagI64 ---whenEqual TagF64 TagF64 k = k TagF64 ---whenEqual _ _ _ = panic "ill-typed Cmm in Wasm translation" checkTagWidth :: WasmTypeTag t -> CT.Width -> a -> a checkTagWidth TagI32 CT.W32 a = a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c9c1cc16512a29fd63333d75b6050d7a611fd4d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c9c1cc16512a29fd63333d75b6050d7a611fd4d You're receiving 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 Sep 29 16:44:47 2022 From: gitlab at gitlab.haskell.org (Norman Ramsey (@nrnrnr)) Date: Thu, 29 Sep 2022 12:44:47 -0400 Subject: [Git][ghc/ghc][wip/nr/wasm-translation-prototypes] demonstration of unary and binary operators including comparisons Message-ID: <6335cb7fa63fa_2c97575141410113ac@gitlab.mail> Norman Ramsey pushed to branch wip/nr/wasm-translation-prototypes at Glasgow Haskell Compiler / GHC Commits: 893c276e by Norman Ramsey at 2022-09-29T12:44:36-04:00 demonstration of unary and binary operators including comparisons The code is clean. The addition of a type parameter to track the platform Boolean type is annoying, but I don't see how to avoid it. - - - - - 2 changed files: - compiler/GHC/Wasm/IR.hs - compiler/GHC/Wasm/Tx.hs Changes: ===================================== compiler/GHC/Wasm/IR.hs ===================================== @@ -2,9 +2,10 @@ {-# LANGUAGE DataKinds, GADTs, RankNTypes, TypeOperators, KindSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeFamilies, ConstraintKinds #-} module GHC.Wasm.IR - ( WasmIR(..), (<>), pattern WasmIf, wasmReturn + ( WasmIR(..), (<>), pattern WasmIf32, wasmReturn , BrTableInterval(..), inclusiveInterval , brTableLimit @@ -19,6 +20,8 @@ where import GHC.Prelude import Data.Kind +import Data.Type.Equality + import GHC.Data.FastString import GHC.Utils.Outputable hiding ((<>)) @@ -45,6 +48,14 @@ data WasmTypeTag :: WasmType -> Type where TagI64 :: WasmTypeTag 'I64 TagF64 :: WasmTypeTag 'F64 +instance TestEquality WasmTypeTag where + TagI32 `testEquality` TagI32 = Just Refl + TagI64 `testEquality` TagI64 = Just Refl + TagF32 `testEquality` TagF32 = Just Refl + TagF64 `testEquality` TagF64 = Just Refl + _ `testEquality` _ = Nothing + + -- | List of WebAssembly types used to describe the sequence of WebAssembly -- values that a block of code may expect on the stack or leave on the stack. @@ -66,58 +77,66 @@ data WasmFunctionType pre post = -- | Representation of WebAssembly control flow. -- Normally written as -- @ --- WasmIR pre post +-- WasmIR bool pre post -- @ --- Type parameter `s` is the type of (unspecified) statements. --- It might be instantiated with an open Cmm block or with a sequence --- of Wasm instructions. --- Parameter `e` is the type of expressions. +-- Type parameter `bool` represents the Wasm type of Boolean results -- Parameter `pre` represents the values that are expected on the -- WebAssembly stack when the code runs, and `post` represents -- the state of the stack on completion. -data WasmIR :: [WasmType] -> [WasmType] -> Type where +data WasmIR :: WasmType -> [WasmType] -> [WasmType] -> Type where - WasmPush :: WasmTypeTag t -> WasmIR stack (t ': stack) -> WasmIR stack (t ': stack) + WasmPush :: WasmTypeTag t -> WasmIR bool stack (t ': stack) -> WasmIR bool stack (t ': stack) WasmBlock :: WasmFunctionType pre post - -> WasmIR pre post - -> WasmIR pre post + -> WasmIR bool pre post + -> WasmIR bool pre post WasmLoop :: WasmFunctionType pre post - -> WasmIR pre post - -> WasmIR pre post + -> WasmIR bool pre post + -> WasmIR bool pre post WasmIfTop :: WasmFunctionType pre post - -> WasmIR pre post - -> WasmIR pre post - -> WasmIR ('I32 ': pre) post + -> WasmIR bool pre post + -> WasmIR bool pre post + -> WasmIR bool (bool ': pre) post - WasmBr :: Int -> WasmIR dropped destination -- not typechecked - WasmFallthrough :: WasmIR dropped destination + WasmBr :: Int -> WasmIR bool dropped destination -- not typechecked + WasmFallthrough :: WasmIR bool dropped destination -- generates no code, but has the same type as a branch WasmBrTable :: e -> BrTableInterval -- for testing -> [Int] -- targets -> Int -- default target - -> WasmIR dropped destination + -> WasmIR bool dropped destination -- invariant: the table interval is contained -- within [0 .. pred (length targets)] WasmReturnTop :: WasmTypeTag t - -> WasmIR (t ': t1star) t2star -- as per type system + -> WasmIR bool (t ': t1star) t2star -- as per type system - WasmActions :: s -> WasmIR stack stack -- basic block: one entry, one exit - WasmSeq :: WasmIR pre mid -> WasmIR mid post -> WasmIR pre post + WasmActions :: s -> WasmIR bool stack stack -- basic block: one entry, one exit + WasmSeq :: WasmIR bool pre mid -> WasmIR bool mid post -> WasmIR bool pre post ---------------------------- - WasmConst :: WasmTypeTag t -> Integer -> WasmIR pre (t : pre) + WasmInt :: WasmTypeTag t -> Integer -> WasmIR bool pre (t : pre) + WasmFloat :: WasmTypeTag t -> Rational -> WasmIR bool pre (t : pre) + + WasmAdd :: WasmTypeTag t -> WasmIR bool (t : t : stack) (t : stack) + WasmSub :: WasmTypeTag t -> WasmIR bool (t : t : stack) (t : stack) + WasmS_Ge :: WasmTypeTag t -> WasmIR bool (t : t : stack) (bool : stack) -- signed >= + + WasmNot :: WasmTypeTag t -> WasmIR bool (t : stack) (t : stack) -- bitwise + + ----- + + WasmCCall :: SymName -> WasmIR bool pre post -- completely untyped + WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmIR bool (t : pre) pre + WasmLocalGet :: WasmTypeTag t -> Int -> WasmIR bool pre (t : pre) + WasmLocalSet :: WasmTypeTag t -> Int -> WasmIR bool (t : pre) pre - WasmAdd :: WasmTypeTag t -> WasmIR (t : t : stack) (t : stack) + WasmLift :: (pre' ~ (t : pre), post' ~ (t : post)) => + WasmTypeTag t -> WasmIR bool pre post -> WasmIR bool pre' post' - WasmCCall :: SymName -> WasmIR pre post -- completely untyped - WasmGlobalSet :: WasmTypeTag t -> SymName -> WasmIR (t : pre) pre - WasmLocalGet :: WasmTypeTag t -> Int -> WasmIR pre (t : pre) - WasmLocalSet :: WasmTypeTag t -> Int -> WasmIR (t : pre) pre @@ -146,27 +165,27 @@ inclusiveInterval lo hi BrTableInterval lo count | otherwise = panic "GHC.Wasm.ControlFlow: empty interval" -(<>) :: forall pre mid post - . WasmIR pre mid - -> WasmIR mid post - -> WasmIR pre post +(<>) :: forall bool pre mid post + . WasmIR bool pre mid + -> WasmIR bool mid post + -> WasmIR bool pre post (<>) = WasmSeq -- N.B. Fallthrough can't be optimized away because of type checking. -- Syntactic sugar. -pattern WasmIf :: WasmFunctionType pre post - -> WasmIR pre ('I32 : pre) - -> WasmIR pre post - -> WasmIR pre post - -> WasmIR pre post +pattern WasmIf32 :: WasmFunctionType pre post + -> WasmIR 'I32 pre ('I32 : pre) + -> WasmIR 'I32 pre post + -> WasmIR 'I32 pre post + -> WasmIR 'I32 pre post -pattern WasmIf ty e t f = +pattern WasmIf32 ty e t f = WasmPush TagI32 e `WasmSeq` WasmIfTop ty t f -- More syntactic sugar. -wasmReturn :: WasmTypeTag t -> WasmIR t1star (t : t1star) -> WasmIR t1star t2star +wasmReturn :: WasmTypeTag t -> WasmIR bool t1star (t : t1star) -> WasmIR bool t1star t2star wasmReturn tag e = WasmPush tag e `WasmSeq` WasmReturnTop tag ===================================== compiler/GHC/Wasm/Tx.hs ===================================== @@ -2,8 +2,12 @@ {-# LANGUAGE DataKinds, GADTs, RankNTypes, TypeOperators, KindSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE MultiParamTypeClasses #-} module GHC.Wasm.Tx + ( tx + , CG(..) + ) where import GHC.Prelude @@ -18,53 +22,96 @@ import GHC.Cmm.Expr import GHC.Utils.Panic import GHC.Wasm.IR -class Monad m => CG m where - platformWordSize :: m Int - asType :: WasmTypeTag t -> m () -- check that type is consistent - -- with platform word size - asInt :: WasmTypeTag t -> m () -- insist on the platofrm integer type +class Monad (codegen bool) => CG bool codegen where +-- platformWordSize :: m Int +-- asType :: WasmTypeTag t -> m () -- check that type is consistent +-- -- with platform word size +-- asInt :: WasmTypeTag t -> m () -- insist on the platofrm integer type + booleanWasmTypeTag :: codegen bool (WasmTypeTag bool) -tx :: CG m +tx :: CG bool codegen => CmmExpr - -> (forall t . WasmTypeTag t -> WasmIR pre (t : pre) -> m r) - -> m r + -> (forall t . WasmTypeTag t -> WasmIR bool '[] (t : '[]) -> codegen bool r) + -> codegen bool r -- combines type checking and translation tx expr k = case expr of CmmLit (CmmInt n w) -> withIntWidthTag w $ \tag -> k tag (WasmInt tag n) CmmLit (CmmFloat x w) -> withFloatWidthTag w $ \tag -> k tag (WasmFloat tag x) - CmmMachOp (MO_Add _w) es -> -- typecheck _w later - binary es $ \tag code1 code2 -> - k tag (code1 <> code2 <> WasmAdd tag) + CmmMachOp (MO_Add w) es -> wasmBinary w es WasmAdd k + CmmMachOp (MO_Sub w) es -> wasmBinary w es WasmSub k + + CmmMachOp (MO_S_Ge w) es -> wasmCompare w es WasmS_Ge k + + CmmMachOp (MO_Not w) es -> wasmUnary w es WasmNot k _ -> panic "unimplemented" +wasmBinary :: CG bool codegen + => CT.Width + -> [CmmExpr] + -> (forall t . WasmTypeTag t -> WasmIR bool (t : t : '[]) (t : '[])) + -> (forall t . WasmTypeTag t -> WasmIR bool '[] (t : '[]) -> codegen bool r) + -> codegen bool r + +wasmCompare :: forall bool codegen r . CG bool codegen + => CT.Width + -> [CmmExpr] + -> (forall t . WasmTypeTag t -> WasmIR bool (t : t : '[]) (bool : '[])) + -> ( WasmTypeTag bool -> WasmIR bool '[] (bool : '[]) -> codegen bool r) + -> codegen bool r + +wasmUnary :: CG bool codegen + => CT.Width + -> [CmmExpr] + -> (forall t . WasmTypeTag t -> WasmIR bool (t : '[]) (t : '[])) + -> (forall t . WasmTypeTag t -> WasmIR bool '[] (t : '[]) -> codegen bool r) + -> codegen bool r + + +wasmBinary w es operator k = + binaryCPS es $ \tag code1 code2 -> + checkTagWidth tag w $ -- optional check + k tag (code1 <> WasmLift tag code2 <> operator tag) + -binary :: CG m +wasmCompare w es operator k = + binaryCPS es $ \tag code1 code2 -> do + bool <- booleanWasmTypeTag + checkTagWidth bool w $ + k bool (code1 <> WasmLift tag code2 <> operator tag) + +binaryCPS + :: forall bool codegen a . CG bool codegen => [CmmExpr] -> (forall t . WasmTypeTag t - -> WasmIR pre (t : pre) - -> WasmIR (t : pre) (t : t : pre) - -> m a) - -> m a -binary [e1, e2] k = - tx e1 $ \tag1 m1 -> - tx e2 $ \tag2 m2 -> - case tag1 `testEquality` tag2 of - Just Refl -> k tag1 (magic m1) (magic m2) - Nothing -> panic "ill-typed Cmm" - -magic :: a -> b -magic x = magic x - -whenEqual :: WasmTypeTag t -> WasmTypeTag t' -> (forall t . WasmTypeTag t -> a) -> a - -- trusted code -whenEqual TagI32 TagI32 k = k TagI32 -whenEqual TagF32 TagF32 k = k TagF32 -whenEqual TagI64 TagI64 k = k TagI64 -whenEqual TagF64 TagF64 k = k TagF64 -whenEqual _ _ _ = panic "ill-typed Cmm in Wasm translation" + -> WasmIR bool '[] (t : '[]) + -> WasmIR bool '[] (t : '[]) + -> codegen bool a) + -> codegen bool a + +binaryCPS [e1, e2] k = -- would dearly love to use do notation here + tx e1 $ \tag1 code1 -> + tx e2 $ \tag2 code2 -> + case tag1 `testEquality` tag2 of -- mandatory check + Just Refl -> k tag1 code1 code2 + Nothing -> panic "ill-typed Cmm" +binaryCPS _ _ = panic "wrong number of operands to binary operator in Cmm" + +wasmUnary w [e] operator k = + tx e $ \tag code -> checkTagWidth tag w $ k tag (code <> operator tag) +wasmUnary _ _ _ _ = panic "wrong number of operands to unary operator in Cmm" + +---------------------------------------------------------------- + + +checkTagWidth :: WasmTypeTag t -> CT.Width -> a -> a +checkTagWidth TagI32 CT.W32 a = a +checkTagWidth TagF32 CT.W32 a = a +checkTagWidth TagI64 CT.W64 a = a +checkTagWidth TagF64 CT.W64 a = a +checkTagWidth _ _ _ = panic "ill-typed Cmm (width mismatch)" withIntWidthTag :: CT.Width -> (forall t . WasmTypeTag t -> a) -> a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/893c276e403e2eddcc458c373d541a4f2a7c80bf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/893c276e403e2eddcc458c373d541a4f2a7c80bf You're receiving 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 Sep 29 16:58:12 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 29 Sep 2022 12:58:12 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Clean up `findWiredInUnit`. In particular, avoid `head`. Message-ID: <6335cea4d82ca_2c975742bd2a1c101155e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 66e5e7cf by Bryan Richter at 2022-09-29T12:57:58-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. - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Utils/Lexeme.hs - docs/users_guide/using-optimisation.rst - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity04.stderr - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity06.stderr - testsuite/tests/arityanal/should_compile/Arity08.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity15.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/determinism/determ004/determ004.hs - testsuite/tests/simplCore/should_compile/OpaqueNoSpecialise.stderr - testsuite/tests/simplCore/should_compile/T13156.hs - testsuite/tests/simplCore/should_compile/T14152.stderr - testsuite/tests/simplCore/should_compile/T14152a.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T18355.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba417041c4254947254307013e95a23ef4dde13a...66e5e7cf9e1501ddde870af4a2403de97e047701 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba417041c4254947254307013e95a23ef4dde13a...66e5e7cf9e1501ddde870af4a2403de97e047701 You're receiving 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 Sep 29 17:29:15 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 29 Sep 2022 13:29:15 -0400 Subject: [Git][ghc/ghc][wip/jsem] 3 commits: hadrian fixes Message-ID: <6335d5ebc6b93_2c975742bcfe2010237d2@gitlab.mail> Matthew Pickering pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 48565020 by Matthew Pickering at 2022-09-29T18:18:35+01:00 hadrian fixes - - - - - bd2afc2f by Matthew Pickering at 2022-09-29T18:20:41+01:00 Fix par logging - - - - - adc4d2b7 by Matthew Pickering at 2022-09-29T18:20:52+01:00 remove hadrian trace - - - - - 5 changed files: - compiler/GHC/Driver/Make.hs - hadrian/hadrian.cabal - hadrian/src/Context.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Library.hs Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -2837,18 +2837,18 @@ runParPipelines worker_limit plugin_hsc_env mHscMessager all_pipelines = do let thread_safe_hsc_env = plugin_hsc_env { hsc_logger = thread_safe_logger } - withParLog log_queue_queue_var (-1) $ \ modify_logger -> do - let sem_logger = modify_logger $ hsc_logger thread_safe_hsc_env - runWorkerLimit worker_limit sem_logger $ \abstract_sem -> do - let env = MakeEnv { hsc_env = thread_safe_hsc_env - , withLogger = withParLog log_queue_queue_var - , compile_sem = abstract_sem - , env_messager = mHscMessager - } - -- Reset the number of capabilities once the upsweep ends. - runAllPipelines worker_limit env all_pipelines - atomically $ writeTVar stopped_var True - wait_log_thread + +-- let sem_logger = modify_logger $ hsc_logger thread_safe_hsc_env + runWorkerLimit worker_limit (hsc_logger thread_safe_hsc_env) $ \abstract_sem -> do + let env = MakeEnv { hsc_env = thread_safe_hsc_env + , withLogger = withParLog log_queue_queue_var + , compile_sem = abstract_sem + , env_messager = mHscMessager + } + -- Reset the number of capabilities once the upsweep ends. + runAllPipelines worker_limit env all_pipelines + atomically $ writeTVar stopped_var True + wait_log_thread withLocalTmpFS :: RunMakeM a -> RunMakeM a withLocalTmpFS act = do ===================================== hadrian/hadrian.cabal ===================================== @@ -165,6 +165,7 @@ executable hadrian , unordered-containers >= 0.2.1 && < 0.3 , text >= 1.2 && < 3 , time + , unix if os(windows) build-depends: Win32 ===================================== hadrian/src/Context.hs ===================================== @@ -9,7 +9,7 @@ module Context ( contextDir, buildPath, buildDir, pkgInplaceConfig, pkgSetupConfigFile, pkgSetupConfigDir, pkgHaddockFile, pkgRegisteredLibraryFile, pkgRegisteredLibraryFileName, pkgLibraryFile, pkgGhciLibraryFile, - pkgConfFile, pkgStampFile, objectPath, contextPath, getContextPath, libPath, distDir, + pkgConfFile, pkgStampFile, pkgStamp2File, objectPath, contextPath, getContextPath, libPath, distDir, haddockStatsFilesDir ) where @@ -148,6 +148,12 @@ pkgStampFile c at Context{..} = do let extension = waySuffix way pkgFile c "stamp-" extension +pkgStamp2File :: Context -> Action FilePath +pkgStamp2File c at Context{..} = do + let extension = waySuffix way + pkgFile c "stamp2-" extension + + -- | Given a 'Context' and a 'FilePath' to a source file, compute the 'FilePath' -- to its object file. For example: -- * "Task.c" -> "_build/stage1/rts/Task.thr_o" ===================================== hadrian/src/Rules/Compile.hs ===================================== @@ -215,7 +215,7 @@ compileHsObjectAndHi rs objpath = do where compileWithMake ctx = do -- Need the stamp file, which triggers a rebuild via make - stamp <- pkgStampFile ctx + stamp <- pkgStamp2File ctx let way = C.way ctx lib_ways <- interpretInContext ctx getLibraryWays -- In this situation -dynamic-too will produce both ways ===================================== hadrian/src/Rules/Library.hs ===================================== @@ -30,6 +30,7 @@ libraryRules = do root -/- "**/libHS*-*.dll" %> buildDynamicLib root "dll" root -/- "**/*.a" %> buildStaticLib root root -/- "**/stamp-*" %> buildPackage root + root -/- "**/stamp2-*" %> buildHsObjs root priority 2 $ do root -/- "stage*/lib/**/libHS*-*.dylib" %> registerDynamicLib root "dylib" root -/- "stage*/lib/**/libHS*-*.so" %> registerDynamicLib root "so" @@ -61,6 +62,25 @@ buildPackage root fp = do lib_targets <- libraryTargets True ctx + need (srcs ++ gens ++ lib_targets) + time <- liftIO $ getCurrentTime + liftIO $ writeFile fp (show time) + ways <- interpretInContext ctx getLibraryWays + let hasVanilla = elem vanilla ways + hasDynamic = elem dynamic ways + support <- platformSupportsSharedLibs + when ((hasVanilla && hasDynamic) && + support && way == vanilla) $ do + stamp <- (pkgStampFile (ctx { way = dynamic })) + liftIO $ writeFile stamp (show time) + +buildHsObjs :: FilePath -> FilePath -> Action () +buildHsObjs root fp = do + l@(BuildPath _ stage _ (PkgStamp _ _ way)) <- parsePath (parseStampPath2 root) "<.stamp parser>" fp + let ctx = stampContext l + srcs <- hsSources ctx + gens <- interpretInContext ctx generatedDependencies + -- Write the current time into the file so the file always changes if -- we restamp it because a dependency changes. @@ -71,13 +91,8 @@ buildPackage root fp = do deps <- sequence [ pkgConfFile (ctx { package = pkg }) | pkg <- depPkgs, pkg `elem` stagePkgs ] need deps - let needs - | isStage0 stage - = srcs ++ gens ++ lib_targets - | otherwise - = srcs ++ gens - need needs - unless (null srcs || isStage0 stage) $ do + need (srcs ++ gens) + unless (null srcs) $ do build $ target ctx (Ghc (CompileHs GhcMake) stage) srcs [] time <- liftIO $ getCurrentTime liftIO $ writeFile fp (show time) @@ -87,7 +102,7 @@ buildPackage root fp = do support <- platformSupportsSharedLibs when ((hasVanilla && hasDynamic) && support && way == vanilla) $ do - stamp <- (pkgStampFile (ctx { way = dynamic })) + stamp <- (pkgStamp2File (ctx { way = dynamic })) liftIO $ writeFile stamp (show time) @@ -303,6 +318,9 @@ parseBuildLibGhci root = parseBuildPath root parseLibGhciFilename parseStampPath :: FilePath -> Parsec.Parsec String () (BuildPath PkgStamp) parseStampPath root = parseBuildPath root parseStamp +parseStampPath2 :: FilePath -> Parsec.Parsec String () (BuildPath PkgStamp) +parseStampPath2 root = parseBuildPath root parseStamp2 + -- | Parse a path to a dynamic library to be built, making sure the path starts -- with the given build root. parseBuildLibDyn :: FilePath -> String -> Parsec.Parsec String () (BuildPath LibDyn) @@ -351,3 +369,10 @@ parseStamp = do (pkgname, pkgver) <- parsePkgId way <- parseWaySuffix vanilla return (PkgStamp pkgname pkgver way) + +parseStamp2 :: Parsec.Parsec String () PkgStamp +parseStamp2 = do + _ <- Parsec.string "stamp2-" + (pkgname, pkgver) <- parsePkgId + way <- parseWaySuffix vanilla + return (PkgStamp pkgname pkgver way) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9644da47cd44eaeadb97ac0ba6ad8ae99e201983...adc4d2b702c370868a82141ad0d6e9367e66f0bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9644da47cd44eaeadb97ac0ba6ad8ae99e201983...adc4d2b702c370868a82141ad0d6e9367e66f0bb You're receiving 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 Sep 29 17:53:59 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Thu, 29 Sep 2022 13:53:59 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Stack: Docs and cleanup Message-ID: <6335dbb77f1c_2c9757514001027183@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 47c49d02 by doyougnu at 2022-09-29T13:53:02-04:00 StgToJS.Stack: Docs and cleanup In particular: -- Removing some single use functions -- Some minor refactors related to these removals - - - - - 3 changed files: - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Stack.hs Changes: ===================================== compiler/GHC/StgToJS/Apply.hs ===================================== @@ -740,7 +740,7 @@ stackApply s fun_name nargs nvars = ] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (entryClosureType c)]) ] - funExact c = popSkip' 1 (reverse $ take nvars jsRegsFromR2) <> returnS c + funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c stackArgs = map (\x -> stack .! (sp - toJExpr x)) [1..nvars] papCase :: JExpr -> JStat ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -644,13 +644,24 @@ genRet ctx e at as l = freshIdent >>= f MultiValAlt _n -> idVt e _ -> [PtrV] + -- special case for popping CCS but preserving stack size + pop_handle_CCS :: [(JExpr, StackSlot)] -> G JStat + pop_handle_CCS [] = return mempty + pop_handle_CCS xs = do + -- grab the slots from 'xs' and push + addSlots (map snd xs) + -- move the stack pointer into the stack by ''length xs + n' + a <- adjSpN (length xs) + -- now load from the top of the stack + return (loadSkip 0 (map fst xs) <> a) + fun free = resetSlots $ do decs <- declVarsForId e load <- flip assignAll (map toJExpr [R1 ..]) . map toJExpr <$> identsForId e loadv <- verifyRuntimeReps [e] ras <- loadRetArgs free rasv <- verifyRuntimeReps (map (\(x,_,_)->x) free) - restoreCCS <- ifProfilingM $ popUnknown [jCurrentCCS] + restoreCCS <- ifProfilingM . pop_handle_CCS $ pure (jCurrentCCS, SlotUnknown) rlne <- popLneFrame False lneLive ctx' rlnev <- verifyRuntimeReps lneVars (alts, _altr) <- genAlts ctx' e at Nothing as ===================================== compiler/GHC/StgToJS/Stack.hs ===================================== @@ -1,7 +1,30 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} --- | Stack manipulation +----------------------------------------------------------------------------- +-- | +-- Module : GHC.JS.Stack +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Utilities and wrappers for Stack manipulation in JS Land. +-- +-- In general, functions suffixed with a tick do the actual work, functions +-- suffixed with an "I" are identical to the non-I versions but work on 'Ident's +-- +-- The stack in JS land is held in the special variable 'h$stack' and the stack +-- pointer is held in 'h$sp'. The top of the stack thus exists at +-- 'h$stack[h$sp]'. h$stack[h$sp + i] where i > 0, moves deeper into the stack +-- into older entries, whereas h$stack[h$sp - i] moves towards the top of the +-- stack. +----------------------------------------------------------------------------- + module GHC.StgToJS.Stack ( resetSlots , isolateSlots @@ -10,7 +33,6 @@ module GHC.StgToJS.Stack , addSlots , dropSlots , addUnknownSlots - , adjPushStack , push , push' , adjSpN @@ -24,12 +46,8 @@ module GHC.StgToJS.Stack , pushOptimized' , pushOptimized , pushLneFrame - , pop - , popn - , popUnknown - , popSkipUnknown + , popN , popSkip - , popSkip' , popSkipI , loadSkip -- * Thunk update @@ -62,7 +80,7 @@ import Data.Array import Data.Monoid import Control.Monad --- | Run the action with no stack info +-- | Run the action, 'm', with no stack info resetSlots :: G a -> G a resetSlots m = do s <- getSlots @@ -73,7 +91,8 @@ resetSlots m = do setStackDepth d return a --- | run the action with current stack info, but don't let modifications propagate +-- | run the action, 'm', with current stack info, but don't let modifications +-- propagate isolateSlots :: G a -> G a isolateSlots m = do s <- getSlots @@ -117,14 +136,10 @@ addSlots xs = do s <- getSlots setSlots (xs ++ s) +-- | drop 'n' slots from our stack knowledge dropSlots :: Int -> G () dropSlots n = modifySlots (drop n) -adjPushStack :: Int -> G () -adjPushStack n = do - modifyStackDepth (+n) - dropSlots n - push :: [JExpr] -> G JStat push xs = do dropSlots (length xs) @@ -137,38 +152,68 @@ push' cs xs | csInlinePush cs || l > 32 || l < 2 = adjSp' l <> mconcat items | otherwise = ApplStat (toJExpr $ pushN ! l) xs where - items = zipWith (\i e -> AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e)) - [(1::Int)..] xs + items = zipWith f [(1::Int)..] xs offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) l = length xs + f i e = AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e) +-- | Grow the stack pointer by 'n' without modifying the stack depth. The stack +-- is just a JS array so we add to grow (instead of the traditional subtract) adjSp' :: Int -> JStat adjSp' 0 = mempty adjSp' n = sp |= InfixExpr AddOp sp (toJExpr n) +-- | Shrink the stack pointer by 'n'. The stack grows downward so substract adjSpN' :: Int -> JStat adjSpN' 0 = mempty adjSpN' n = sp |= InfixExpr SubOp sp (toJExpr n) +-- | Wrapper which adjusts the stack pointer /and/ modifies the stack depth +-- tracked in 'G'. See also 'adjSp'' which actually does the stack pointer +-- manipulation. adjSp :: Int -> G JStat adjSp 0 = return mempty adjSp n = do + -- grow depth by n modifyStackDepth (+n) return (adjSp' n) +-- | Shrink the stack and stack pointer. NB: This function is unsafe when the +-- input 'n', is negative. This function wraps around 'adjSpN' which actually +-- performs the work. adjSpN :: Int -> G JStat adjSpN 0 = return mempty adjSpN n = do modifyStackDepth (\x -> x - n) return (adjSpN' n) +-- | A constant array that holds global function symbols which do N pushes onto +-- the stack. For example: +-- @ +-- function h$p1(x1) { +-- ++h$sp; +-- h$stack[(h$sp - 0)] = x1; +-- }; +-- function h$p2(x1, x2) { +-- h$sp += 2; +-- h$stack[(h$sp - 1)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- and so on up to 32. pushN :: Array Int Ident pushN = listArray (1,32) $ map (TxtI . mkFastString . ("h$p"++) . show) [(1::Int)..32] +-- | Convert all function symbols in 'pushN' to global top-level functions. This +-- is a hack which converts the function symbols to variables. This hack is +-- caught in 'GHC.StgToJS.Printer.prettyBlock'' to turn these into global +-- functions. pushN' :: Array Int JExpr pushN' = fmap (ValExpr . JVar) pushN + where pushNN :: Array Integer Ident pushNN = listArray (1,255) $ map (TxtI . mkFastString . ("h$pp"++) . show) [(1::Int)..255] @@ -216,82 +261,67 @@ pushOptimized xs = do offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) +-- | push a let-no-escape frame onto the stack pushLneFrame :: HasDebugCallStack => Int -> ExprCtx -> G JStat pushLneFrame size ctx = let ctx' = ctxLneShrinkStack ctx size in pushOptimized' (ctxLneFrameVars ctx') -popUnknown :: [JExpr] -> G JStat -popUnknown xs = popSkipUnknown 0 xs - -popSkipUnknown :: Int -> [JExpr] -> G JStat -popSkipUnknown n xs = popSkip n (map (,SlotUnknown) xs) - -pop :: [(JExpr,StackSlot)] -> G JStat -pop = popSkip 0 - --- | pop the expressions, but ignore the top n elements of the stack -popSkip :: Int -> [(JExpr,StackSlot)] -> G JStat -popSkip 0 [] = pure mempty -popSkip n [] = addUnknownSlots n >> adjSpN n -popSkip n xs = do - addUnknownSlots n - addSlots (map snd xs) - a <- adjSpN (length xs + n) - return (loadSkip n (map fst xs) <> a) - --- | pop things, don't upstate stack knowledge -popSkip' :: Int -- ^ number of slots to skip +-- | Pop things, don't update the stack knowledge in 'G' +popSkip :: Int -- ^ number of slots to skip -> [JExpr] -- ^ assign stack slot values to these -> JStat -popSkip' 0 [] = mempty -popSkip' n [] = adjSpN' n -popSkip' n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) +popSkip 0 [] = mempty +popSkip n [] = adjSpN' n +popSkip n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) --- | like popSkip, but without modifying the stack pointer +-- | Load 'length (xs :: [JExpr])' things from the stack at offset 'n :: Int'. +-- This function does no stack pointer manipulation, it merely indexes into the +-- stack and loads payloads into 'xs'. loadSkip :: Int -> [JExpr] -> JStat loadSkip = loadSkipFrom sp - -loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat -loadSkipFrom fr n xs = mconcat items - where - items = reverse $ zipWith (\i ex -> ex |= IdxExpr stack (toJExpr (offset (i+n)))) - [(0::Int)..] - (reverse xs) - offset 0 = toJExpr fr - offset n = InfixExpr SubOp (toJExpr fr) (toJExpr n) - - --- declare and pop + where + loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat + loadSkipFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + -- helper to generate sp - n offset to index with + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + -- helper to load stack .! i into ex, e.g., ex = stack[i] + f i ex = ex |= IdxExpr stack (toJExpr (offset (i+n))) + + +-- | Pop but preserve the first N slots popSkipI :: Int -> [(Ident,StackSlot)] -> G JStat popSkipI 0 [] = pure mempty -popSkipI n [] = adjSpN n +popSkipI n [] = popN n popSkipI n xs = do + -- add N unknown slots addUnknownSlots n + -- now add the slots from xs, after this line the stack should look like + -- [xs] ++ [Unknown...] ++ old_stack addSlots (map snd xs) + -- move stack pointer into the stack by (length xs + n), basically resetting + -- the stack pointer a <- adjSpN (length xs + n) + -- now load skipping first N slots return (loadSkipI n (map fst xs) <> a) --- like popSkip, but without modifying sp +-- | Just like 'loadSkip' but operate on 'Ident's rather than 'JExpr' loadSkipI :: Int -> [Ident] -> JStat loadSkipI = loadSkipIFrom sp - -loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat -loadSkipIFrom fr n xs = mconcat items - where - items = reverse $ zipWith f [(0::Int)..] (reverse xs) - offset 0 = fr - offset n = InfixExpr SubOp fr (toJExpr n) - f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) - -popn :: Int -> G JStat -popn n = addUnknownSlots n >> adjSpN n - -updateThunk' :: StgToJSConfig -> JStat -updateThunk' settings = - if csInlineBlackhole settings - then bhStats settings True - else ApplStat (var "h$bh") [] + where loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat + loadSkipIFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) + +-- | Blindly pop N slots +popN :: Int -> G JStat +popN n = addUnknownSlots n >> adjSpN n -- | Generate statements to update the current node with a blackhole bhStats :: StgToJSConfig -> Bool -> JStat @@ -302,8 +332,23 @@ bhStats s pushUpd = mconcat , toJExpr R1 .^ closureField2_ |= null_ -- will be filled with waiters array ] +-- | Wrapper around 'updateThunk'', performs the stack manipulation before +-- updating the Thunk. updateThunk :: G JStat updateThunk = do settings <- getSettings - adjPushStack 2 -- update frame size + -- update frame size + let adjPushStack :: Int -> G () + adjPushStack n = do modifyStackDepth (+n) + dropSlots n + adjPushStack 2 return $ (updateThunk' settings) + +-- | Update a thunk by checking 'StgToJSConfig'. If the config inlines black +-- holes then update inline, else make an explicit call to the black hole +-- handler. +updateThunk' :: StgToJSConfig -> JStat +updateThunk' settings = + if csInlineBlackhole settings + then bhStats settings True + else ApplStat (var "h$bh") [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/47c49d02e8effc257d54c1cbd65d1b5d0a52f31c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/47c49d02e8effc257d54c1cbd65d1b5d0a52f31c You're receiving 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 Sep 29 18:22:17 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 29 Sep 2022 14:22:17 -0400 Subject: [Git][ghc/ghc][wip/jsem] subtract one in the right place Message-ID: <6335e2598ae56_2c975742bcfe701033045@gitlab.mail> Matthew Pickering pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: b6149e21 by Matthew Pickering at 2022-09-29T19:22:07+01:00 subtract one in the right place - - - - - 1 changed file: - compiler/GHC/Driver/MakeSem.hs Changes: ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -211,7 +211,8 @@ cleanupJobserver (Jobserver { jSemaphore = sem logDumpMsg logger "cleanupJobserver {" $ vcat [ text "about to release all owned semaphore tokens" , ppr jobs ] - tokens_before <- releaseSemaphore sem owned + -- (-1) because the caller of GHC is responsible for releasing the last slot on the semaphore. + tokens_before <- releaseSemaphore sem (owned - 1) logDumpMsg logger "cleanupJobserver }" $ vcat [ text "released:" <+> ppr owned , text "semaphore count before release:" <+> ppr tokens_before ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b6149e21f4c4a326ad15975ea1fe75e1568afd48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b6149e21f4c4a326ad15975ea1fe75e1568afd48 You're receiving 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 Sep 29 18:43:21 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 29 Sep 2022 14:43:21 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T12971 Message-ID: <6335e7493c26f_2c975742cc316010338ee@gitlab.mail> Ben Gamari pushed new branch wip/T12971 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T12971 You're receiving 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 Sep 29 19:48:21 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 29 Sep 2022 15:48:21 -0400 Subject: [Git][ghc/ghc][master] Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Message-ID: <6335f685c7c7_2c9757514001044684@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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 - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - docs/users_guide/using-optimisation.rst - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity04.stderr - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity06.stderr - testsuite/tests/arityanal/should_compile/Arity08.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity15.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/determinism/determ004/determ004.hs - testsuite/tests/simplCore/should_compile/OpaqueNoSpecialise.stderr - testsuite/tests/simplCore/should_compile/T13156.hs - testsuite/tests/simplCore/should_compile/T14152.stderr - testsuite/tests/simplCore/should_compile/T14152a.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T19890.stderr - testsuite/tests/simplCore/should_compile/T21694b.stderr - testsuite/tests/simplCore/should_compile/T21948.stderr - testsuite/tests/simplCore/should_compile/T21960.stderr - testsuite/tests/simplCore/should_compile/T7785.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a535172d13b30c94766751d0bc21a494b8858ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a535172d13b30c94766751d0bc21a494b8858ed You're receiving 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 Sep 29 19:48:52 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 29 Sep 2022 15:48:52 -0400 Subject: [Git][ghc/ghc][master] Revert "ci: enable parallel compression for xz" Message-ID: <6335f6a4d9e63_2c97575148c10480d6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -499,7 +499,7 @@ function build_hadrian() { if [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian build-cabal -V else - XZ_OPT="${XZ_OPT:-} -T$cores" run_hadrian binary-dist -V + run_hadrian binary-dist -V mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" fi View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea0083bf56b222579b586c8247031e04c80c15f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea0083bf56b222579b586c8247031e04c80c15f1 You're receiving 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 Sep 29 20:06:33 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Thu, 29 Sep 2022 16:06:33 -0400 Subject: [Git][ghc/ghc][wip/jsem] fix the fixes Message-ID: <6335fac9568fb_2c975742bd2a1c10499d2@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 4ef26c78 by sheaf at 2022-09-29T22:06:20+02:00 fix the fixes - - - - - 2 changed files: - compiler/GHC/Driver/MakeSem.hs - hadrian/hadrian.cabal Changes: ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -212,10 +212,12 @@ cleanupJobserver (Jobserver { jSemaphore = sem vcat [ text "about to release all owned semaphore tokens" , ppr jobs ] -- (-1) because the caller of GHC is responsible for releasing the last slot on the semaphore. - tokens_before <- releaseSemaphore sem (owned - 1) - logDumpMsg logger "cleanupJobserver }" $ - vcat [ text "released:" <+> ppr owned - , text "semaphore count before release:" <+> ppr tokens_before ] + let toks_to_release = owned - 1 + when (toks_to_release > 0) do + tokens_before <- releaseSemaphore sem (owned - 1) + logDumpMsg logger "cleanupJobserver }" $ + vcat [ text "released:" <+> ppr owned + , text "semaphore count before release:" <+> ppr tokens_before ] -- | Dispatch the available tokens acquired from the semaphore -- to the pending jobs in the job server. ===================================== hadrian/hadrian.cabal ===================================== @@ -165,12 +165,11 @@ executable hadrian , unordered-containers >= 0.2.1 && < 0.3 , text >= 1.2 && < 3 , time - , unix if os(windows) - build-depends: Win32 - else - build-depends: unix + build-depends: Win32 + else + build-depends: unix ghc-options: -Wall -Wincomplete-record-updates View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ef26c78b511fe576f75a1d37e7f898d99b756c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ef26c78b511fe576f75a1d37e7f898d99b756c6 You're receiving 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 Sep 29 20:07:01 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Thu, 29 Sep 2022 16:07:01 -0400 Subject: [Git][ghc/ghc][wip/jsem] fix the fixes Message-ID: <6335fae57be09_2c975742bcfe701050475@gitlab.mail> sheaf pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 5b620380 by sheaf at 2022-09-29T22:06:49+02:00 fix the fixes - - - - - 2 changed files: - compiler/GHC/Driver/MakeSem.hs - hadrian/hadrian.cabal Changes: ===================================== compiler/GHC/Driver/MakeSem.hs ===================================== @@ -212,10 +212,12 @@ cleanupJobserver (Jobserver { jSemaphore = sem vcat [ text "about to release all owned semaphore tokens" , ppr jobs ] -- (-1) because the caller of GHC is responsible for releasing the last slot on the semaphore. - tokens_before <- releaseSemaphore sem (owned - 1) - logDumpMsg logger "cleanupJobserver }" $ - vcat [ text "released:" <+> ppr owned - , text "semaphore count before release:" <+> ppr tokens_before ] + let toks_to_release = owned - 1 + when (toks_to_release > 0) do + tokens_before <- releaseSemaphore sem toks_to_release + logDumpMsg logger "cleanupJobserver }" $ + vcat [ text "released:" <+> ppr owned + , text "semaphore count before release:" <+> ppr tokens_before ] -- | Dispatch the available tokens acquired from the semaphore -- to the pending jobs in the job server. ===================================== hadrian/hadrian.cabal ===================================== @@ -165,12 +165,11 @@ executable hadrian , unordered-containers >= 0.2.1 && < 0.3 , text >= 1.2 && < 3 , time - , unix if os(windows) - build-depends: Win32 - else - build-depends: unix + build-depends: Win32 + else + build-depends: unix ghc-options: -Wall -Wincomplete-record-updates View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b6203809bceb7f30b601fdc3151292b76da35a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b6203809bceb7f30b601fdc3151292b76da35a0 You're receiving 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 Sep 30 00:01:23 2022 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Thu, 29 Sep 2022 20:01:23 -0400 Subject: [Git][ghc/ghc][wip/T21623] Improvements to comments, etc., from Richard Message-ID: <633631d37e488_2c97575140010757d2@gitlab.mail> Richard Eisenberg pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 6b10aad6 by Richard Eisenberg at 2022-09-29T19:47:07-04:00 Improvements to comments, etc., from Richard - - - - - 8 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unify.hs Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1437,7 +1437,7 @@ GHC.Core.TyCo.Rep.mkFunTy has assertions about the consistency of the argument flag and arg/res types. But when constructing the kinds of tYPETyCon and cONSTRAINTTyCon we don't want to make these checks because TYPE :: RuntimeRep -> Type -i.e. TYPE :: RuntimeRep- > TYPE LiftedRep +i.e. TYPE :: RuntimeRep -> TYPE LiftedRep so the check will loop infinitely. Hence the use of a naked FunTy constructor in tTYPETyCon and cONSTRAINTTyCon. @@ -1941,7 +1941,7 @@ type BoxingInfo b = (DataCon, Expr b, Type) -- (K, K ty, boxed type) -- e.g. (I#, I#, Int) -- recall: data Int = I# Int# - -- or (MkInt8Box, MkInt8Box @ty, Int8Box @ty) + -- or (MkInt8Box, MkInt8Box @ty, Int8Box ty) -- recall: data Int8Box (a :: TYPE Int8Rep) = MkIntBox a boxingDataCon_maybe :: HasDebugCallStack => Type -> Maybe (BoxingInfo b) @@ -2003,7 +2003,7 @@ boxingDataConMap = foldl add emptyTypeMap boxingDataCons add bdcm (kind, boxing_con) = extendTypeMap bdcm kind boxing_con boxingDataCons :: [(Kind, DataCon)] --- The TyCon is the RuntimeRep for which the DataCon is the right boxing +-- The Kind is the kind of types for which the DataCon is the right boxing boxingDataCons = zipWith mkBoxingDataCon (map mkBoxingTyConUnique [1..]) [ (mkTYPEapp wordRepDataConTy, fsLit "WordBox", fsLit "MkWordBox") ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -777,6 +777,12 @@ precisely, that TYPE and CONSTRAINT are not apart. This non-apart-ness check is implemented in GHC.Core.Unify.unify_ty: look for `maybeApart MARTypeVsConstraint`. +We further extend this treatment to the different arrow types (see +Note [Function type constructors and FunTy]): if we have +FunCo (axC Int) :: (C Int => Int) ~ ((Int -> Int) -> Int), then +we could extract an equality between (=>) and (->). We thus must ensure +that (=>) and (->) (among the other arrow combinations) are not Apart. + Note that, as before, nothing prevents writing instances like: instance C (Proxy @Type a) where ... ===================================== compiler/GHC/Builtin/Uniques.hs ===================================== @@ -300,7 +300,7 @@ Allocation of unique supply characters: other a-z: lower case chars for unique supplies. Used so far: a TypeChecking? - b RuntimeRep + b Boxing tycons & datacons c StgToCmm/Renamer d desugarer f AbsC flattener @@ -314,6 +314,25 @@ Allocation of unique supply characters: u Cmm pipeline y GHCi bytecode generator z anonymous sums + +All wired in tycons actually use *two* uniques: + * u: the TyCon itself + * u+1: the TyConRepName of the TyCon (for use with TypeRep) + The "+1" is implemented in tyConRepNameUnique. +If this ever changes, make sure to also change the treatment for boxing tycons. + +All wired in datacons use *three* uniques: + * u: the DataCon itself + * u+1: its worker Id + * u+2: the TyConRepName of the promoted TyCon +No wired-in datacons have wrappers. +The "+1" is implemented in dataConWorkerUnique and the "+2" is in dataConTyRepNameUnique. +If this ever changes, make sure to also change the treatment for boxing tycons. + +Because boxing tycons (see Note [Boxing constructors] in GHC.Builtin.Types) +come with both a tycon and a datacon, each one takes up five slots, combining +the two cases above. Getting from the tycon to the datacon (by adding 2) +is implemented in boxingDataConUnique. -} mkAlphaTyVarUnique :: Int -> Unique @@ -357,8 +376,7 @@ initExitJoinUnique = mkUnique 's' 0 -------------------------------------------------- -- Wired-in type constructor keys occupy *two* slots: --- * u: the TyCon itself --- * u+1: the TyConRepName of the TyCon +-- See Note [Uniques for wired-in prelude things and known masks] mkPreludeTyConUnique :: Int -> Unique mkPreludeTyConUnique i = mkUnique '3' (2*i) @@ -368,10 +386,7 @@ tyConRepNameUnique u = incrUnique u -------------------------------------------------- -- Wired-in data constructor keys occupy *three* slots: --- * u: the DataCon itself --- * u+1: its worker Id --- * u+2: the TyConRepName of the promoted TyCon --- Prelude data constructors are too simple to need wrappers. +-- See Note [Uniques for wired-in prelude things and known masks] mkPreludeDataConUnique :: Int -> Unique mkPreludeDataConUnique i = mkUnique '6' (3*i) -- Must be alphabetic @@ -381,7 +396,9 @@ dataConWorkerUnique u = incrUnique u dataConTyRepNameUnique u = stepUnique u 2 -------------------------------------------------- --- The data constructors of RuntimeRep occupy *six* slots: +-- The data constructors of RuntimeRep occupy *five* slots: +-- See Note [Uniques for wired-in prelude things and known masks] +-- -- Example: WordRep -- -- * u: the TyCon of the boxing data type WordBox ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -387,28 +387,8 @@ isReflMCo _ = False Destructing coercions %* * %************************************************************************ - -Note [Function coercions] -~~~~~~~~~~~~~~~~~~~~~~~~~ -** ToDo: needs updating ** - -Remember that - (->) :: forall {r1} {r2}. Multiplicity -> TYPE r1 -> TYPE r2 -> Type - (=>) :: forall {r1} {r2}. CONSTRAINT r1 -> TYPE r2 -> Type - (==>) :: forall {r1} {r2}. CONSTRAINT r1 -> CONSTRAINT r2 -> Consraint -whose `RuntimeRep' arguments are intentionally marked inferred to -avoid type application. - -Hence - FunCo r VisArg mult co1 co2 :: (s1->t1) ~r (s2->t2) -is short for - TyConAppCo (->) mult co_rep1 co_rep2 co1 co2 -where co_rep1, co_rep2 are the coercions on the representations. - -and similarly for (=>) and (==>). -} - -- | This breaks a 'Coercion' with type @T A B C ~ T D E F@ into -- a list of 'Coercion's of kinds @A ~ D@, @B ~ E@ and @E ~ F at . Hence: -- @@ -425,9 +405,9 @@ decomposeCo arity co rs decomposeFunCo :: HasDebugCallStack => Coercion -- Input coercion -> (CoercionN, Coercion, Coercion) --- Expects co :: (s1 -> t1) ~ (s2 -> t2) --- Returns (co1 :: s1~s2, co2 :: t1~t2) --- See Note [Function coercions] for the "3" and "4" +-- Expects co :: (s1 %m1-> t1) ~ (s2 %m2-> t2) +-- Returns (cow :: m1 ~N m2, co1 :: s1~s2, co2 :: t1~t2) +-- actually cow will be a Phantom coercion if the input is a Phantom coercion decomposeFunCo (FunCo _ w co1 co2) = (w, co1, co2) -- Short-circuits the calls to mkSelCo @@ -770,11 +750,7 @@ mkNomReflCo = Refl mkTyConAppCo :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Coercion mkTyConAppCo r tc cos | Just (_af, w, co1, co2) <- tyConAppFun_maybe (mkReflCo r) tc cos - -- See Note [Function coercions] - = -- (a :: TYPE ra) -> (b :: TYPE rb) ~ (c :: TYPE rc) -> (d :: TYPE rd) - -- rep1 :: ra ~ rc rep2 :: rb ~ rd - -- co1 :: a ~ c co2 :: b ~ d - mkFunCo r w co1 co2 + = mkFunCo r w co1 co2 -- Expand type synonyms | ExpandsSyn tv_co_prs rhs_ty leftover_cos <- expandSynTyCon_maybe tc cos @@ -1137,15 +1113,6 @@ getNthFun :: FunSel -> a -- ^ argument -> a -- ^ result -> a -- ^ One of the above three --- See Note [Function coercions] --- If FunCo _ mult arg_co res_co :: (s1:TYPE sk1 :mult-> s2:TYPE sk2) --- ~ (t1:TYPE tk1 :mult-> t2:TYPE tk2) --- Then we want to behave as if co was --- TyConAppCo mult argk_co resk_co arg_co res_co --- where --- argk_co :: sk1 ~ tk1 = mkSelCo 0 (mkKindCo arg_co) --- resk_co :: sk2 ~ tk2 = mkSelCo 0 (mkKindCo res_co) --- i.e. mkRuntimeRepCo getNthFun SelMult mult _ _ = mult getNthFun SelArg _ arg _ = arg getNthFun SelRes _ _ res = res @@ -1158,7 +1125,7 @@ mkLRCo lr co = LRCo lr co -- | Instantiates a 'Coercion'. -mkInstCo :: Coercion -> Coercion -> Coercion +mkInstCo :: Coercion -> CoercionN -> Coercion mkInstCo (ForAllCo tcv _kind_co body_co) co | Just (arg, _) <- isReflCo_maybe co -- works for both tyvar and covar @@ -1174,7 +1141,7 @@ mkGReflRightCo r ty co -- instead of @isReflCo@ | otherwise = GRefl r ty (MCo co) --- | Given @ty :: k1@, @co :: k1 ~ k2@, +-- | Given @r@, @ty :: k1@, and @co :: k1 ~N k2@, -- produces @co' :: (ty |> co) ~r ty@ mkGReflLeftCo :: Role -> Type -> CoercionN -> Coercion mkGReflLeftCo r ty co ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -417,7 +417,7 @@ mkCoreUbxSum arity alt tys exp {- Note [Big tuples] ~~~~~~~~~~~~~~~~~~~~ "Big" tuples (`mkBigCoreTup` and friends) are more general than "small" -ones (`mkCoreTup` and friend) in two ways. +ones (`mkCoreTup` and friends) in two ways. 1. GHCs built-in tuples can only go up to 'mAX_TUPLE_SIZE' in arity, but we might conceivably want to build such a massive tuple as part of the @@ -501,8 +501,8 @@ wrapBox e e_ty = exprType e boxTy :: Type -> Type --- ^ If (e :: ty) and (ty :: Type), wrapBox is a no-op --- But if (ty :: ki), and ki is not Type, wrapBox returns the type +-- ^ If (e :: ty) and (ty :: Type), boxTy is a no-op +-- But if (ty :: ki), and ki is not Type, boxTy returns the type -- of (K @ty e), where K is the boxing data constructor for ki -- See Note [Boxing constructors] in GHC.Builtin.Types boxTy ty @@ -610,7 +610,7 @@ mkBigTupleSelectorSolo vars the_var scrut_var scrut = mkBigTupleSelector vars the_var scrut_var scrut -- | `mkSmallTupleSelector` is like 'mkBigTupleSelector', but for tuples that --- are guaranteed never to be "big". Also does not unwrap Dict types. +-- are guaranteed never to be "big". Also does not unwrap boxed types. -- -- > mkSmallTupleSelector [x] x v e = [| e |] -- > mkSmallTupleSelector [x,y,z] x v e = [| case e of v { (x,y,z) -> x } |] ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -2826,19 +2826,19 @@ pushCoTyArg co ty = Nothing where Pair tyL tyR = coercionKind co - -- co :: tyL ~ tyR + -- co :: tyL ~R tyR -- tyL = forall (a1 :: k1). ty1 -- tyR = forall (a2 :: k2). ty2 co1 = mkSymCo (mkSelCo SelForAll co) -- co1 :: k2 ~N k1 - -- Note that SelCo can extract a Nominal equality between the + -- Note that SelCo extracts a Nominal equality between the -- kinds of the types related by a coercion between forall-types. -- See the SelCo case in GHC.Core.Lint. co2 = mkInstCo co (mkGReflLeftCo Nominal ty co1) - -- co2 :: ty1[ (ty|>co1)/a1 ] ~ ty2[ ty/a2 ] - -- Arg of mkInstCo is always nominal, hence mkNomReflCo + -- co2 :: ty1[ (ty|>co1)/a1 ] ~R ty2[ ty/a2 ] + -- Arg of mkInstCo is always nominal, hence Nominal -- | If @pushCoValArg co = Just (co_arg, co_res)@, then -- ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -965,7 +965,9 @@ data Coercion -- ForAllCo :: _ -> N -> e -> e | FunCo Role CoercionN Coercion Coercion -- See Note [FunCo] - -- FunCo :: "e" -> N -> e -> e -> e + -- FunCo :: "e" -> N/P -> e -> e -> e + -- (if the role "e" is Phantom, the first coercion is, too) + -- the first coercion is for the multiplicity -- These are special | CoVarCo CoVar -- :: _ -> (N or R) @@ -1193,17 +1195,13 @@ SelTyCon, SelForAll, and SelFun. Note [FunCo] ~~~~~~~~~~~~ You might think that a FunCo (which connects two function types) should -contain the FunTyFlag from the function types. But we are allowed to -have an axiom (and hence a coercion) connecting Type and Constraint, thus - co :: (t::Type) ~ (c::Constraint) -c.f. GHC.Builtin.Types.Prim Note [Type and Constraint are not apart] -Given such a coercion we can use FunCo to make - FunCo co :: (t -> Int) ~ (c => Int) -Note that the two arrows are different: those FunTys have different -FunTyFlags! That's why: - -* FunCo does not store an FunTyFlag -* We use mkFuntionType in the FunCo case of coercionLKind/coercoinRKind, +contain the FunTyFlag from the function types. We don't need to store +this, though: it's completely recoverable from the kinds of the arguments. +We thus use mkFunctionType in the FunCo case of coercionLKind/coercionRKind, +which sets the FunTyFlag correctly. + +If you are worried about coercions connecting, say, (=>) and (->), see +Note [Type and Constraint are not apart] in GHC.Builtin.Types.Prim. Note [Coercion axioms applied to coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -541,7 +541,7 @@ data MaybeApartReason | MARInfinite -- ^ matching e.g. a ~? Maybe a - | MARTypeVsConstraint -- ^ matching Type ~? Constraint + | MARTypeVsConstraint -- ^ matching Type ~? Constraint or the arrow types -- See Note [Type and Constraint are not apart] in GHC.Builtin.Types.Prim instance Outputable MaybeApartReason where @@ -1127,6 +1127,13 @@ unify_ty env ty1 ty2 _kco , Just {} <- sORTKind_maybe ty2 = maybeApart MARTypeVsConstraint + -- The arrow types are not Apart + -- See Note [Type and Constraint are not apart] in GHC.Builtin.Types.Prim + -- NB: at this point we know that the two TyCons do not match + | FunTy {} <- ty1 + , FunTy {} <- ty2 + = maybeApart MARTypeVsConstraint + where mb_tc_app1 = splitTyConApp_maybe ty1 mb_tc_app2 = splitTyConApp_maybe ty2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b10aad63a0d3506d195e4235a84d2f069b717e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b10aad63a0d3506d195e4235a84d2f069b717e4 You're receiving 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 Sep 30 05:49:47 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 30 Sep 2022 01:49:47 -0400 Subject: [Git][ghc/ghc][wip/jsem] jsem stub Message-ID: <6336837b9022b_2c975742bcfe201102123@gitlab.mail> Matthew Pickering pushed to branch wip/jsem at Glasgow Haskell Compiler / GHC Commits: 5175c78b by Matthew Pickering at 2022-09-30T06:49:42+01:00 jsem stub - - - - - 1 changed file: - docs/users_guide/using.rst Changes: ===================================== docs/users_guide/using.rst ===================================== @@ -751,6 +751,14 @@ search path (see :ref:`search-path`). number of processors. Note that compilation of a module may not begin until its dependencies have been built. +.. ghc-flag:: -jsem + :shortdesc: stub + :type: dynamic + :category: misc + + Stub + + .. _multi-home-units: Multiple Home Units View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5175c78b1ca16af6229a6813f4a87dcd2789772b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5175c78b1ca16af6229a6813f4a87dcd2789772b You're receiving 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 Sep 30 07:45:59 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 30 Sep 2022 03:45:59 -0400 Subject: [Git][ghc/ghc][wip/T21851-rule-win] 3 commits: Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Message-ID: <63369eb737969_2c97572ed3bc7811148b0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851-rule-win at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 7b9ad44f by Simon Peyton Jones at 2022-09-30T08:48:08+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, with (sadly) a 0.5% upward trend. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ------------------------------------- Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +4.4% BAD T10421a(normal) +6.1% T10547(normal) +1.8% T11195(normal) +1.2% T11303b(normal) +1.2% T11822(normal) +1.0% T13253(normal) +1.7% T15304(normal) -1.3% T16577(normal) +3.3% BAD T17516(normal) +2.4% T17977b(normal) +1.2% T5837(normal) +1.6% T8095(normal) -1.2% T9198(normal) +1.1% T9961(normal) +2.8% BAD hard_hole_fits(normal) +1.0% geo. mean +0.5% minimum -1.7% maximum +6.1% Metric Increase: T10421 T16577 T9961 - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Utils/Monad.hs - docs/users_guide/using-optimisation.rst - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity04.stderr - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity06.stderr - testsuite/tests/arityanal/should_compile/Arity08.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity15.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/determinism/determ004/determ004.hs - testsuite/tests/lib/integer/Makefile - testsuite/tests/simplCore/should_compile/OpaqueNoSpecialise.stderr - testsuite/tests/simplCore/should_compile/T13156.hs - testsuite/tests/simplCore/should_compile/T14152.stderr - testsuite/tests/simplCore/should_compile/T14152a.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T18355.stderr - testsuite/tests/simplCore/should_compile/T19890.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/683c166b191bdea248e9eb069be3a748eb97aad4...7b9ad44f42207a7d4ce388c945437f5856609401 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/683c166b191bdea248e9eb069be3a748eb97aad4...7b9ad44f42207a7d4ce388c945437f5856609401 You're receiving 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 Sep 30 07:52:47 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 30 Sep 2022 03:52:47 -0400 Subject: [Git][ghc/ghc][wip/T21470] 13 commits: Apply some tricks to speed up core lint. Message-ID: <6336a04f48aa4_2c975742bd2a1c1118084@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21470 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 2f34e1b0 by Simon Peyton Jones at 2022-09-30T08:54:40+01: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 T13056, because we generate more specialised code. This seems OK. Metric Increase: T13056 - - - - - e57eefb8 by Simon Peyton Jones at 2022-09-30T08:54:41+01:00 Fix binder-swap bug This patch fixes #21229 / #21470 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. I als 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. - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/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/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.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/f7a033ac30301c942594c59e8ad5f03a3e2ecd3e...e57eefb80e83061c03e49dd2fd91f29635181625 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7a033ac30301c942594c59e8ad5f03a3e2ecd3e...e57eefb80e83061c03e49dd2fd91f29635181625 You're receiving 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 Sep 30 10:49:23 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 30 Sep 2022 06:49:23 -0400 Subject: [Git][ghc/ghc][wip/T21623] 8 commits: Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Message-ID: <6336c9b34516d_2c97575148c11340b5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 2ca6a829 by Simon Peyton Jones at 2022-09-30T11:51:27+01: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 - - - - - 0e32ad95 by Simon Peyton Jones at 2022-09-30T11:51:27+01:00 Wibbles - - - - - 91436b36 by Simon Peyton Jones at 2022-09-30T11:51:27+01:00 Unused import - - - - - b0b943c3 by Simon Peyton Jones at 2022-09-30T11:51:27+01:00 Better boxingCon_maybe - - - - - 124937d4 by Richard Eisenberg at 2022-09-30T11:51:27+01:00 Improvements to comments, etc., from Richard - - - - - a7286187 by Simon Peyton Jones at 2022-09-30T11:51:27+01:00 Respond to Richard - - - - - 17 changed files: - .gitlab/ci.sh - 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 - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b10aad63a0d3506d195e4235a84d2f069b717e4...a728618761d09799d6813ccf278c2dfcf3fd308b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b10aad63a0d3506d195e4235a84d2f069b717e4...a728618761d09799d6813ccf278c2dfcf3fd308b You're receiving 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 Sep 30 11:20:17 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 30 Sep 2022 07:20:17 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Stack: Docs and cleanup Message-ID: <6336d0f1a1045_2c975742bcfe70113484f@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 36c7ed0b by doyougnu at 2022-09-30T07:19:34-04:00 StgToJS.Stack: Docs and cleanup In particular: -- Removing some single use functions -- Some minor refactors related to these removals - - - - - 3 changed files: - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Stack.hs Changes: ===================================== compiler/GHC/StgToJS/Apply.hs ===================================== @@ -740,7 +740,7 @@ stackApply s fun_name nargs nvars = ] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (entryClosureType c)]) ] - funExact c = popSkip' 1 (reverse $ take nvars jsRegsFromR2) <> returnS c + funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c stackArgs = map (\x -> stack .! (sp - toJExpr x)) [1..nvars] papCase :: JExpr -> JStat ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -644,13 +644,24 @@ genRet ctx e at as l = freshIdent >>= f MultiValAlt _n -> idVt e _ -> [PtrV] + -- special case for popping CCS but preserving stack size + pop_handle_CCS :: [(JExpr, StackSlot)] -> G JStat + pop_handle_CCS [] = return mempty + pop_handle_CCS xs = do + -- grab the slots from 'xs' and push + addSlots (map snd xs) + -- move the stack pointer into the stack by ''length xs + n' + a <- adjSpN (length xs) + -- now load from the top of the stack + return (loadSkip 0 (map fst xs) <> a) + fun free = resetSlots $ do decs <- declVarsForId e load <- flip assignAll (map toJExpr [R1 ..]) . map toJExpr <$> identsForId e loadv <- verifyRuntimeReps [e] ras <- loadRetArgs free rasv <- verifyRuntimeReps (map (\(x,_,_)->x) free) - restoreCCS <- ifProfilingM $ popUnknown [jCurrentCCS] + restoreCCS <- ifProfilingM . pop_handle_CCS $ pure (jCurrentCCS, SlotUnknown) rlne <- popLneFrame False lneLive ctx' rlnev <- verifyRuntimeReps lneVars (alts, _altr) <- genAlts ctx' e at Nothing as ===================================== compiler/GHC/StgToJS/Stack.hs ===================================== @@ -1,7 +1,30 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} --- | Stack manipulation +----------------------------------------------------------------------------- +-- | +-- Module : GHC.JS.Stack +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Utilities and wrappers for Stack manipulation in JS Land. +-- +-- In general, functions suffixed with a tick do the actual work, functions +-- suffixed with an "I" are identical to the non-I versions but work on 'Ident's +-- +-- The stack in JS land is held in the special variable 'h$stack' and the stack +-- pointer is held in 'h$sp'. The top of the stack thus exists at +-- 'h$stack[h$sp]'. h$stack[h$sp + i] where i > 0, moves deeper into the stack +-- into older entries, whereas h$stack[h$sp - i] moves towards the top of the +-- stack. +----------------------------------------------------------------------------- + module GHC.StgToJS.Stack ( resetSlots , isolateSlots @@ -10,7 +33,6 @@ module GHC.StgToJS.Stack , addSlots , dropSlots , addUnknownSlots - , adjPushStack , push , push' , adjSpN @@ -24,12 +46,8 @@ module GHC.StgToJS.Stack , pushOptimized' , pushOptimized , pushLneFrame - , pop - , popn - , popUnknown - , popSkipUnknown + , popN , popSkip - , popSkip' , popSkipI , loadSkip -- * Thunk update @@ -62,7 +80,7 @@ import Data.Array import Data.Monoid import Control.Monad --- | Run the action with no stack info +-- | Run the action, 'm', with no stack info resetSlots :: G a -> G a resetSlots m = do s <- getSlots @@ -73,7 +91,8 @@ resetSlots m = do setStackDepth d return a --- | run the action with current stack info, but don't let modifications propagate +-- | run the action, 'm', with current stack info, but don't let modifications +-- propagate isolateSlots :: G a -> G a isolateSlots m = do s <- getSlots @@ -117,14 +136,10 @@ addSlots xs = do s <- getSlots setSlots (xs ++ s) +-- | drop 'n' slots from our stack knowledge dropSlots :: Int -> G () dropSlots n = modifySlots (drop n) -adjPushStack :: Int -> G () -adjPushStack n = do - modifyStackDepth (+n) - dropSlots n - push :: [JExpr] -> G JStat push xs = do dropSlots (length xs) @@ -137,42 +152,85 @@ push' cs xs | csInlinePush cs || l > 32 || l < 2 = adjSp' l <> mconcat items | otherwise = ApplStat (toJExpr $ pushN ! l) xs where - items = zipWith (\i e -> AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e)) - [(1::Int)..] xs + items = zipWith f [(1::Int)..] xs offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) l = length xs + f i e = AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e) +-- | Grow the stack pointer by 'n' without modifying the stack depth. The stack +-- is just a JS array so we add to grow (instead of the traditional subtract) adjSp' :: Int -> JStat adjSp' 0 = mempty adjSp' n = sp |= InfixExpr AddOp sp (toJExpr n) +-- | Shrink the stack pointer by 'n'. The stack grows downward so substract adjSpN' :: Int -> JStat adjSpN' 0 = mempty adjSpN' n = sp |= InfixExpr SubOp sp (toJExpr n) +-- | Wrapper which adjusts the stack pointer /and/ modifies the stack depth +-- tracked in 'G'. See also 'adjSp'' which actually does the stack pointer +-- manipulation. adjSp :: Int -> G JStat adjSp 0 = return mempty adjSp n = do + -- grow depth by n modifyStackDepth (+n) return (adjSp' n) +-- | Shrink the stack and stack pointer. NB: This function is unsafe when the +-- input 'n', is negative. This function wraps around 'adjSpN' which actually +-- performs the work. adjSpN :: Int -> G JStat adjSpN 0 = return mempty adjSpN n = do modifyStackDepth (\x -> x - n) return (adjSpN' n) +-- | A constant array that holds global function symbols which do N pushes onto +-- the stack. For example: +-- @ +-- function h$p1(x1) { +-- ++h$sp; +-- h$stack[(h$sp - 0)] = x1; +-- }; +-- function h$p2(x1, x2) { +-- h$sp += 2; +-- h$stack[(h$sp - 1)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- and so on up to 32. pushN :: Array Int Ident pushN = listArray (1,32) $ map (TxtI . mkFastString . ("h$p"++) . show) [(1::Int)..32] +-- | Convert all function symbols in 'pushN' to global top-level functions. This +-- is a hack which converts the function symbols to variables. This hack is +-- caught in 'GHC.StgToJS.Printer.prettyBlock'' to turn these into global +-- functions. pushN' :: Array Int JExpr pushN' = fmap (ValExpr . JVar) pushN + where +-- | Partial Push functions. Like 'pushN' except these push functions skip +-- slots. For example, +-- @ +-- function h$pp33(x1, x2) { +-- h$sp += 6; +-- h$stack[(h$sp - 5)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- The 33rd entry skips slots 1-4 to bind the top of the stack and the 6th +-- slot. pushNN :: Array Integer Ident pushNN = listArray (1,255) $ map (TxtI . mkFastString . ("h$pp"++) . show) [(1::Int)..255] +-- | Like 'pushN'' but for the partial push functions pushNN' :: Array Integer JExpr pushNN' = fmap (ValExpr . JVar) pushNN @@ -216,82 +274,67 @@ pushOptimized xs = do offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) +-- | push a let-no-escape frame onto the stack pushLneFrame :: HasDebugCallStack => Int -> ExprCtx -> G JStat pushLneFrame size ctx = let ctx' = ctxLneShrinkStack ctx size in pushOptimized' (ctxLneFrameVars ctx') -popUnknown :: [JExpr] -> G JStat -popUnknown xs = popSkipUnknown 0 xs - -popSkipUnknown :: Int -> [JExpr] -> G JStat -popSkipUnknown n xs = popSkip n (map (,SlotUnknown) xs) - -pop :: [(JExpr,StackSlot)] -> G JStat -pop = popSkip 0 - --- | pop the expressions, but ignore the top n elements of the stack -popSkip :: Int -> [(JExpr,StackSlot)] -> G JStat -popSkip 0 [] = pure mempty -popSkip n [] = addUnknownSlots n >> adjSpN n -popSkip n xs = do - addUnknownSlots n - addSlots (map snd xs) - a <- adjSpN (length xs + n) - return (loadSkip n (map fst xs) <> a) - --- | pop things, don't upstate stack knowledge -popSkip' :: Int -- ^ number of slots to skip +-- | Pop things, don't update the stack knowledge in 'G' +popSkip :: Int -- ^ number of slots to skip -> [JExpr] -- ^ assign stack slot values to these -> JStat -popSkip' 0 [] = mempty -popSkip' n [] = adjSpN' n -popSkip' n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) +popSkip 0 [] = mempty +popSkip n [] = adjSpN' n +popSkip n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) --- | like popSkip, but without modifying the stack pointer +-- | Load 'length (xs :: [JExpr])' things from the stack at offset 'n :: Int'. +-- This function does no stack pointer manipulation, it merely indexes into the +-- stack and loads payloads into 'xs'. loadSkip :: Int -> [JExpr] -> JStat loadSkip = loadSkipFrom sp - -loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat -loadSkipFrom fr n xs = mconcat items - where - items = reverse $ zipWith (\i ex -> ex |= IdxExpr stack (toJExpr (offset (i+n)))) - [(0::Int)..] - (reverse xs) - offset 0 = toJExpr fr - offset n = InfixExpr SubOp (toJExpr fr) (toJExpr n) - - --- declare and pop + where + loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat + loadSkipFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + -- helper to generate sp - n offset to index with + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + -- helper to load stack .! i into ex, e.g., ex = stack[i] + f i ex = ex |= IdxExpr stack (toJExpr (offset (i+n))) + + +-- | Pop but preserve the first N slots popSkipI :: Int -> [(Ident,StackSlot)] -> G JStat popSkipI 0 [] = pure mempty -popSkipI n [] = adjSpN n +popSkipI n [] = popN n popSkipI n xs = do + -- add N unknown slots addUnknownSlots n + -- now add the slots from xs, after this line the stack should look like + -- [xs] ++ [Unknown...] ++ old_stack addSlots (map snd xs) + -- move stack pointer into the stack by (length xs + n), basically resetting + -- the stack pointer a <- adjSpN (length xs + n) + -- now load skipping first N slots return (loadSkipI n (map fst xs) <> a) --- like popSkip, but without modifying sp +-- | Just like 'loadSkip' but operate on 'Ident's rather than 'JExpr' loadSkipI :: Int -> [Ident] -> JStat loadSkipI = loadSkipIFrom sp - -loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat -loadSkipIFrom fr n xs = mconcat items - where - items = reverse $ zipWith f [(0::Int)..] (reverse xs) - offset 0 = fr - offset n = InfixExpr SubOp fr (toJExpr n) - f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) - -popn :: Int -> G JStat -popn n = addUnknownSlots n >> adjSpN n - -updateThunk' :: StgToJSConfig -> JStat -updateThunk' settings = - if csInlineBlackhole settings - then bhStats settings True - else ApplStat (var "h$bh") [] + where loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat + loadSkipIFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) + +-- | Blindly pop N slots +popN :: Int -> G JStat +popN n = addUnknownSlots n >> adjSpN n -- | Generate statements to update the current node with a blackhole bhStats :: StgToJSConfig -> Bool -> JStat @@ -302,8 +345,23 @@ bhStats s pushUpd = mconcat , toJExpr R1 .^ closureField2_ |= null_ -- will be filled with waiters array ] +-- | Wrapper around 'updateThunk'', performs the stack manipulation before +-- updating the Thunk. updateThunk :: G JStat updateThunk = do settings <- getSettings - adjPushStack 2 -- update frame size + -- update frame size + let adjPushStack :: Int -> G () + adjPushStack n = do modifyStackDepth (+n) + dropSlots n + adjPushStack 2 return $ (updateThunk' settings) + +-- | Update a thunk by checking 'StgToJSConfig'. If the config inlines black +-- holes then update inline, else make an explicit call to the black hole +-- handler. +updateThunk' :: StgToJSConfig -> JStat +updateThunk' settings = + if csInlineBlackhole settings + then bhStats settings True + else ApplStat (var "h$bh") [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36c7ed0b2bd2c257b55704015e1b6fee963b33d7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36c7ed0b2bd2c257b55704015e1b6fee963b33d7 You're receiving 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 Sep 30 11:24:44 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 30 Sep 2022 07:24:44 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Stack: Docs and cleanup Message-ID: <6336d1fc6b09a_2c975742bcfe701135010@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 68633bd4 by doyougnu at 2022-09-30T07:24:34-04:00 StgToJS.Stack: Docs and cleanup In particular: -- Removing some single use functions -- Some minor refactors related to these removals - - - - - 3 changed files: - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Stack.hs Changes: ===================================== compiler/GHC/StgToJS/Apply.hs ===================================== @@ -740,7 +740,7 @@ stackApply s fun_name nargs nvars = ] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (entryClosureType c)]) ] - funExact c = popSkip' 1 (reverse $ take nvars jsRegsFromR2) <> returnS c + funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c stackArgs = map (\x -> stack .! (sp - toJExpr x)) [1..nvars] papCase :: JExpr -> JStat ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -644,13 +644,24 @@ genRet ctx e at as l = freshIdent >>= f MultiValAlt _n -> idVt e _ -> [PtrV] + -- special case for popping CCS but preserving stack size + pop_handle_CCS :: [(JExpr, StackSlot)] -> G JStat + pop_handle_CCS [] = return mempty + pop_handle_CCS xs = do + -- grab the slots from 'xs' and push + addSlots (map snd xs) + -- move the stack pointer into the stack by ''length xs + n' + a <- adjSpN (length xs) + -- now load from the top of the stack + return (loadSkip 0 (map fst xs) <> a) + fun free = resetSlots $ do decs <- declVarsForId e load <- flip assignAll (map toJExpr [R1 ..]) . map toJExpr <$> identsForId e loadv <- verifyRuntimeReps [e] ras <- loadRetArgs free rasv <- verifyRuntimeReps (map (\(x,_,_)->x) free) - restoreCCS <- ifProfilingM $ popUnknown [jCurrentCCS] + restoreCCS <- ifProfilingM . pop_handle_CCS $ pure (jCurrentCCS, SlotUnknown) rlne <- popLneFrame False lneLive ctx' rlnev <- verifyRuntimeReps lneVars (alts, _altr) <- genAlts ctx' e at Nothing as ===================================== compiler/GHC/StgToJS/Stack.hs ===================================== @@ -1,7 +1,30 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} --- | Stack manipulation +----------------------------------------------------------------------------- +-- | +-- Module : GHC.JS.Stack +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Utilities and wrappers for Stack manipulation in JS Land. +-- +-- In general, functions suffixed with a tick do the actual work, functions +-- suffixed with an "I" are identical to the non-I versions but work on 'Ident's +-- +-- The stack in JS land is held in the special variable 'h$stack' and the stack +-- pointer is held in 'h$sp'. The top of the stack thus exists at +-- 'h$stack[h$sp]'. h$stack[h$sp + i] where i > 0, moves deeper into the stack +-- into older entries, whereas h$stack[h$sp - i] moves towards the top of the +-- stack. +----------------------------------------------------------------------------- + module GHC.StgToJS.Stack ( resetSlots , isolateSlots @@ -10,7 +33,6 @@ module GHC.StgToJS.Stack , addSlots , dropSlots , addUnknownSlots - , adjPushStack , push , push' , adjSpN @@ -24,12 +46,8 @@ module GHC.StgToJS.Stack , pushOptimized' , pushOptimized , pushLneFrame - , pop - , popn - , popUnknown - , popSkipUnknown + , popN , popSkip - , popSkip' , popSkipI , loadSkip -- * Thunk update @@ -62,7 +80,7 @@ import Data.Array import Data.Monoid import Control.Monad --- | Run the action with no stack info +-- | Run the action, 'm', with no stack info resetSlots :: G a -> G a resetSlots m = do s <- getSlots @@ -73,7 +91,8 @@ resetSlots m = do setStackDepth d return a --- | run the action with current stack info, but don't let modifications propagate +-- | run the action, 'm', with current stack info, but don't let modifications +-- propagate isolateSlots :: G a -> G a isolateSlots m = do s <- getSlots @@ -117,14 +136,10 @@ addSlots xs = do s <- getSlots setSlots (xs ++ s) +-- | drop 'n' slots from our stack knowledge dropSlots :: Int -> G () dropSlots n = modifySlots (drop n) -adjPushStack :: Int -> G () -adjPushStack n = do - modifyStackDepth (+n) - dropSlots n - push :: [JExpr] -> G JStat push xs = do dropSlots (length xs) @@ -137,42 +152,85 @@ push' cs xs | csInlinePush cs || l > 32 || l < 2 = adjSp' l <> mconcat items | otherwise = ApplStat (toJExpr $ pushN ! l) xs where - items = zipWith (\i e -> AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e)) - [(1::Int)..] xs + items = zipWith f [(1::Int)..] xs offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) l = length xs + f i e = AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e) +-- | Grow the stack pointer by 'n' without modifying the stack depth. The stack +-- is just a JS array so we add to grow (instead of the traditional subtract) adjSp' :: Int -> JStat adjSp' 0 = mempty adjSp' n = sp |= InfixExpr AddOp sp (toJExpr n) +-- | Shrink the stack pointer by 'n'. The stack grows downward so substract adjSpN' :: Int -> JStat adjSpN' 0 = mempty adjSpN' n = sp |= InfixExpr SubOp sp (toJExpr n) +-- | Wrapper which adjusts the stack pointer /and/ modifies the stack depth +-- tracked in 'G'. See also 'adjSp'' which actually does the stack pointer +-- manipulation. adjSp :: Int -> G JStat adjSp 0 = return mempty adjSp n = do + -- grow depth by n modifyStackDepth (+n) return (adjSp' n) +-- | Shrink the stack and stack pointer. NB: This function is unsafe when the +-- input 'n', is negative. This function wraps around 'adjSpN' which actually +-- performs the work. adjSpN :: Int -> G JStat adjSpN 0 = return mempty adjSpN n = do modifyStackDepth (\x -> x - n) return (adjSpN' n) +-- | A constant array that holds global function symbols which do N pushes onto +-- the stack. For example: +-- @ +-- function h$p1(x1) { +-- ++h$sp; +-- h$stack[(h$sp - 0)] = x1; +-- }; +-- function h$p2(x1, x2) { +-- h$sp += 2; +-- h$stack[(h$sp - 1)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- and so on up to 32. pushN :: Array Int Ident pushN = listArray (1,32) $ map (TxtI . mkFastString . ("h$p"++) . show) [(1::Int)..32] +-- | Convert all function symbols in 'pushN' to global top-level functions. This +-- is a hack which converts the function symbols to variables. This hack is +-- caught in 'GHC.StgToJS.Printer.prettyBlock'' to turn these into global +-- functions. pushN' :: Array Int JExpr pushN' = fmap (ValExpr . JVar) pushN + where +-- | Partial Push functions. Like 'pushN' except these push functions skip +-- slots. For example, +-- @ +-- function h$pp33(x1, x2) { +-- h$sp += 6; +-- h$stack[(h$sp - 5)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- The 33rd entry skips slots 1-4 to bind the top of the stack and the 6th +-- slot. See 'pushOptimized' and 'pushOptimized'' for use cases. pushNN :: Array Integer Ident pushNN = listArray (1,255) $ map (TxtI . mkFastString . ("h$pp"++) . show) [(1::Int)..255] +-- | Like 'pushN'' but for the partial push functions pushNN' :: Array Integer JExpr pushNN' = fmap (ValExpr . JVar) pushNN @@ -216,82 +274,67 @@ pushOptimized xs = do offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) +-- | push a let-no-escape frame onto the stack pushLneFrame :: HasDebugCallStack => Int -> ExprCtx -> G JStat pushLneFrame size ctx = let ctx' = ctxLneShrinkStack ctx size in pushOptimized' (ctxLneFrameVars ctx') -popUnknown :: [JExpr] -> G JStat -popUnknown xs = popSkipUnknown 0 xs - -popSkipUnknown :: Int -> [JExpr] -> G JStat -popSkipUnknown n xs = popSkip n (map (,SlotUnknown) xs) - -pop :: [(JExpr,StackSlot)] -> G JStat -pop = popSkip 0 - --- | pop the expressions, but ignore the top n elements of the stack -popSkip :: Int -> [(JExpr,StackSlot)] -> G JStat -popSkip 0 [] = pure mempty -popSkip n [] = addUnknownSlots n >> adjSpN n -popSkip n xs = do - addUnknownSlots n - addSlots (map snd xs) - a <- adjSpN (length xs + n) - return (loadSkip n (map fst xs) <> a) - --- | pop things, don't upstate stack knowledge -popSkip' :: Int -- ^ number of slots to skip +-- | Pop things, don't update the stack knowledge in 'G' +popSkip :: Int -- ^ number of slots to skip -> [JExpr] -- ^ assign stack slot values to these -> JStat -popSkip' 0 [] = mempty -popSkip' n [] = adjSpN' n -popSkip' n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) +popSkip 0 [] = mempty +popSkip n [] = adjSpN' n +popSkip n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) --- | like popSkip, but without modifying the stack pointer +-- | Load 'length (xs :: [JExpr])' things from the stack at offset 'n :: Int'. +-- This function does no stack pointer manipulation, it merely indexes into the +-- stack and loads payloads into 'xs'. loadSkip :: Int -> [JExpr] -> JStat loadSkip = loadSkipFrom sp - -loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat -loadSkipFrom fr n xs = mconcat items - where - items = reverse $ zipWith (\i ex -> ex |= IdxExpr stack (toJExpr (offset (i+n)))) - [(0::Int)..] - (reverse xs) - offset 0 = toJExpr fr - offset n = InfixExpr SubOp (toJExpr fr) (toJExpr n) - - --- declare and pop + where + loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat + loadSkipFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + -- helper to generate sp - n offset to index with + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + -- helper to load stack .! i into ex, e.g., ex = stack[i] + f i ex = ex |= IdxExpr stack (toJExpr (offset (i+n))) + + +-- | Pop but preserve the first N slots popSkipI :: Int -> [(Ident,StackSlot)] -> G JStat popSkipI 0 [] = pure mempty -popSkipI n [] = adjSpN n +popSkipI n [] = popN n popSkipI n xs = do + -- add N unknown slots addUnknownSlots n + -- now add the slots from xs, after this line the stack should look like + -- [xs] ++ [Unknown...] ++ old_stack addSlots (map snd xs) + -- move stack pointer into the stack by (length xs + n), basically resetting + -- the stack pointer a <- adjSpN (length xs + n) + -- now load skipping first N slots return (loadSkipI n (map fst xs) <> a) --- like popSkip, but without modifying sp +-- | Just like 'loadSkip' but operate on 'Ident's rather than 'JExpr' loadSkipI :: Int -> [Ident] -> JStat loadSkipI = loadSkipIFrom sp - -loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat -loadSkipIFrom fr n xs = mconcat items - where - items = reverse $ zipWith f [(0::Int)..] (reverse xs) - offset 0 = fr - offset n = InfixExpr SubOp fr (toJExpr n) - f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) - -popn :: Int -> G JStat -popn n = addUnknownSlots n >> adjSpN n - -updateThunk' :: StgToJSConfig -> JStat -updateThunk' settings = - if csInlineBlackhole settings - then bhStats settings True - else ApplStat (var "h$bh") [] + where loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat + loadSkipIFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) + +-- | Blindly pop N slots +popN :: Int -> G JStat +popN n = addUnknownSlots n >> adjSpN n -- | Generate statements to update the current node with a blackhole bhStats :: StgToJSConfig -> Bool -> JStat @@ -302,8 +345,23 @@ bhStats s pushUpd = mconcat , toJExpr R1 .^ closureField2_ |= null_ -- will be filled with waiters array ] +-- | Wrapper around 'updateThunk'', performs the stack manipulation before +-- updating the Thunk. updateThunk :: G JStat updateThunk = do settings <- getSettings - adjPushStack 2 -- update frame size + -- update frame size + let adjPushStack :: Int -> G () + adjPushStack n = do modifyStackDepth (+n) + dropSlots n + adjPushStack 2 return $ (updateThunk' settings) + +-- | Update a thunk by checking 'StgToJSConfig'. If the config inlines black +-- holes then update inline, else make an explicit call to the black hole +-- handler. +updateThunk' :: StgToJSConfig -> JStat +updateThunk' settings = + if csInlineBlackhole settings + then bhStats settings True + else ApplStat (var "h$bh") [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68633bd49a798d95265021af87926f4fae71b2fd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68633bd49a798d95265021af87926f4fae71b2fd You're receiving 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 Sep 30 11:41:59 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 30 Sep 2022 07:41:59 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS.Stack: Docs and cleanup Message-ID: <6336d6072ebd7_2c9757514001137221@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 498a1882 by doyougnu at 2022-09-30T07:41:06-04:00 StgToJS.Stack: Docs and cleanup In particular: -- Removing some single use functions -- Some minor refactors related to these removals - - - - - 3 changed files: - compiler/GHC/StgToJS/Apply.hs - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Stack.hs Changes: ===================================== compiler/GHC/StgToJS/Apply.hs ===================================== @@ -740,7 +740,7 @@ stackApply s fun_name nargs nvars = ] (appS "throw" [toJExpr ("panic: " <> fun_name <> ", unexpected closure type: ") + (entryClosureType c)]) ] - funExact c = popSkip' 1 (reverse $ take nvars jsRegsFromR2) <> returnS c + funExact c = popSkip 1 (reverse $ take nvars jsRegsFromR2) <> returnS c stackArgs = map (\x -> stack .! (sp - toJExpr x)) [1..nvars] papCase :: JExpr -> JStat ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -644,13 +644,24 @@ genRet ctx e at as l = freshIdent >>= f MultiValAlt _n -> idVt e _ -> [PtrV] + -- special case for popping CCS but preserving stack size + pop_handle_CCS :: [(JExpr, StackSlot)] -> G JStat + pop_handle_CCS [] = return mempty + pop_handle_CCS xs = do + -- grab the slots from 'xs' and push + addSlots (map snd xs) + -- move the stack pointer into the stack by ''length xs + n' + a <- adjSpN (length xs) + -- now load from the top of the stack + return (loadSkip 0 (map fst xs) <> a) + fun free = resetSlots $ do decs <- declVarsForId e load <- flip assignAll (map toJExpr [R1 ..]) . map toJExpr <$> identsForId e loadv <- verifyRuntimeReps [e] ras <- loadRetArgs free rasv <- verifyRuntimeReps (map (\(x,_,_)->x) free) - restoreCCS <- ifProfilingM $ popUnknown [jCurrentCCS] + restoreCCS <- ifProfilingM . pop_handle_CCS $ pure (jCurrentCCS, SlotUnknown) rlne <- popLneFrame False lneLive ctx' rlnev <- verifyRuntimeReps lneVars (alts, _altr) <- genAlts ctx' e at Nothing as ===================================== compiler/GHC/StgToJS/Stack.hs ===================================== @@ -1,7 +1,38 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} --- | Stack manipulation +----------------------------------------------------------------------------- +-- | +-- Module : GHC.JS.Stack +-- Copyright : (c) The University of Glasgow 2001 +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Jeffrey Young +-- Luite Stegeman +-- Sylvain Henry +-- Josh Meredith +-- Stability : experimental +-- +-- Utilities and wrappers for Stack manipulation in JS Land. +-- +-- In general, functions suffixed with a tick do the actual work, functions +-- suffixed with an "I" are identical to the non-I versions but work on 'Ident's +-- +-- The stack in JS land is held in the special JS array 'h$stack' and the stack +-- pointer is held in 'h$sp'. The top of the stack thus exists at +-- 'h$stack[h$sp]'. h$stack[h$sp + i] where i > 0, moves deeper into the stack +-- into older entries, whereas h$stack[h$sp - i] moves towards the top of the +-- stack. +-- +-- The stack layout algorithm is slightly peculiar. It makes an effort to +-- remember recently popped things so that if these values need to be pushed +-- then they can be quickly. The implementation for this is storing these values +-- above the stack pointer, and the pushing will skip slots that we know we will +-- use and fill in slots marked as unknown. Thus, you may find that our push and +-- pop functions do some non-traditional stack manipulation such as adding slots +-- in pop or removing slots in push. +----------------------------------------------------------------------------- + module GHC.StgToJS.Stack ( resetSlots , isolateSlots @@ -10,7 +41,6 @@ module GHC.StgToJS.Stack , addSlots , dropSlots , addUnknownSlots - , adjPushStack , push , push' , adjSpN @@ -24,12 +54,8 @@ module GHC.StgToJS.Stack , pushOptimized' , pushOptimized , pushLneFrame - , pop - , popn - , popUnknown - , popSkipUnknown + , popN , popSkip - , popSkip' , popSkipI , loadSkip -- * Thunk update @@ -62,7 +88,7 @@ import Data.Array import Data.Monoid import Control.Monad --- | Run the action with no stack info +-- | Run the action, 'm', with no stack info resetSlots :: G a -> G a resetSlots m = do s <- getSlots @@ -73,7 +99,8 @@ resetSlots m = do setStackDepth d return a --- | run the action with current stack info, but don't let modifications propagate +-- | run the action, 'm', with current stack info, but don't let modifications +-- propagate isolateSlots :: G a -> G a isolateSlots m = do s <- getSlots @@ -117,14 +144,10 @@ addSlots xs = do s <- getSlots setSlots (xs ++ s) +-- | drop 'n' slots from our stack knowledge dropSlots :: Int -> G () dropSlots n = modifySlots (drop n) -adjPushStack :: Int -> G () -adjPushStack n = do - modifyStackDepth (+n) - dropSlots n - push :: [JExpr] -> G JStat push xs = do dropSlots (length xs) @@ -137,42 +160,85 @@ push' cs xs | csInlinePush cs || l > 32 || l < 2 = adjSp' l <> mconcat items | otherwise = ApplStat (toJExpr $ pushN ! l) xs where - items = zipWith (\i e -> AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e)) - [(1::Int)..] xs + items = zipWith f [(1::Int)..] xs offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) l = length xs + f i e = AssignStat ((IdxExpr stack) (toJExpr (offset i))) (toJExpr e) +-- | Grow the stack pointer by 'n' without modifying the stack depth. The stack +-- is just a JS array so we add to grow (instead of the traditional subtract) adjSp' :: Int -> JStat adjSp' 0 = mempty adjSp' n = sp |= InfixExpr AddOp sp (toJExpr n) +-- | Shrink the stack pointer by 'n'. The stack grows downward so substract adjSpN' :: Int -> JStat adjSpN' 0 = mempty adjSpN' n = sp |= InfixExpr SubOp sp (toJExpr n) +-- | Wrapper which adjusts the stack pointer /and/ modifies the stack depth +-- tracked in 'G'. See also 'adjSp'' which actually does the stack pointer +-- manipulation. adjSp :: Int -> G JStat adjSp 0 = return mempty adjSp n = do + -- grow depth by n modifyStackDepth (+n) return (adjSp' n) +-- | Shrink the stack and stack pointer. NB: This function is unsafe when the +-- input 'n', is negative. This function wraps around 'adjSpN' which actually +-- performs the work. adjSpN :: Int -> G JStat adjSpN 0 = return mempty adjSpN n = do modifyStackDepth (\x -> x - n) return (adjSpN' n) +-- | A constant array that holds global function symbols which do N pushes onto +-- the stack. For example: +-- @ +-- function h$p1(x1) { +-- ++h$sp; +-- h$stack[(h$sp - 0)] = x1; +-- }; +-- function h$p2(x1, x2) { +-- h$sp += 2; +-- h$stack[(h$sp - 1)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- and so on up to 32. pushN :: Array Int Ident pushN = listArray (1,32) $ map (TxtI . mkFastString . ("h$p"++) . show) [(1::Int)..32] +-- | Convert all function symbols in 'pushN' to global top-level functions. This +-- is a hack which converts the function symbols to variables. This hack is +-- caught in 'GHC.StgToJS.Printer.prettyBlock'' to turn these into global +-- functions. pushN' :: Array Int JExpr pushN' = fmap (ValExpr . JVar) pushN + where +-- | Partial Push functions. Like 'pushN' except these push functions skip +-- slots. For example, +-- @ +-- function h$pp33(x1, x2) { +-- h$sp += 6; +-- h$stack[(h$sp - 5)] = x1; +-- h$stack[(h$sp - 0)] = x2; +-- }; +-- @ +-- +-- The 33rd entry skips slots 1-4 to bind the top of the stack and the 6th +-- slot. See 'pushOptimized' and 'pushOptimized'' for use cases. pushNN :: Array Integer Ident pushNN = listArray (1,255) $ map (TxtI . mkFastString . ("h$pp"++) . show) [(1::Int)..255] +-- | Like 'pushN'' but for the partial push functions pushNN' :: Array Integer JExpr pushNN' = fmap (ValExpr . JVar) pushNN @@ -216,82 +282,67 @@ pushOptimized xs = do offset i | i == l = sp | otherwise = InfixExpr SubOp sp (toJExpr (l - i)) +-- | push a let-no-escape frame onto the stack pushLneFrame :: HasDebugCallStack => Int -> ExprCtx -> G JStat pushLneFrame size ctx = let ctx' = ctxLneShrinkStack ctx size in pushOptimized' (ctxLneFrameVars ctx') -popUnknown :: [JExpr] -> G JStat -popUnknown xs = popSkipUnknown 0 xs - -popSkipUnknown :: Int -> [JExpr] -> G JStat -popSkipUnknown n xs = popSkip n (map (,SlotUnknown) xs) - -pop :: [(JExpr,StackSlot)] -> G JStat -pop = popSkip 0 - --- | pop the expressions, but ignore the top n elements of the stack -popSkip :: Int -> [(JExpr,StackSlot)] -> G JStat -popSkip 0 [] = pure mempty -popSkip n [] = addUnknownSlots n >> adjSpN n -popSkip n xs = do - addUnknownSlots n - addSlots (map snd xs) - a <- adjSpN (length xs + n) - return (loadSkip n (map fst xs) <> a) - --- | pop things, don't upstate stack knowledge -popSkip' :: Int -- ^ number of slots to skip +-- | Pop things, don't update the stack knowledge in 'G' +popSkip :: Int -- ^ number of slots to skip -> [JExpr] -- ^ assign stack slot values to these -> JStat -popSkip' 0 [] = mempty -popSkip' n [] = adjSpN' n -popSkip' n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) +popSkip 0 [] = mempty +popSkip n [] = adjSpN' n +popSkip n tgt = loadSkip n tgt <> adjSpN' (length tgt + n) --- | like popSkip, but without modifying the stack pointer +-- | Load 'length (xs :: [JExpr])' things from the stack at offset 'n :: Int'. +-- This function does no stack pointer manipulation, it merely indexes into the +-- stack and loads payloads into 'xs'. loadSkip :: Int -> [JExpr] -> JStat loadSkip = loadSkipFrom sp - -loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat -loadSkipFrom fr n xs = mconcat items - where - items = reverse $ zipWith (\i ex -> ex |= IdxExpr stack (toJExpr (offset (i+n)))) - [(0::Int)..] - (reverse xs) - offset 0 = toJExpr fr - offset n = InfixExpr SubOp (toJExpr fr) (toJExpr n) - - --- declare and pop + where + loadSkipFrom :: JExpr -> Int -> [JExpr] -> JStat + loadSkipFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + -- helper to generate sp - n offset to index with + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + -- helper to load stack .! i into ex, e.g., ex = stack[i] + f i ex = ex |= IdxExpr stack (toJExpr (offset (i+n))) + + +-- | Pop but preserve the first N slots popSkipI :: Int -> [(Ident,StackSlot)] -> G JStat popSkipI 0 [] = pure mempty -popSkipI n [] = adjSpN n +popSkipI n [] = popN n popSkipI n xs = do + -- add N unknown slots addUnknownSlots n + -- now add the slots from xs, after this line the stack should look like + -- [xs] ++ [Unknown...] ++ old_stack addSlots (map snd xs) + -- move stack pointer into the stack by (length xs + n), basically resetting + -- the stack pointer a <- adjSpN (length xs + n) + -- now load skipping first N slots return (loadSkipI n (map fst xs) <> a) --- like popSkip, but without modifying sp +-- | Just like 'loadSkip' but operate on 'Ident's rather than 'JExpr' loadSkipI :: Int -> [Ident] -> JStat loadSkipI = loadSkipIFrom sp - -loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat -loadSkipIFrom fr n xs = mconcat items - where - items = reverse $ zipWith f [(0::Int)..] (reverse xs) - offset 0 = fr - offset n = InfixExpr SubOp fr (toJExpr n) - f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) - -popn :: Int -> G JStat -popn n = addUnknownSlots n >> adjSpN n - -updateThunk' :: StgToJSConfig -> JStat -updateThunk' settings = - if csInlineBlackhole settings - then bhStats settings True - else ApplStat (var "h$bh") [] + where loadSkipIFrom :: JExpr -> Int -> [Ident] -> JStat + loadSkipIFrom fr n xs = mconcat items + where + items = reverse $ zipWith f [(0::Int)..] (reverse xs) + offset 0 = fr + offset n = InfixExpr SubOp fr (toJExpr n) + f i ex = ex ||= IdxExpr stack (toJExpr (offset (i+n))) + +-- | Blindly pop N slots +popN :: Int -> G JStat +popN n = addUnknownSlots n >> adjSpN n -- | Generate statements to update the current node with a blackhole bhStats :: StgToJSConfig -> Bool -> JStat @@ -302,8 +353,23 @@ bhStats s pushUpd = mconcat , toJExpr R1 .^ closureField2_ |= null_ -- will be filled with waiters array ] +-- | Wrapper around 'updateThunk'', performs the stack manipulation before +-- updating the Thunk. updateThunk :: G JStat updateThunk = do settings <- getSettings - adjPushStack 2 -- update frame size + -- update frame size + let adjPushStack :: Int -> G () + adjPushStack n = do modifyStackDepth (+n) + dropSlots n + adjPushStack 2 return $ (updateThunk' settings) + +-- | Update a thunk by checking 'StgToJSConfig'. If the config inlines black +-- holes then update inline, else make an explicit call to the black hole +-- handler. +updateThunk' :: StgToJSConfig -> JStat +updateThunk' settings = + if csInlineBlackhole settings + then bhStats settings True + else ApplStat (var "h$bh") [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/498a188253026c5d510ef2adb24aeb63e532e1ae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/498a188253026c5d510ef2adb24aeb63e532e1ae You're receiving 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 Sep 30 12:36:29 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 30 Sep 2022 08:36:29 -0400 Subject: [Git][ghc/ghc][wip/T21754] 12 commits: Apply some tricks to speed up core lint. Message-ID: <6336e2cd18c7_2c975742bcfe2011434db@gitlab.mail> Sebastian Graf pushed to branch wip/T21754 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - b72b5347 by Sebastian Graf at 2022-09-30T14:36:20+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. - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - + compiler/GHC/Data/Unboxed.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3bf718f71ec57e09e20a93344c8e04ebdc49eb34...b72b53472f84f0111ef70aaa49412473c6637f30 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3bf718f71ec57e09e20a93344c8e04ebdc49eb34...b72b53472f84f0111ef70aaa49412473c6637f30 You're receiving 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 Sep 30 12:56:41 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Fri, 30 Sep 2022 08:56:41 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Minor cleanup in compactor Message-ID: <6336e78926d24_2c97575140011522d9@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 7866b112 by Sylvain Henry at 2022-09-30T14:59:47+02:00 Minor cleanup in compactor - - - - - dde60479 by Sylvain Henry at 2022-09-30T14:59:47+02:00 Fix encoding of unboxed strings (don't pass through FastString/h$str) - - - - - 1 changed file: - compiler/GHC/StgToJS/Linker/Compactor.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Compactor.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -152,21 +153,25 @@ staticInitStat _prof (StaticInfo i sv cc) = -- | declare and do first-pass init of a global object (create JS object for heap objects) staticDeclStat :: StaticInfo -> JStat -staticDeclStat (StaticInfo si sv _) = - let si' = TxtI si - ssv (StaticUnboxed u) = Just (ssu u) - ssv (StaticThunk Nothing) = Nothing - ssv _ = Just (app "h$d" []) - ssu (StaticUnboxedBool b) = app "h$p" [toJExpr b] - ssu (StaticUnboxedInt i) = app "h$p" [toJExpr i] - ssu (StaticUnboxedDouble d) = app "h$p" [toJExpr (unSaneDouble d)] - ssu (StaticUnboxedString str) = ApplExpr (initStr str) [] - ssu StaticUnboxedStringOffset {} = 0 - in maybe (appS "h$di" [toJExpr si']) (\v -> DeclStat si' `mappend` (toJExpr si' |= v)) (ssv sv) - --- | JS expression corresponding to a static string -initStr :: BS.ByteString -> JExpr -initStr str = app "h$str" [ValExpr (JStr . mkFastStringByteString $! str)] +staticDeclStat (StaticInfo global_name static_value _) = decl + where + global_ident = TxtI global_name + decl_init v = DeclStat global_ident `mappend` (toJExpr global_ident |= v) + decl_no_init = appS "h$di" [toJExpr global_ident] + + decl = case static_value of + StaticUnboxed u -> decl_init (unboxed_expr u) + StaticThunk Nothing -> decl_no_init -- CAF initialized in an alternative way + _ -> decl_init (app "h$d" []) + + unboxed_expr = \case + StaticUnboxedBool b -> app "h$p" [toJExpr b] + StaticUnboxedInt i -> app "h$p" [toJExpr i] + StaticUnboxedDouble d -> app "h$p" [toJExpr (unSaneDouble d)] + StaticUnboxedString str -> app "h$rawStringData" [ValExpr (to_byte_list str)] + StaticUnboxedStringOffset {} -> 0 + + to_byte_list = JList . map (Int . fromIntegral) . BS.unpack -- | rename a heap object, which means adding it to the -- static init table in addition to the renamer @@ -240,20 +245,6 @@ staticIdentsA :: (FastString -> FastString) -> StaticArg -> StaticArg staticIdentsA f (StaticObjArg t) = StaticObjArg $! f t staticIdentsA _ x = x - -{- | - The Base data structure contains the information we need - to do incremental linking against a base bundle. - - base file format: - GHCJSBASE - [renamer state] - [linkedPackages] - [packages] - [modules] - [symbols] - -} - staticInfoArgs :: Applicative f => (StaticArg -> f StaticArg) -> StaticInfo -> f StaticInfo staticInfoArgs f (StaticInfo si sv sa) = StaticInfo si <$> staticValArgs f sv <*> pure sa View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/498a188253026c5d510ef2adb24aeb63e532e1ae...dde604795a1f09b28eb50f3c52b71d41fc618a9b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/498a188253026c5d510ef2adb24aeb63e532e1ae...dde604795a1f09b28eb50f3c52b71d41fc618a9b You're receiving 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 Sep 30 13:17:39 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Fri, 30 Sep 2022 09:17:39 -0400 Subject: [Git][ghc/ghc][wip/js-staging] StgToJS: comments on static args and optimizeFree Message-ID: <6336ec7312562_2c975742bcfe20115446c@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: bed7d64a by doyougnu at 2022-09-30T09:17:28-04:00 StgToJS: comments on static args and optimizeFree - - - - - 2 changed files: - compiler/GHC/StgToJS/Expr.hs - compiler/GHC/StgToJS/Types.hs Changes: ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -494,7 +494,14 @@ genStaticRefs lv -- | Reorder the things we need to push to reuse existing stack values as much -- as possible True if already on the stack at that location -optimizeFree :: HasDebugCallStack => Int -> [Id] -> G [(Id,Int,Bool)] +optimizeFree + :: HasDebugCallStack + => Int + -> [Id] + -> G [(Id,Int,Bool)] -- ^ A list of stack slots. + -- -- Id: stored on the slot + -- -- Int: the part of the value that is stored + -- -- Bool: True when the slot already contains a value optimizeFree offset ids = do -- this line goes wrong vvvvvvv let -- ids' = concat $ map (\i -> map (i,) [1..varSize . uTypeVt . idType $ i]) ids ===================================== compiler/GHC/StgToJS/Types.hs ===================================== @@ -254,7 +254,9 @@ data StaticUnboxed instance NFData StaticUnboxed --- | Static Arguments +-- | Static Arguments. Static Arguments are things that are statically +-- allocated, i.e., they exist at program startup. These are static heap objects +-- or literals or things that have been floated to the top level binding by ghc. data StaticArg = StaticObjArg !FastString -- ^ reference to a heap object | StaticLitArg !StaticLit -- ^ literal View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bed7d64a1572c4cd677e72fb016be50404098b86 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bed7d64a1572c4cd677e72fb016be50404098b86 You're receiving 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 Sep 30 15:19:17 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 30 Sep 2022 11:19:17 -0400 Subject: [Git][ghc/ghc][wip/T21754] Boxity: Don't update Boxity unless worker/wrapper follows (#21754) Message-ID: <633708f588b54_2c975742bcfe20117129d@gitlab.mail> Sebastian Graf pushed to branch wip/T21754 at Glasgow Haskell Compiler / GHC Commits: 90a260d3 by Sebastian Graf at 2022-09-30T17:19:02+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. - - - - - 10 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/simplCore/should_compile/spec-inline.stderr - + testsuite/tests/stranal/sigs/T21754.hs - + testsuite/tests/stranal/sigs/T21754.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -59,9 +59,18 @@ _ = pprTrace -- Tired of commenting out the import all the time -- | Options for the demand analysis data DmdAnalOpts = DmdAnalOpts - { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries - , dmd_unbox_width :: !Int -- ^ Use strict dictionaries + { dmd_strict_dicts :: !Bool + -- ^ Value of `-fdicts-strict` (on by default). + -- When set, all functons are implicitly strict in dictionary args. + , dmd_do_boxity :: !Bool + -- ^ Governs whether the analysis should update boxity signatures. + -- See Note [Don't change boxity without worker/wrapper]. + , dmd_unbox_width :: !Int + -- ^ Value of `-fdmd-unbox-width`. + -- See Note [Unboxed demand on function bodies returning small products] , dmd_max_worker_args :: !Int + -- ^ Value of `-fmax-worker-args`. + -- Don't unbox anything if we end up with more than this many args. } -- This is a strict alternative to (,) @@ -146,6 +155,40 @@ unforced thunks in demand or strictness information; and it is the most memory-intensive part of the compilation process, so this added seqBinds makes a big difference in peak memory usage. +Note [Don't change boxity without worker/wrapper] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (T21754) + f n = n+1 + {-# NOINLINE f #-} +With `-fno-worker-wrapper`, we should not give `f` a boxity signature that says +that it unboxes its argument! Client modules would never be able to cancel away +the box for n. Likewise we shouldn't give `f` the CPR property. + +Similarly, in the last run of DmdAnal before codegen (which does not have a +worker/wrapper phase) we should not change boxity in any way. Remember: an +earlier result of the demand analyser, complete with worker/wrapper, has aleady +given a demand signature (with boxity info) to the function. +(The "last run" is mainly there to attach demanded-once info to let-bindings.) + +In general, we should not run Note [Boxity analysis] unless worker/wrapper +follows to exploit the boxity and make sure that calling modules can observe the +reported boxity. + +Hence DmdAnal is configured by a flag `dmd_do_boxity` that is True only +if worker/wrapper follows after DmdAnal. If it is not set, and the signature +is not subject to Note [Boxity for bottoming functions], DmdAnal tries +to transfer over the previous boxity to the new demand signature, in +`setIdDmdAndBoxSig`. + +Why isn't CprAnal configured with a similar flag? Because if we aren't going to +do worker/wrapper we don't run CPR analysis at all. (see GHC.Core.Opt.Pipeline) + +It might be surprising that we only try to preserve *arg* boxity, not boxity on +FVs. But FV demands won't make it into interface files anyway, so it's a waste +of energy. +Besides, W/W zaps the `DmdEnv` portion of a signature, so we don't know the old +boxity to begin with; see Note [Zapping DmdEnv after Demand Analyzer]. + Note [Analysing top-level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a CoreProgram like @@ -257,6 +300,16 @@ setBindIdDemandInfo top_lvl id dmd = setIdDemandInfo id $ case top_lvl of TopLevel | not (isInterestingTopLevelFn id) -> topDmd _ -> dmd +-- | Update the demand signature, but be careful not to change boxity info if +-- `dmd_do_boxity` is True or if the signature is bottom. +-- See Note [Don't change boxity without worker/wrapper] +-- and Note [Boxity for bottoming functions]. +setIdDmdAndBoxSig :: DmdAnalOpts -> Id -> DmdSig -> Id +setIdDmdAndBoxSig opts id sig = setIdDmdSig id $ + if dmd_do_boxity opts || isBottomingSig sig + then sig + else transferArgBoxityDmdSig (idDmdSig id) sig + -- | Let bindings can be processed in two ways: -- Down (RHS before body) or Up (body before RHS). -- This function handles the up variant. @@ -1018,7 +1071,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) - final_id = id `setIdDmdSig` sig + opts = ae_opts env + final_id = setIdDmdAndBoxSig opts id sig !final_env = extendAnalEnv top_lvl env final_id sig -- See Note [Aggregated demand for cardinality] @@ -1858,8 +1912,9 @@ dmdFix :: TopLevelFlag dmdFix top_lvl env let_dmd orig_pairs = loop 1 initial_pairs where + opts = ae_opts env -- See Note [Initialising strictness] - initial_pairs | ae_virgin env = [(setIdDmdSig id botSig, rhs) | (id, rhs) <- orig_pairs ] + initial_pairs | ae_virgin env = [(setIdDmdAndBoxSig opts id botSig, rhs) | (id, rhs) <- orig_pairs ] | otherwise = orig_pairs -- If fixed-point iteration does not yield a result we use this instead ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -150,7 +150,7 @@ getCoreToDo dflags rule_base extra_vars maybe_rule_check phase = runMaybe rule_check (CoreDoRuleCheck phase) maybe_strictness_before (Phase phase) - | phase `elem` strictnessBefore dflags = CoreDoDemand + | phase `elem` strictnessBefore dflags = CoreDoDemand False maybe_strictness_before _ = CoreDoNothing @@ -171,8 +171,8 @@ getCoreToDo dflags rule_base extra_vars simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter (initGentleSimplMode dflags) rule_base - dmd_cpr_ww = if ww_on then [CoreDoDemand,CoreDoCpr,CoreDoWorkerWrapper] - else [CoreDoDemand,CoreDoCpr] + dmd_cpr_ww = if ww_on then [CoreDoDemand True,CoreDoCpr,CoreDoWorkerWrapper] + else [CoreDoDemand False] -- NB: No CPR! See Note [Don't change boxity without worker/wrapper] demand_analyser = (CoreDoPasses ( @@ -340,7 +340,7 @@ getCoreToDo dflags rule_base extra_vars -- has run at all. See Note [Final Demand Analyser run] in GHC.Core.Opt.DmdAnal -- It is EXTREMELY IMPORTANT to run this pass, otherwise execution -- can become /exponentially/ more expensive. See #11731, #12996. - runWhen (strictness || late_dmd_anal) CoreDoDemand, + runWhen (strictness || late_dmd_anal) (CoreDoDemand False), maybe_rule_check FinalPhase, @@ -491,8 +491,8 @@ doCorePass pass guts = do CoreDoExitify -> {-# SCC "Exitify" #-} updateBinds exitifyProgram - CoreDoDemand -> {-# SCC "DmdAnal" #-} - updateBindsM (liftIO . dmdAnal logger dflags fam_envs (mg_rules guts)) + CoreDoDemand before_ww -> {-# SCC "DmdAnal" #-} + updateBindsM (liftIO . dmdAnal logger before_ww dflags fam_envs (mg_rules guts)) CoreDoCpr -> {-# SCC "CprAnal" #-} updateBindsM (liftIO . cprAnalProgram logger fam_envs) @@ -557,10 +557,11 @@ ruleCheckPass current_phase pat guts = do rule_fn (mg_binds guts)) return guts -dmdAnal :: Logger -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram -dmdAnal logger dflags fam_envs rules binds = do +dmdAnal :: Logger -> Bool -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram +dmdAnal logger before_ww dflags fam_envs rules binds = do let !opts = DmdAnalOpts { dmd_strict_dicts = gopt Opt_DictsStrict dflags + , dmd_do_boxity = before_ww -- only run Boxity Analysis immediately preceding WW , dmd_unbox_width = dmdUnboxWidth dflags , dmd_max_worker_args = maxWorkerArgs dflags } ===================================== compiler/GHC/Core/Opt/Pipeline/Types.hs ===================================== @@ -45,7 +45,8 @@ data CoreToDo -- These are diff core-to-core passes, | CoreDoStaticArgs | CoreDoCallArity | CoreDoExitify - | CoreDoDemand + | CoreDoDemand Bool -- Bool: Do worker/wrapper afterwards? + -- See Note [Don't change boxity without worker/wrapper] | CoreDoCpr | CoreDoWorkerWrapper | CoreDoSpecialising @@ -74,7 +75,8 @@ instance Outputable CoreToDo where ppr CoreDoStaticArgs = text "Static argument" ppr CoreDoCallArity = text "Called arity analysis" ppr CoreDoExitify = text "Exitification transformation" - ppr CoreDoDemand = text "Demand analysis" + ppr (CoreDoDemand True) = text "Demand analysis (including Boxity)" + ppr (CoreDoDemand False) = text "Demand analysis" ppr CoreDoCpr = text "Constructed Product Result analysis" ppr CoreDoWorkerWrapper = text "Worker Wrapper binds" ppr CoreDoSpecialising = text "Specialise" ===================================== compiler/GHC/Driver/Config/Core/Lint.hs ===================================== @@ -83,7 +83,7 @@ coreDumpFlag CoreLiberateCase = Just Opt_D_verbose_core2core coreDumpFlag CoreDoStaticArgs = Just Opt_D_verbose_core2core coreDumpFlag CoreDoCallArity = Just Opt_D_dump_call_arity coreDumpFlag CoreDoExitify = Just Opt_D_dump_exitify -coreDumpFlag CoreDoDemand = Just Opt_D_dump_stranal +coreDumpFlag (CoreDoDemand {}) = Just Opt_D_dump_stranal coreDumpFlag CoreDoCpr = Just Opt_D_dump_cpranal coreDumpFlag CoreDoWorkerWrapper = Just Opt_D_dump_worker_wrapper coreDumpFlag CoreDoSpecialising = Just Opt_D_dump_spec ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -64,7 +64,8 @@ module GHC.Types.Demand ( -- * Demand signatures DmdSig(..), mkDmdSigForArity, mkClosedDmdSig, mkVanillaDmdSig, splitDmdSig, dmdSigDmdEnv, hasDemandEnvSig, - nopSig, botSig, isNopSig, isDeadEndSig, isDeadEndAppSig, trimBoxityDmdSig, + nopSig, botSig, isNopSig, isBottomingSig, isDeadEndSig, isDeadEndAppSig, + trimBoxityDmdSig, transferArgBoxityDmdSig, -- ** Handling arity adjustments prependArgsDmdSig, etaConvertDmdSig, @@ -2147,6 +2148,13 @@ isNopSig (DmdSig ty) = isNopDmdType ty isDeadEndSig :: DmdSig -> Bool isDeadEndSig (DmdSig (DmdType _ _ res)) = isDeadEndDiv res +-- | True if the signature diverges or throws an imprecise exception in a saturated call. +-- NB: In constrast to 'isDeadEndSig' this returns False for 'exnDiv'. +-- See Note [Dead ends] +-- and Note [Precise vs imprecise exceptions]. +isBottomingSig :: DmdSig -> Bool +isBottomingSig (DmdSig (DmdType _ _ res)) = res == botDiv + -- | True when the signature indicates all arguments are boxed onlyBoxedArguments :: DmdSig -> Bool onlyBoxedArguments (DmdSig (DmdType _ dmds _)) = all demandIsBoxed dmds @@ -2179,6 +2187,38 @@ trimBoxityDmdType (DmdType fvs ds res) = trimBoxityDmdSig :: DmdSig -> DmdSig trimBoxityDmdSig = coerce trimBoxityDmdType +-- | Transfers the boxity of the left arg to the demand structure of the right +-- arg. This only makes sense if applied to new and old demands of the same +-- value. +transferBoxity :: Demand -> Demand -> Demand +transferBoxity from to = go_dmd from to + where + go_dmd (from_n :* from_sd) to_dmd@(to_n :* to_sd) + | isAbs from_n || isAbs to_n = to_dmd + | otherwise = case (from_sd, to_sd) of + (Poly from_b _, Poly _ to_c) -> + to_n :* Poly from_b to_c + (_, Prod _ to_ds) + | Just (from_b, from_ds) <- viewProd (length to_ds) from_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + (Prod from_b from_ds, _) + | Just (_, to_ds) <- viewProd (length from_ds) to_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + _ -> trimBoxity to_dmd + +transferArgBoxityDmdType :: DmdType -> DmdType -> DmdType +transferArgBoxityDmdType _from@(DmdType _ from_ds _) to@(DmdType to_fvs to_ds to_res) + | equalLength from_ds to_ds + = -- pprTraceWith "transfer" (\r -> ppr _from $$ ppr to $$ ppr r) $ + DmdType to_fvs -- Only arg boxity! See Note [Don't change boxity without worker/wrapper] + (zipWith transferBoxity from_ds to_ds) + to_res + | otherwise + = trimBoxityDmdType to + +transferArgBoxityDmdSig :: DmdSig -> DmdSig -> DmdSig +transferArgBoxityDmdSig = coerce transferArgBoxityDmdType + prependArgsDmdSig :: Int -> DmdSig -> DmdSig -- ^ Add extra ('topDmd') arguments to a strictness signature. -- In contrast to 'etaConvertDmdSig', this /prepends/ additional argument ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -143,7 +143,7 @@ Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 foo :: Int -> Int [GblId, Arity=1, - Str=<1!P(L)>, + Str=<1L>, Cpr=1, Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/stranal/sigs/T21754.hs ===================================== @@ -0,0 +1,7 @@ +{-# OPTIONS_GHC -fno-worker-wrapper #-} + +module Test where + +f :: Int -> Int +f n = n+1 +{-# NOINLINE f #-} ===================================== testsuite/tests/stranal/sigs/T21754.stderr ===================================== @@ -0,0 +1,10 @@ + +==================== Strictness signatures ==================== +Test.f: <1L> + + + +==================== Strictness signatures ==================== +Test.f: <1L> + + ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -14,7 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.f: +T5075.f: T5075.g: <1L> T5075.h: <1!P(L)> ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -34,5 +34,6 @@ test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) test('T21717', normal, compile, ['']) +test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90a260d35e3d6da8e4542d201d4df182fc104fa5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90a260d35e3d6da8e4542d201d4df182fc104fa5 You're receiving 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 Sep 30 15:29:15 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 30 Sep 2022 11:29:15 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix boot_hc Message-ID: <63370b4b5ee9a_2c975742cc316011717c5@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 7de361f2 by Matthew Pickering at 2022-09-30T16:29:05+01:00 fix boot_hc - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -391,6 +391,7 @@ hadrian-multi: tags: - x86_64-linux script: + - export BOOT_HC=$GHC - root=$(pwd)/ghc - ls - | @@ -407,7 +408,7 @@ hadrian-multi: - .gitlab/ci.sh setup - .gitlab/ci.sh configure # Now GHC means, use this GHC for hadrian - - unset GHC + - export GHC=$BOOT_HC # Load hadrian-multi then immediately exit and check the modules loaded - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," after_script: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7de361f29fbfeb94d3f284406e5a63546edc5609 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7de361f29fbfeb94d3f284406e5a63546edc5609 You're receiving 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 Sep 30 16:42:24 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 30 Sep 2022 12:42:24 -0400 Subject: [Git][ghc/ghc][wip/T21754] Boxity: Don't update Boxity unless worker/wrapper follows (#21754) Message-ID: <63371c7098595_2c975742bcfe7011942dc@gitlab.mail> Sebastian Graf pushed to branch wip/T21754 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 9 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/simplCore/should_compile/spec-inline.stderr - + testsuite/tests/stranal/sigs/T21754.hs - + testsuite/tests/stranal/sigs/T21754.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -59,9 +59,18 @@ _ = pprTrace -- Tired of commenting out the import all the time -- | Options for the demand analysis data DmdAnalOpts = DmdAnalOpts - { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries - , dmd_unbox_width :: !Int -- ^ Use strict dictionaries + { dmd_strict_dicts :: !Bool + -- ^ Value of `-fdicts-strict` (on by default). + -- When set, all functons are implicitly strict in dictionary args. + , dmd_do_boxity :: !Bool + -- ^ Governs whether the analysis should update boxity signatures. + -- See Note [Don't change boxity without worker/wrapper]. + , dmd_unbox_width :: !Int + -- ^ Value of `-fdmd-unbox-width`. + -- See Note [Unboxed demand on function bodies returning small products] , dmd_max_worker_args :: !Int + -- ^ Value of `-fmax-worker-args`. + -- Don't unbox anything if we end up with more than this many args. } -- This is a strict alternative to (,) @@ -146,6 +155,40 @@ unforced thunks in demand or strictness information; and it is the most memory-intensive part of the compilation process, so this added seqBinds makes a big difference in peak memory usage. +Note [Don't change boxity without worker/wrapper] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (T21754) + f n = n+1 + {-# NOINLINE f #-} +With `-fno-worker-wrapper`, we should not give `f` a boxity signature that says +that it unboxes its argument! Client modules would never be able to cancel away +the box for n. Likewise we shouldn't give `f` the CPR property. + +Similarly, in the last run of DmdAnal before codegen (which does not have a +worker/wrapper phase) we should not change boxity in any way. Remember: an +earlier result of the demand analyser, complete with worker/wrapper, has aleady +given a demand signature (with boxity info) to the function. +(The "last run" is mainly there to attach demanded-once info to let-bindings.) + +In general, we should not run Note [Boxity analysis] unless worker/wrapper +follows to exploit the boxity and make sure that calling modules can observe the +reported boxity. + +Hence DmdAnal is configured by a flag `dmd_do_boxity` that is True only +if worker/wrapper follows after DmdAnal. If it is not set, and the signature +is not subject to Note [Boxity for bottoming functions], DmdAnal tries +to transfer over the previous boxity to the new demand signature, in +`setIdDmdAndBoxSig`. + +Why isn't CprAnal configured with a similar flag? Because if we aren't going to +do worker/wrapper we don't run CPR analysis at all. (see GHC.Core.Opt.Pipeline) + +It might be surprising that we only try to preserve *arg* boxity, not boxity on +FVs. But FV demands won't make it into interface files anyway, so it's a waste +of energy. +Besides, W/W zaps the `DmdEnv` portion of a signature, so we don't know the old +boxity to begin with; see Note [Zapping DmdEnv after Demand Analyzer]. + Note [Analysing top-level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a CoreProgram like @@ -257,6 +300,16 @@ setBindIdDemandInfo top_lvl id dmd = setIdDemandInfo id $ case top_lvl of TopLevel | not (isInterestingTopLevelFn id) -> topDmd _ -> dmd +-- | Update the demand signature, but be careful not to change boxity info if +-- `dmd_do_boxity` is True or if the signature is bottom. +-- See Note [Don't change boxity without worker/wrapper] +-- and Note [Boxity for bottoming functions]. +setIdDmdAndBoxSig :: DmdAnalOpts -> Id -> DmdSig -> Id +setIdDmdAndBoxSig opts id sig = setIdDmdSig id $ + if dmd_do_boxity opts || isBottomingSig sig + then sig + else transferArgBoxityDmdSig (idDmdSig id) sig + -- | Let bindings can be processed in two ways: -- Down (RHS before body) or Up (body before RHS). -- This function handles the up variant. @@ -1018,7 +1071,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) - final_id = id `setIdDmdSig` sig + opts = ae_opts env + final_id = setIdDmdAndBoxSig opts id sig !final_env = extendAnalEnv top_lvl env final_id sig -- See Note [Aggregated demand for cardinality] @@ -1858,8 +1912,9 @@ dmdFix :: TopLevelFlag dmdFix top_lvl env let_dmd orig_pairs = loop 1 initial_pairs where + opts = ae_opts env -- See Note [Initialising strictness] - initial_pairs | ae_virgin env = [(setIdDmdSig id botSig, rhs) | (id, rhs) <- orig_pairs ] + initial_pairs | ae_virgin env = [(setIdDmdAndBoxSig opts id botSig, rhs) | (id, rhs) <- orig_pairs ] | otherwise = orig_pairs -- If fixed-point iteration does not yield a result we use this instead ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -150,7 +150,7 @@ getCoreToDo dflags rule_base extra_vars maybe_rule_check phase = runMaybe rule_check (CoreDoRuleCheck phase) maybe_strictness_before (Phase phase) - | phase `elem` strictnessBefore dflags = CoreDoDemand + | phase `elem` strictnessBefore dflags = CoreDoDemand False maybe_strictness_before _ = CoreDoNothing @@ -171,8 +171,8 @@ getCoreToDo dflags rule_base extra_vars simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter (initGentleSimplMode dflags) rule_base - dmd_cpr_ww = if ww_on then [CoreDoDemand,CoreDoCpr,CoreDoWorkerWrapper] - else [CoreDoDemand,CoreDoCpr] + dmd_cpr_ww = if ww_on then [CoreDoDemand True,CoreDoCpr,CoreDoWorkerWrapper] + else [CoreDoDemand False] -- NB: No CPR! See Note [Don't change boxity without worker/wrapper] demand_analyser = (CoreDoPasses ( @@ -340,7 +340,7 @@ getCoreToDo dflags rule_base extra_vars -- has run at all. See Note [Final Demand Analyser run] in GHC.Core.Opt.DmdAnal -- It is EXTREMELY IMPORTANT to run this pass, otherwise execution -- can become /exponentially/ more expensive. See #11731, #12996. - runWhen (strictness || late_dmd_anal) CoreDoDemand, + runWhen (strictness || late_dmd_anal) (CoreDoDemand False), maybe_rule_check FinalPhase, @@ -491,8 +491,8 @@ doCorePass pass guts = do CoreDoExitify -> {-# SCC "Exitify" #-} updateBinds exitifyProgram - CoreDoDemand -> {-# SCC "DmdAnal" #-} - updateBindsM (liftIO . dmdAnal logger dflags fam_envs (mg_rules guts)) + CoreDoDemand before_ww -> {-# SCC "DmdAnal" #-} + updateBindsM (liftIO . dmdAnal logger before_ww dflags fam_envs (mg_rules guts)) CoreDoCpr -> {-# SCC "CprAnal" #-} updateBindsM (liftIO . cprAnalProgram logger fam_envs) @@ -557,10 +557,11 @@ ruleCheckPass current_phase pat guts = do rule_fn (mg_binds guts)) return guts -dmdAnal :: Logger -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram -dmdAnal logger dflags fam_envs rules binds = do +dmdAnal :: Logger -> Bool -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram +dmdAnal logger before_ww dflags fam_envs rules binds = do let !opts = DmdAnalOpts { dmd_strict_dicts = gopt Opt_DictsStrict dflags + , dmd_do_boxity = before_ww -- only run Boxity Analysis immediately preceding WW , dmd_unbox_width = dmdUnboxWidth dflags , dmd_max_worker_args = maxWorkerArgs dflags } ===================================== compiler/GHC/Core/Opt/Pipeline/Types.hs ===================================== @@ -45,7 +45,8 @@ data CoreToDo -- These are diff core-to-core passes, | CoreDoStaticArgs | CoreDoCallArity | CoreDoExitify - | CoreDoDemand + | CoreDoDemand Bool -- Bool: Do worker/wrapper afterwards? + -- See Note [Don't change boxity without worker/wrapper] | CoreDoCpr | CoreDoWorkerWrapper | CoreDoSpecialising @@ -74,7 +75,8 @@ instance Outputable CoreToDo where ppr CoreDoStaticArgs = text "Static argument" ppr CoreDoCallArity = text "Called arity analysis" ppr CoreDoExitify = text "Exitification transformation" - ppr CoreDoDemand = text "Demand analysis" + ppr (CoreDoDemand True) = text "Demand analysis (including Boxity)" + ppr (CoreDoDemand False) = text "Demand analysis" ppr CoreDoCpr = text "Constructed Product Result analysis" ppr CoreDoWorkerWrapper = text "Worker Wrapper binds" ppr CoreDoSpecialising = text "Specialise" ===================================== compiler/GHC/Driver/Config/Core/Lint.hs ===================================== @@ -83,7 +83,7 @@ coreDumpFlag CoreLiberateCase = Just Opt_D_verbose_core2core coreDumpFlag CoreDoStaticArgs = Just Opt_D_verbose_core2core coreDumpFlag CoreDoCallArity = Just Opt_D_dump_call_arity coreDumpFlag CoreDoExitify = Just Opt_D_dump_exitify -coreDumpFlag CoreDoDemand = Just Opt_D_dump_stranal +coreDumpFlag (CoreDoDemand {}) = Just Opt_D_dump_stranal coreDumpFlag CoreDoCpr = Just Opt_D_dump_cpranal coreDumpFlag CoreDoWorkerWrapper = Just Opt_D_dump_worker_wrapper coreDumpFlag CoreDoSpecialising = Just Opt_D_dump_spec ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -64,7 +64,8 @@ module GHC.Types.Demand ( -- * Demand signatures DmdSig(..), mkDmdSigForArity, mkClosedDmdSig, mkVanillaDmdSig, splitDmdSig, dmdSigDmdEnv, hasDemandEnvSig, - nopSig, botSig, isNopSig, isDeadEndSig, isDeadEndAppSig, trimBoxityDmdSig, + nopSig, botSig, isNopSig, isBottomingSig, isDeadEndSig, isDeadEndAppSig, + trimBoxityDmdSig, transferArgBoxityDmdSig, -- ** Handling arity adjustments prependArgsDmdSig, etaConvertDmdSig, @@ -2147,6 +2148,13 @@ isNopSig (DmdSig ty) = isNopDmdType ty isDeadEndSig :: DmdSig -> Bool isDeadEndSig (DmdSig (DmdType _ _ res)) = isDeadEndDiv res +-- | True if the signature diverges or throws an imprecise exception in a saturated call. +-- NB: In constrast to 'isDeadEndSig' this returns False for 'exnDiv'. +-- See Note [Dead ends] +-- and Note [Precise vs imprecise exceptions]. +isBottomingSig :: DmdSig -> Bool +isBottomingSig (DmdSig (DmdType _ _ res)) = res == botDiv + -- | True when the signature indicates all arguments are boxed onlyBoxedArguments :: DmdSig -> Bool onlyBoxedArguments (DmdSig (DmdType _ dmds _)) = all demandIsBoxed dmds @@ -2179,6 +2187,38 @@ trimBoxityDmdType (DmdType fvs ds res) = trimBoxityDmdSig :: DmdSig -> DmdSig trimBoxityDmdSig = coerce trimBoxityDmdType +-- | Transfers the boxity of the left arg to the demand structure of the right +-- arg. This only makes sense if applied to new and old demands of the same +-- value. +transferBoxity :: Demand -> Demand -> Demand +transferBoxity from to = go_dmd from to + where + go_dmd (from_n :* from_sd) to_dmd@(to_n :* to_sd) + | isAbs from_n || isAbs to_n = to_dmd + | otherwise = case (from_sd, to_sd) of + (Poly from_b _, Poly _ to_c) -> + to_n :* Poly from_b to_c + (_, Prod _ to_ds) + | Just (from_b, from_ds) <- viewProd (length to_ds) from_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + (Prod from_b from_ds, _) + | Just (_, to_ds) <- viewProd (length from_ds) to_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + _ -> trimBoxity to_dmd + +transferArgBoxityDmdType :: DmdType -> DmdType -> DmdType +transferArgBoxityDmdType _from@(DmdType _ from_ds _) to@(DmdType to_fvs to_ds to_res) + | equalLength from_ds to_ds + = -- pprTraceWith "transfer" (\r -> ppr _from $$ ppr to $$ ppr r) $ + DmdType to_fvs -- Only arg boxity! See Note [Don't change boxity without worker/wrapper] + (zipWith transferBoxity from_ds to_ds) + to_res + | otherwise + = trimBoxityDmdType to + +transferArgBoxityDmdSig :: DmdSig -> DmdSig -> DmdSig +transferArgBoxityDmdSig = coerce transferArgBoxityDmdType + prependArgsDmdSig :: Int -> DmdSig -> DmdSig -- ^ Add extra ('topDmd') arguments to a strictness signature. -- In contrast to 'etaConvertDmdSig', this /prepends/ additional argument ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -143,7 +143,7 @@ Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 foo :: Int -> Int [GblId, Arity=1, - Str=<1!P(L)>, + Str=<1L>, Cpr=1, Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/stranal/sigs/T21754.hs ===================================== @@ -0,0 +1,7 @@ +{-# OPTIONS_GHC -fno-worker-wrapper #-} + +module Test where + +f :: Int -> Int +f n = n+1 +{-# NOINLINE f #-} ===================================== testsuite/tests/stranal/sigs/T21754.stderr ===================================== @@ -0,0 +1,10 @@ + +==================== Strictness signatures ==================== +Test.f: <1L> + + + +==================== Strictness signatures ==================== +Test.f: <1L> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -34,5 +34,6 @@ test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) test('T21717', normal, compile, ['']) +test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5e8f493b015df859833beac5a8e64a0f9b9d4f4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5e8f493b015df859833beac5a8e64a0f9b9d4f4 You're receiving 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 Sep 30 16:46:00 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 30 Sep 2022 12:46:00 -0400 Subject: [Git][ghc/ghc][wip/T22084] 4 commits: Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Message-ID: <63371d481bc6c_2c975742bd2a1c1198318@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22084 at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 9abcc262 by Simon Peyton Jones at 2022-09-30T08:58:30+01: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 arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). It's not a big deal, but it shaves 0.1% off compile times. - - - - - f9a5a739 by Simon Peyton Jones at 2022-09-30T17:47:54+01:00 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.) This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. - - - - - 30 changed files: - .gitlab/ci.sh - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Demand.hs - docs/users_guide/using-optimisation.rst - testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/should_compile/Arity04.stderr - testsuite/tests/arityanal/should_compile/Arity05.stderr - testsuite/tests/arityanal/should_compile/Arity06.stderr - testsuite/tests/arityanal/should_compile/Arity08.stderr - testsuite/tests/arityanal/should_compile/Arity11.stderr - testsuite/tests/arityanal/should_compile/Arity14.stderr - testsuite/tests/arityanal/should_compile/Arity15.stderr - testsuite/tests/arityanal/should_compile/Arity16.stderr - testsuite/tests/determinism/determ004/determ004.hs - testsuite/tests/simplCore/should_compile/OpaqueNoSpecialise.stderr - testsuite/tests/simplCore/should_compile/T13156.hs - testsuite/tests/simplCore/should_compile/T14152.stderr - testsuite/tests/simplCore/should_compile/T14152a.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/87f32247e4beef49e010e5bfc0aa7a12329fd173...f9a5a7394d7d7108b827c50441eb48237f75ffea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/87f32247e4beef49e010e5bfc0aa7a12329fd173...f9a5a7394d7d7108b827c50441eb48237f75ffea You're receiving 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 Sep 30 18:26:56 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 30 Sep 2022 14:26:56 -0400 Subject: [Git][ghc/ghc][wip/fix-multi-repl] fix! Message-ID: <633734f07ba1c_2c975742bd2a1c12050db@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: 3150b008 by Matthew Pickering at 2022-09-30T19:26:48+01:00 fix! - - - - - 1 changed file: - hadrian/ghci-multi-cabal.in Changes: ===================================== hadrian/ghci-multi-cabal.in ===================================== @@ -1,7 +1,7 @@ #!/usr/bin/env sh -GHC=@WithGhc@ -if [[ $(printf "9.4.0\n%s\n" $($GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi +RUN_GHC=@WithGhc@ +if [[ $(printf "9.4.0\n%s\n" $($RUN_GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi # This file is generated by configure from ghci-multi.in @@ -10,4 +10,4 @@ export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args # Replace newlines with spaces, as these otherwise break the ghci invocation on windows. CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')" -$GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m +$RUN_GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3150b008269e038d59049de63caaa74610506605 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3150b008269e038d59049de63caaa74610506605 You're receiving 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 Sep 30 18:55:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 30 Sep 2022 14:55:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Revert "ci: enable parallel compression for xz" Message-ID: <63373ba02b59b_2c975742bcfe5c12087f2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 6b366242 by M Farkas-Dyck at 2022-09-30T14:55:00-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 25 changed files: - .gitlab/ci.sh - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Llvm/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Utils/Misc.hs - testsuite/tests/simplCore/should_compile/spec-inline.stderr - + testsuite/tests/stranal/sigs/T21754.hs - + testsuite/tests/stranal/sigs/T21754.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== .gitlab/ci.sh ===================================== @@ -499,7 +499,7 @@ function build_hadrian() { if [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian build-cabal -V else - XZ_OPT="${XZ_OPT:-} -T$cores" run_hadrian binary-dist -V + run_hadrian binary-dist -V mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" fi ===================================== compiler/GHC/Cmm/Node.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Cmm.Dataflow.Block import GHC.Cmm.Dataflow.Graph import GHC.Cmm.Dataflow.Collections import GHC.Cmm.Dataflow.Label +import Data.Foldable (toList) import Data.Functor.Classes (liftCompare) import Data.Maybe import Data.List (tails,sortBy) @@ -247,7 +248,7 @@ pprNode platform node = pp_node <+> pp_debug (cases, mbdef) = switchTargetsFallThrough ids ppCase (is,l) = hsep [ text "case" - , commafy $ map integer is + , commafy $ toList $ fmap integer is , text ": goto" , ppr l <> semi ] ===================================== compiler/GHC/Cmm/Switch.hs ===================================== @@ -12,7 +12,7 @@ module GHC.Cmm.Switch ( createSwitchPlan, ) where -import GHC.Prelude +import GHC.Prelude hiding (head) import GHC.Utils.Outputable import GHC.Driver.Backend @@ -20,7 +20,7 @@ import GHC.Utils.Panic import GHC.Cmm.Dataflow.Label (Label) import Data.Maybe -import qualified Data.List.NonEmpty as NE +import Data.List.NonEmpty (NonEmpty (..), groupWith, head) import qualified Data.Map as M -- Note [Cmm Switches, the general plan] @@ -200,11 +200,11 @@ switchTargetsToList (SwitchTargets _ _ mbdef branches) -- | Groups cases with equal targets, suitable for pretty-printing to a -- c-like switch statement with fall-through semantics. -switchTargetsFallThrough :: SwitchTargets -> ([([Integer], Label)], Maybe Label) +switchTargetsFallThrough :: SwitchTargets -> ([(NonEmpty Integer, Label)], Maybe Label) switchTargetsFallThrough (SwitchTargets _ _ mbdef branches) = (groups, mbdef) where - groups = map (\xs -> (map fst (NE.toList xs), snd (NE.head xs))) $ - NE.groupWith snd $ + groups = fmap (\xs -> (fmap fst xs, snd (head xs))) $ + groupWith snd $ M.toList branches -- | Custom equality helper, needed for "GHC.Cmm.CommonBlockElim" ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -78,7 +78,7 @@ module GHC.CmmToAsm ) where -import GHC.Prelude +import GHC.Prelude hiding (head) import qualified GHC.CmmToAsm.X86 as X86 import qualified GHC.CmmToAsm.PPC as PPC @@ -140,7 +140,7 @@ import GHC.Data.Stream (Stream) import qualified GHC.Data.Stream as Stream import Data.List (sortBy) -import qualified Data.List.NonEmpty as NE +import Data.List.NonEmpty (groupAllWith, head) import Data.Maybe import Data.Ord ( comparing ) import Control.Monad @@ -776,8 +776,8 @@ makeImportsDoc config imports | needImportedSymbols config = vcat $ (pprGotDeclaration config :) $ - fmap ( pprImportedSymbol config . fst . NE.head) $ - NE.groupAllWith snd $ + fmap (pprImportedSymbol config . fst . head) $ + groupAllWith snd $ map doPpr $ imps | otherwise ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -59,6 +59,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as BS import Data.Char import Data.List (intersperse) +import Data.List.NonEmpty (NonEmpty (..)) import Data.Map (Map) import qualified Data.Map as Map import GHC.Float @@ -347,7 +348,7 @@ pprSwitch platform e ids rep = typeWidth (cmmExprType platform e) -- fall through case - caseify (ix:ixs, ident) = vcat (map do_fallthrough ixs) $$ final_branch ix + caseify (ix:|ixs, ident) = vcat (map do_fallthrough ixs) $$ final_branch ix where do_fallthrough ix = hsep [ text "case" , pprHexVal platform ix rep <> colon , @@ -357,8 +358,6 @@ pprSwitch platform e ids hsep [ text "case" , pprHexVal platform ix rep <> colon , text "goto" , (pprBlockId ident) <> semi ] - caseify (_ , _ ) = panic "pprSwitch: switch with no cases!" - def | Just l <- mbdef = text "default: goto" <+> pprBlockId l <> semi | otherwise = text "default: __builtin_unreachable();" ===================================== compiler/GHC/CmmToLlvm.hs ===================================== @@ -11,7 +11,7 @@ module GHC.CmmToLlvm ) where -import GHC.Prelude +import GHC.Prelude hiding ( head ) import GHC.Llvm import GHC.CmmToLlvm.Base @@ -37,6 +37,7 @@ import GHC.Utils.Logger import qualified GHC.Data.Stream as Stream import Control.Monad ( when, forM_ ) +import Data.List.NonEmpty ( head ) import Data.Maybe ( fromMaybe, catMaybes ) import System.IO @@ -68,7 +69,7 @@ llvmCodeGen logger cfg h cmm_stream "System LLVM version: " <> text (llvmVersionStr ver) $$ "We will try though..." let isS390X = platformArch (llvmCgPlatform cfg) == ArchS390X - let major_ver = head . llvmVersionList $ ver + let major_ver = head . llvmVersionNE $ ver when (isS390X && major_ver < 10 && doWarn) $ putMsg logger $ "Warning: For s390x the GHC calling convention is only supported since LLVM version 10." <+> "You are using LLVM version: " <> text (llvmVersionStr ver) ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -59,9 +59,18 @@ _ = pprTrace -- Tired of commenting out the import all the time -- | Options for the demand analysis data DmdAnalOpts = DmdAnalOpts - { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries - , dmd_unbox_width :: !Int -- ^ Use strict dictionaries + { dmd_strict_dicts :: !Bool + -- ^ Value of `-fdicts-strict` (on by default). + -- When set, all functons are implicitly strict in dictionary args. + , dmd_do_boxity :: !Bool + -- ^ Governs whether the analysis should update boxity signatures. + -- See Note [Don't change boxity without worker/wrapper]. + , dmd_unbox_width :: !Int + -- ^ Value of `-fdmd-unbox-width`. + -- See Note [Unboxed demand on function bodies returning small products] , dmd_max_worker_args :: !Int + -- ^ Value of `-fmax-worker-args`. + -- Don't unbox anything if we end up with more than this many args. } -- This is a strict alternative to (,) @@ -146,6 +155,40 @@ unforced thunks in demand or strictness information; and it is the most memory-intensive part of the compilation process, so this added seqBinds makes a big difference in peak memory usage. +Note [Don't change boxity without worker/wrapper] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (T21754) + f n = n+1 + {-# NOINLINE f #-} +With `-fno-worker-wrapper`, we should not give `f` a boxity signature that says +that it unboxes its argument! Client modules would never be able to cancel away +the box for n. Likewise we shouldn't give `f` the CPR property. + +Similarly, in the last run of DmdAnal before codegen (which does not have a +worker/wrapper phase) we should not change boxity in any way. Remember: an +earlier result of the demand analyser, complete with worker/wrapper, has aleady +given a demand signature (with boxity info) to the function. +(The "last run" is mainly there to attach demanded-once info to let-bindings.) + +In general, we should not run Note [Boxity analysis] unless worker/wrapper +follows to exploit the boxity and make sure that calling modules can observe the +reported boxity. + +Hence DmdAnal is configured by a flag `dmd_do_boxity` that is True only +if worker/wrapper follows after DmdAnal. If it is not set, and the signature +is not subject to Note [Boxity for bottoming functions], DmdAnal tries +to transfer over the previous boxity to the new demand signature, in +`setIdDmdAndBoxSig`. + +Why isn't CprAnal configured with a similar flag? Because if we aren't going to +do worker/wrapper we don't run CPR analysis at all. (see GHC.Core.Opt.Pipeline) + +It might be surprising that we only try to preserve *arg* boxity, not boxity on +FVs. But FV demands won't make it into interface files anyway, so it's a waste +of energy. +Besides, W/W zaps the `DmdEnv` portion of a signature, so we don't know the old +boxity to begin with; see Note [Zapping DmdEnv after Demand Analyzer]. + Note [Analysing top-level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a CoreProgram like @@ -257,6 +300,16 @@ setBindIdDemandInfo top_lvl id dmd = setIdDemandInfo id $ case top_lvl of TopLevel | not (isInterestingTopLevelFn id) -> topDmd _ -> dmd +-- | Update the demand signature, but be careful not to change boxity info if +-- `dmd_do_boxity` is True or if the signature is bottom. +-- See Note [Don't change boxity without worker/wrapper] +-- and Note [Boxity for bottoming functions]. +setIdDmdAndBoxSig :: DmdAnalOpts -> Id -> DmdSig -> Id +setIdDmdAndBoxSig opts id sig = setIdDmdSig id $ + if dmd_do_boxity opts || isBottomingSig sig + then sig + else transferArgBoxityDmdSig (idDmdSig id) sig + -- | Let bindings can be processed in two ways: -- Down (RHS before body) or Up (body before RHS). -- This function handles the up variant. @@ -1018,7 +1071,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) - final_id = id `setIdDmdSig` sig + opts = ae_opts env + final_id = setIdDmdAndBoxSig opts id sig !final_env = extendAnalEnv top_lvl env final_id sig -- See Note [Aggregated demand for cardinality] @@ -1858,8 +1912,9 @@ dmdFix :: TopLevelFlag dmdFix top_lvl env let_dmd orig_pairs = loop 1 initial_pairs where + opts = ae_opts env -- See Note [Initialising strictness] - initial_pairs | ae_virgin env = [(setIdDmdSig id botSig, rhs) | (id, rhs) <- orig_pairs ] + initial_pairs | ae_virgin env = [(setIdDmdAndBoxSig opts id botSig, rhs) | (id, rhs) <- orig_pairs ] | otherwise = orig_pairs -- If fixed-point iteration does not yield a result we use this instead ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -150,7 +150,7 @@ getCoreToDo dflags rule_base extra_vars maybe_rule_check phase = runMaybe rule_check (CoreDoRuleCheck phase) maybe_strictness_before (Phase phase) - | phase `elem` strictnessBefore dflags = CoreDoDemand + | phase `elem` strictnessBefore dflags = CoreDoDemand False maybe_strictness_before _ = CoreDoNothing @@ -171,8 +171,8 @@ getCoreToDo dflags rule_base extra_vars simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter (initGentleSimplMode dflags) rule_base - dmd_cpr_ww = if ww_on then [CoreDoDemand,CoreDoCpr,CoreDoWorkerWrapper] - else [CoreDoDemand,CoreDoCpr] + dmd_cpr_ww = if ww_on then [CoreDoDemand True,CoreDoCpr,CoreDoWorkerWrapper] + else [CoreDoDemand False] -- NB: No CPR! See Note [Don't change boxity without worker/wrapper] demand_analyser = (CoreDoPasses ( @@ -340,7 +340,7 @@ getCoreToDo dflags rule_base extra_vars -- has run at all. See Note [Final Demand Analyser run] in GHC.Core.Opt.DmdAnal -- It is EXTREMELY IMPORTANT to run this pass, otherwise execution -- can become /exponentially/ more expensive. See #11731, #12996. - runWhen (strictness || late_dmd_anal) CoreDoDemand, + runWhen (strictness || late_dmd_anal) (CoreDoDemand False), maybe_rule_check FinalPhase, @@ -491,8 +491,8 @@ doCorePass pass guts = do CoreDoExitify -> {-# SCC "Exitify" #-} updateBinds exitifyProgram - CoreDoDemand -> {-# SCC "DmdAnal" #-} - updateBindsM (liftIO . dmdAnal logger dflags fam_envs (mg_rules guts)) + CoreDoDemand before_ww -> {-# SCC "DmdAnal" #-} + updateBindsM (liftIO . dmdAnal logger before_ww dflags fam_envs (mg_rules guts)) CoreDoCpr -> {-# SCC "CprAnal" #-} updateBindsM (liftIO . cprAnalProgram logger fam_envs) @@ -557,10 +557,11 @@ ruleCheckPass current_phase pat guts = do rule_fn (mg_binds guts)) return guts -dmdAnal :: Logger -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram -dmdAnal logger dflags fam_envs rules binds = do +dmdAnal :: Logger -> Bool -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram +dmdAnal logger before_ww dflags fam_envs rules binds = do let !opts = DmdAnalOpts { dmd_strict_dicts = gopt Opt_DictsStrict dflags + , dmd_do_boxity = before_ww -- only run Boxity Analysis immediately preceding WW , dmd_unbox_width = dmdUnboxWidth dflags , dmd_max_worker_args = maxWorkerArgs dflags } ===================================== compiler/GHC/Core/Opt/Pipeline/Types.hs ===================================== @@ -45,7 +45,8 @@ data CoreToDo -- These are diff core-to-core passes, | CoreDoStaticArgs | CoreDoCallArity | CoreDoExitify - | CoreDoDemand + | CoreDoDemand Bool -- Bool: Do worker/wrapper afterwards? + -- See Note [Don't change boxity without worker/wrapper] | CoreDoCpr | CoreDoWorkerWrapper | CoreDoSpecialising @@ -74,7 +75,8 @@ instance Outputable CoreToDo where ppr CoreDoStaticArgs = text "Static argument" ppr CoreDoCallArity = text "Called arity analysis" ppr CoreDoExitify = text "Exitification transformation" - ppr CoreDoDemand = text "Demand analysis" + ppr (CoreDoDemand True) = text "Demand analysis (including Boxity)" + ppr (CoreDoDemand False) = text "Demand analysis" ppr CoreDoCpr = text "Constructed Product Result analysis" ppr CoreDoWorkerWrapper = text "Worker Wrapper binds" ppr CoreDoSpecialising = text "Specialise" ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -63,6 +63,8 @@ import GHC.Unit.Module( Module ) import GHC.Unit.Module.ModGuts import GHC.Core.Unfold +import Data.List.NonEmpty ( NonEmpty (..) ) + {- ************************************************************************ * * @@ -1201,7 +1203,7 @@ specCase env scrut' case_bndr [Alt con args rhs] | -- See Note [Floating dictionaries out of cases] interestingDict scrut' (idType case_bndr) , not (isDeadBinder case_bndr && null sc_args') - = do { (case_bndr_flt : sc_args_flt) <- mapM clone_me (case_bndr' : sc_args') + = do { case_bndr_flt :| sc_args_flt <- mapM clone_me (case_bndr' :| sc_args') ; let case_bndr_flt' = case_bndr_flt `addDictUnfolding` scrut' scrut_bind = mkDB (NonRec case_bndr_flt scrut') ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1200,12 +1200,9 @@ cpeApp top_env expr arg_ty' = cpSubstTy env arg_ty CpeApp (Coercion co) - -> rebuild_app' env as (App fun' (Coercion co')) floats ss' rt_ticks req_depth + -> rebuild_app' env as (App fun' (Coercion co')) floats (drop 1 ss) rt_ticks req_depth where co' = cpSubstCo env co - ss' - | null ss = [] - | otherwise = tail ss CpeApp arg -> do let (ss1, ss_rest) -- See Note [lazyId magic] in GHC.Types.Id.Make ===================================== compiler/GHC/Data/BooleanFormula.hs ===================================== @@ -16,9 +16,10 @@ module GHC.Data.BooleanFormula ( pprBooleanFormula, pprBooleanFormulaNice ) where -import GHC.Prelude +import GHC.Prelude hiding ( init, last ) import Data.List ( nub, intersperse ) +import Data.List.NonEmpty ( NonEmpty (..), init, last ) import Data.Data import GHC.Utils.Monad @@ -227,7 +228,7 @@ pprBooleanFormulaNice = pprBooleanFormula' pprVar pprAnd pprOr 0 pprAnd p = cparen (p > 1) . pprAnd' pprAnd' [] = empty pprAnd' [x,y] = x <+> text "and" <+> y - pprAnd' xs@(_:_) = fsep (punctuate comma (init xs)) <> text ", and" <+> last xs + pprAnd' (x:xs) = fsep (punctuate comma (init (x:|xs))) <> text ", and" <+> last (x:|xs) pprOr p xs = cparen (p > 1) $ text "either" <+> sep (intersperse (text "or") xs) instance (OutputableBndr a) => Outputable (BooleanFormula a) where ===================================== compiler/GHC/Driver/Config/Core/Lint.hs ===================================== @@ -83,7 +83,7 @@ coreDumpFlag CoreLiberateCase = Just Opt_D_verbose_core2core coreDumpFlag CoreDoStaticArgs = Just Opt_D_verbose_core2core coreDumpFlag CoreDoCallArity = Just Opt_D_dump_call_arity coreDumpFlag CoreDoExitify = Just Opt_D_dump_exitify -coreDumpFlag CoreDoDemand = Just Opt_D_dump_stranal +coreDumpFlag (CoreDoDemand {}) = Just Opt_D_dump_stranal coreDumpFlag CoreDoCpr = Just Opt_D_dump_cpranal coreDumpFlag CoreDoWorkerWrapper = Just Opt_D_dump_worker_wrapper coreDumpFlag CoreDoSpecialising = Just Opt_D_dump_spec ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -1779,9 +1779,9 @@ getGccSearchDirectory logger dflags key = do find :: String -> String -> String find r x = let lst = lines x val = filter (r `isPrefixOf`) lst - in if null val - then [] - else case break (=='=') (head val) of + in case val of + [] -> [] + x:_ -> case break (=='=') x of (_ , []) -> [] (_, (_:xs)) -> xs ===================================== compiler/GHC/Llvm/Types.hs ===================================== @@ -181,7 +181,7 @@ getLitType :: LlvmLit -> LlvmType getLitType (LMIntLit _ t) = t getLitType (LMFloatLit _ t) = t getLitType (LMVectorLit []) = panic "getLitType" -getLitType (LMVectorLit ls) = LMVector (length ls) (getLitType (head ls)) +getLitType (LMVectorLit ls@(l:_)) = LMVector (length ls) (getLitType l) getLitType (LMNullLit t) = t getLitType (LMUndefLit t) = t ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2513,10 +2513,10 @@ mkRecConstrOrUpdate _ (L _ (HsVar _ (L l c))) _lrec (fbinds,dd) anns | isRdrDataCon c = do let (fs, ps) = partitionEithers fbinds - if not (null ps) - then addFatalError $ mkPlainErrorMsgEnvelope (getLocA (head ps)) $ - PsErrOverloadedRecordDotInvalid - else return (mkRdrRecordCon (L l c) (mk_rec_fields fs dd) anns) + case ps of + p:_ -> addFatalError $ mkPlainErrorMsgEnvelope (getLocA p) $ + PsErrOverloadedRecordDotInvalid + _ -> return (mkRdrRecordCon (L l c) (mk_rec_fields fs dd) anns) mkRecConstrOrUpdate overloaded_update exp _ (fs,dd) anns | Just dd_loc <- dd = addFatalError $ mkPlainErrorMsgEnvelope dd_loc $ PsErrDotsInRecordUpdate @@ -2546,15 +2546,13 @@ mkRdrRecordUpd overloaded_on exp@(L loc _) fbinds anns = do [ L l lbl | L _ (HsFieldBind _ (L l lbl) _ _) <- fs' , isQual . rdrNameAmbiguousFieldOcc $ lbl ] - if not $ null qualifiedFields - then - addFatalError $ mkPlainErrorMsgEnvelope (getLocA (head qualifiedFields)) $ + case qualifiedFields of + qf:_ -> addFatalError $ mkPlainErrorMsgEnvelope (getLocA qf) $ PsErrOverloadedRecordUpdateNoQualifiedFields - else -- This is a RecordDotSyntax update. - return RecordUpd { - rupd_ext = anns - , rupd_expr = exp - , rupd_flds = Right (toProjUpdates fbinds) } + _ -> return RecordUpd -- This is a RecordDotSyntax update. + { rupd_ext = anns + , rupd_expr = exp + , rupd_flds = Right (toProjUpdates fbinds) } where toProjUpdates :: [Fbind (HsExpr GhcPs)] -> [LHsRecUpdProj GhcPs] toProjUpdates = map (\case { Right p -> p; Left f -> recFieldToProjUpdate f }) ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -178,6 +178,8 @@ import qualified GHC.Data.BooleanFormula as BF import Data.Functor.Classes ( liftEq ) import Data.List ( sortBy, sort ) +import Data.List.NonEmpty ( NonEmpty (..) ) +import qualified Data.List.NonEmpty as NE import Data.Ord import Data.Data ( Data ) import qualified Data.Set as S @@ -2223,10 +2225,8 @@ type Plan = TcM PlanResult -- | Try the plans in order. If one fails (by raising an exn), try the next. -- If one succeeds, take it. -runPlans :: [Plan] -> TcM PlanResult -runPlans [] = panic "runPlans" -runPlans [p] = p -runPlans (p:ps) = tryTcDiscardingErrs (runPlans ps) p +runPlans :: NonEmpty Plan -> Plan +runPlans = foldr1 (flip tryTcDiscardingErrs) -- | Typecheck (and 'lift') a stmt entered by the user in GHCi into the -- GHCi 'environment'. @@ -2298,30 +2298,31 @@ tcUserStmt (L loc (BodyStmt _ expr _ _)) -- See Note [GHCi Plans] - it_plans = [ + it_plans = -- Plan A do { stuff@([it_id], _) <- tcGhciStmts [bind_stmt, print_it] ; it_ty <- zonkTcType (idType it_id) - ; when (isUnitTy $ it_ty) failM - ; return stuff }, + ; when (isUnitTy it_ty) failM + ; return stuff } :| -- Plan B; a naked bind statement - tcGhciStmts [bind_stmt], + [ tcGhciStmts [bind_stmt] -- Plan C; check that the let-binding is typeable all by itself. -- If not, fail; if so, try to print it. -- The two-step process avoids getting two errors: one from -- the expression itself, and one from the 'print it' part -- This two-step story is very clunky, alas - do { _ <- checkNoErrs (tcGhciStmts [let_stmt]) + , do { _ <- checkNoErrs (tcGhciStmts [let_stmt]) --- checkNoErrs defeats the error recovery of let-bindings ; tcGhciStmts [let_stmt, print_it] } ] -- Plans where we don't bind "it" - no_it_plans = [ - tcGhciStmts [no_it_a] , - tcGhciStmts [no_it_b] , - tcGhciStmts [no_it_c] ] + no_it_plans = + tcGhciStmts [no_it_a] :| + tcGhciStmts [no_it_b] : + tcGhciStmts [no_it_c] : + [] ; generate_it <- goptM Opt_NoIt @@ -2413,13 +2414,13 @@ tcUserStmt rdr_stmt@(L loc _) ; let print_result_plan | opt_pr_flag -- The flag says "print result" , [v] <- collectLStmtBinders CollNoDictBinders gi_stmt -- One binder - = [mk_print_result_plan gi_stmt v] - | otherwise = [] + = Just $ mk_print_result_plan gi_stmt v + | otherwise = Nothing -- The plans are: -- [stmt; print v] if one binder and not v::() -- [stmt] otherwise - ; plan <- runPlans (print_result_plan ++ [tcGhciStmts [gi_stmt]]) + ; plan <- runPlans $ maybe id (NE.<|) print_result_plan $ NE.singleton $ tcGhciStmts [gi_stmt] ; return (plan, fix_env) } where mk_print_result_plan stmt v ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -64,7 +64,8 @@ module GHC.Types.Demand ( -- * Demand signatures DmdSig(..), mkDmdSigForArity, mkClosedDmdSig, mkVanillaDmdSig, splitDmdSig, dmdSigDmdEnv, hasDemandEnvSig, - nopSig, botSig, isNopSig, isDeadEndSig, isDeadEndAppSig, trimBoxityDmdSig, + nopSig, botSig, isNopSig, isBottomingSig, isDeadEndSig, isDeadEndAppSig, + trimBoxityDmdSig, transferArgBoxityDmdSig, -- ** Handling arity adjustments prependArgsDmdSig, etaConvertDmdSig, @@ -2147,6 +2148,13 @@ isNopSig (DmdSig ty) = isNopDmdType ty isDeadEndSig :: DmdSig -> Bool isDeadEndSig (DmdSig (DmdType _ _ res)) = isDeadEndDiv res +-- | True if the signature diverges or throws an imprecise exception in a saturated call. +-- NB: In constrast to 'isDeadEndSig' this returns False for 'exnDiv'. +-- See Note [Dead ends] +-- and Note [Precise vs imprecise exceptions]. +isBottomingSig :: DmdSig -> Bool +isBottomingSig (DmdSig (DmdType _ _ res)) = res == botDiv + -- | True when the signature indicates all arguments are boxed onlyBoxedArguments :: DmdSig -> Bool onlyBoxedArguments (DmdSig (DmdType _ dmds _)) = all demandIsBoxed dmds @@ -2179,6 +2187,38 @@ trimBoxityDmdType (DmdType fvs ds res) = trimBoxityDmdSig :: DmdSig -> DmdSig trimBoxityDmdSig = coerce trimBoxityDmdType +-- | Transfers the boxity of the left arg to the demand structure of the right +-- arg. This only makes sense if applied to new and old demands of the same +-- value. +transferBoxity :: Demand -> Demand -> Demand +transferBoxity from to = go_dmd from to + where + go_dmd (from_n :* from_sd) to_dmd@(to_n :* to_sd) + | isAbs from_n || isAbs to_n = to_dmd + | otherwise = case (from_sd, to_sd) of + (Poly from_b _, Poly _ to_c) -> + to_n :* Poly from_b to_c + (_, Prod _ to_ds) + | Just (from_b, from_ds) <- viewProd (length to_ds) from_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + (Prod from_b from_ds, _) + | Just (_, to_ds) <- viewProd (length from_ds) to_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + _ -> trimBoxity to_dmd + +transferArgBoxityDmdType :: DmdType -> DmdType -> DmdType +transferArgBoxityDmdType _from@(DmdType _ from_ds _) to@(DmdType to_fvs to_ds to_res) + | equalLength from_ds to_ds + = -- pprTraceWith "transfer" (\r -> ppr _from $$ ppr to $$ ppr r) $ + DmdType to_fvs -- Only arg boxity! See Note [Don't change boxity without worker/wrapper] + (zipWith transferBoxity from_ds to_ds) + to_res + | otherwise + = trimBoxityDmdType to + +transferArgBoxityDmdSig :: DmdSig -> DmdSig -> DmdSig +transferArgBoxityDmdSig = coerce transferArgBoxityDmdType + prependArgsDmdSig :: Int -> DmdSig -> DmdSig -- ^ Add extra ('topDmd') arguments to a strictness signature. -- In contrast to 'etaConvertDmdSig', this /prepends/ additional argument ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -825,12 +825,12 @@ pprGlobalRdrEnv locals_only env remove_locals gres | locals_only = filter isLocalGRE gres | otherwise = gres pp [] = empty - pp gres = hang (ppr occ + pp gres@(gre:_) = hang (ppr occ <+> parens (text "unique" <+> ppr (getUnique occ)) <> colon) 2 (vcat (map ppr gres)) where - occ = nameOccName (greMangledName (head gres)) + occ = nameOccName (greMangledName gre) lookupGlobalRdrEnv :: GlobalRdrEnv -> OccName -> [GlobalRdrElt] lookupGlobalRdrEnv env occ_name = case lookupOccEnv env occ_name of ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -699,8 +699,8 @@ getUnitDbRefs cfg = do let base_conf_refs = case e_pkg_path of Left _ -> system_conf_refs Right path - | not (null path) && isSearchPathSeparator (last path) - -> map PkgDbPath (splitSearchPath (init path)) ++ system_conf_refs + | Just (xs, x) <- snocView path, isSearchPathSeparator x + -> map PkgDbPath (splitSearchPath xs) ++ system_conf_refs | otherwise -> map PkgDbPath (splitSearchPath path) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -124,7 +124,7 @@ module GHC.Utils.Misc ( HasDebugCallStack, ) where -import GHC.Prelude +import GHC.Prelude hiding ( last ) import GHC.Utils.Exception import GHC.Utils.Panic.Plain @@ -133,7 +133,7 @@ import GHC.Utils.Fingerprint import Data.Data import qualified Data.List as List -import Data.List.NonEmpty ( NonEmpty(..) ) +import Data.List.NonEmpty ( NonEmpty(..), last ) import GHC.Exts import GHC.Stack (HasCallStack) @@ -750,7 +750,7 @@ last2 = List.foldl' (\(_,x2) x -> (x2,x)) (partialError,partialError) lastMaybe :: [a] -> Maybe a lastMaybe [] = Nothing -lastMaybe xs = Just $ last xs +lastMaybe (x:xs) = Just $ last (x:|xs) -- | @onJust x m f@ applies f to the value inside the Just or returns the default. onJust :: b -> Maybe a -> (a->b) -> b @@ -1293,9 +1293,9 @@ withAtomicRename targetFile f = do -- string is returned in the first component (and the second one is just -- empty). splitLongestPrefix :: String -> (Char -> Bool) -> (String,String) -splitLongestPrefix str pred - | null r_pre = (str, []) - | otherwise = (reverse (tail r_pre), reverse r_suf) +splitLongestPrefix str pred = case r_pre of + [] -> (str, []) + _:r_pre' -> (reverse r_pre', reverse r_suf) -- 'tail' drops the char satisfying 'pred' where (r_suf, r_pre) = break pred (reverse str) ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -143,7 +143,7 @@ Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 foo :: Int -> Int [GblId, Arity=1, - Str=<1!P(L)>, + Str=<1L>, Cpr=1, Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/stranal/sigs/T21754.hs ===================================== @@ -0,0 +1,7 @@ +{-# OPTIONS_GHC -fno-worker-wrapper #-} + +module Test where + +f :: Int -> Int +f n = n+1 +{-# NOINLINE f #-} ===================================== testsuite/tests/stranal/sigs/T21754.stderr ===================================== @@ -0,0 +1,10 @@ + +==================== Strictness signatures ==================== +Test.f: <1L> + + + +==================== Strictness signatures ==================== +Test.f: <1L> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -34,5 +34,6 @@ test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) test('T21717', normal, compile, ['']) +test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66e5e7cf9e1501ddde870af4a2403de97e047701...6b36624262c1956f7fd2ba8b50b5fe14cd9e83e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/66e5e7cf9e1501ddde870af4a2403de97e047701...6b36624262c1956f7fd2ba8b50b5fe14cd9e83e9 You're receiving 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 Sep 30 20:04:56 2022 From: gitlab at gitlab.haskell.org (Brandon Chinn (@brandonchinn178)) Date: Fri, 30 Sep 2022 16:04:56 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/pattern-synonym-docs Message-ID: <63374be89af32_2c975742bcfe70122071a@gitlab.mail> Brandon Chinn pushed new branch wip/pattern-synonym-docs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/pattern-synonym-docs You're receiving 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 Sep 30 20:16:12 2022 From: gitlab at gitlab.haskell.org (Brandon Chinn (@brandonchinn178)) Date: Fri, 30 Sep 2022 16:16:12 -0400 Subject: [Git][ghc/ghc][wip/pattern-synonym-docs] Clarify INLINE support for patterns were added in GHC 9.2 Message-ID: <63374e8cd54b2_2c97575148c122285d@gitlab.mail> Brandon Chinn pushed to branch wip/pattern-synonym-docs at Glasgow Haskell Compiler / GHC Commits: a704ff03 by Brandon Chinn at 2022-09-30T20:16:11+00:00 Clarify INLINE support for patterns were added in GHC 9.2 - - - - - 1 changed file: - docs/users_guide/exts/pattern_synonyms.rst Changes: ===================================== docs/users_guide/exts/pattern_synonyms.rst ===================================== @@ -524,7 +524,7 @@ Pragmas for pattern synonyms ---------------------------- The :ref:`inlinable-pragma`, :ref:`inline-pragma` and :ref:`noinline-pragma` are supported for pattern -synonyms. For example: :: +synonyms as of GHC 9.2. For example: :: pattern InlinablePattern x = [x] {-# INLINABLE InlinablePattern #-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a704ff0311447c49a393c0ec8cbd528ced348d01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a704ff0311447c49a393c0ec8cbd528ced348d01 You're receiving 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 Sep 30 21:45:23 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 30 Sep 2022 17:45:23 -0400 Subject: [Git][ghc/ghc][master] Boxity: Don't update Boxity unless worker/wrapper follows (#21754) Message-ID: <6337637321f3_2c975742cc3160124585e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 9 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Pipeline/Types.hs - compiler/GHC/Driver/Config/Core/Lint.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/simplCore/should_compile/spec-inline.stderr - + testsuite/tests/stranal/sigs/T21754.hs - + testsuite/tests/stranal/sigs/T21754.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -59,9 +59,18 @@ _ = pprTrace -- Tired of commenting out the import all the time -- | Options for the demand analysis data DmdAnalOpts = DmdAnalOpts - { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries - , dmd_unbox_width :: !Int -- ^ Use strict dictionaries + { dmd_strict_dicts :: !Bool + -- ^ Value of `-fdicts-strict` (on by default). + -- When set, all functons are implicitly strict in dictionary args. + , dmd_do_boxity :: !Bool + -- ^ Governs whether the analysis should update boxity signatures. + -- See Note [Don't change boxity without worker/wrapper]. + , dmd_unbox_width :: !Int + -- ^ Value of `-fdmd-unbox-width`. + -- See Note [Unboxed demand on function bodies returning small products] , dmd_max_worker_args :: !Int + -- ^ Value of `-fmax-worker-args`. + -- Don't unbox anything if we end up with more than this many args. } -- This is a strict alternative to (,) @@ -146,6 +155,40 @@ unforced thunks in demand or strictness information; and it is the most memory-intensive part of the compilation process, so this added seqBinds makes a big difference in peak memory usage. +Note [Don't change boxity without worker/wrapper] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (T21754) + f n = n+1 + {-# NOINLINE f #-} +With `-fno-worker-wrapper`, we should not give `f` a boxity signature that says +that it unboxes its argument! Client modules would never be able to cancel away +the box for n. Likewise we shouldn't give `f` the CPR property. + +Similarly, in the last run of DmdAnal before codegen (which does not have a +worker/wrapper phase) we should not change boxity in any way. Remember: an +earlier result of the demand analyser, complete with worker/wrapper, has aleady +given a demand signature (with boxity info) to the function. +(The "last run" is mainly there to attach demanded-once info to let-bindings.) + +In general, we should not run Note [Boxity analysis] unless worker/wrapper +follows to exploit the boxity and make sure that calling modules can observe the +reported boxity. + +Hence DmdAnal is configured by a flag `dmd_do_boxity` that is True only +if worker/wrapper follows after DmdAnal. If it is not set, and the signature +is not subject to Note [Boxity for bottoming functions], DmdAnal tries +to transfer over the previous boxity to the new demand signature, in +`setIdDmdAndBoxSig`. + +Why isn't CprAnal configured with a similar flag? Because if we aren't going to +do worker/wrapper we don't run CPR analysis at all. (see GHC.Core.Opt.Pipeline) + +It might be surprising that we only try to preserve *arg* boxity, not boxity on +FVs. But FV demands won't make it into interface files anyway, so it's a waste +of energy. +Besides, W/W zaps the `DmdEnv` portion of a signature, so we don't know the old +boxity to begin with; see Note [Zapping DmdEnv after Demand Analyzer]. + Note [Analysing top-level bindings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider a CoreProgram like @@ -257,6 +300,16 @@ setBindIdDemandInfo top_lvl id dmd = setIdDemandInfo id $ case top_lvl of TopLevel | not (isInterestingTopLevelFn id) -> topDmd _ -> dmd +-- | Update the demand signature, but be careful not to change boxity info if +-- `dmd_do_boxity` is True or if the signature is bottom. +-- See Note [Don't change boxity without worker/wrapper] +-- and Note [Boxity for bottoming functions]. +setIdDmdAndBoxSig :: DmdAnalOpts -> Id -> DmdSig -> Id +setIdDmdAndBoxSig opts id sig = setIdDmdSig id $ + if dmd_do_boxity opts || isBottomingSig sig + then sig + else transferArgBoxityDmdSig (idDmdSig id) sig + -- | Let bindings can be processed in two ways: -- Down (RHS before body) or Up (body before RHS). -- This function handles the up variant. @@ -1018,7 +1071,8 @@ dmdAnalRhsSig top_lvl rec_flag env let_dmd id rhs sig = mkDmdSigForArity threshold_arity (DmdType sig_fv final_rhs_dmds rhs_div) - final_id = id `setIdDmdSig` sig + opts = ae_opts env + final_id = setIdDmdAndBoxSig opts id sig !final_env = extendAnalEnv top_lvl env final_id sig -- See Note [Aggregated demand for cardinality] @@ -1858,8 +1912,9 @@ dmdFix :: TopLevelFlag dmdFix top_lvl env let_dmd orig_pairs = loop 1 initial_pairs where + opts = ae_opts env -- See Note [Initialising strictness] - initial_pairs | ae_virgin env = [(setIdDmdSig id botSig, rhs) | (id, rhs) <- orig_pairs ] + initial_pairs | ae_virgin env = [(setIdDmdAndBoxSig opts id botSig, rhs) | (id, rhs) <- orig_pairs ] | otherwise = orig_pairs -- If fixed-point iteration does not yield a result we use this instead ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -150,7 +150,7 @@ getCoreToDo dflags rule_base extra_vars maybe_rule_check phase = runMaybe rule_check (CoreDoRuleCheck phase) maybe_strictness_before (Phase phase) - | phase `elem` strictnessBefore dflags = CoreDoDemand + | phase `elem` strictnessBefore dflags = CoreDoDemand False maybe_strictness_before _ = CoreDoNothing @@ -171,8 +171,8 @@ getCoreToDo dflags rule_base extra_vars simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter (initGentleSimplMode dflags) rule_base - dmd_cpr_ww = if ww_on then [CoreDoDemand,CoreDoCpr,CoreDoWorkerWrapper] - else [CoreDoDemand,CoreDoCpr] + dmd_cpr_ww = if ww_on then [CoreDoDemand True,CoreDoCpr,CoreDoWorkerWrapper] + else [CoreDoDemand False] -- NB: No CPR! See Note [Don't change boxity without worker/wrapper] demand_analyser = (CoreDoPasses ( @@ -340,7 +340,7 @@ getCoreToDo dflags rule_base extra_vars -- has run at all. See Note [Final Demand Analyser run] in GHC.Core.Opt.DmdAnal -- It is EXTREMELY IMPORTANT to run this pass, otherwise execution -- can become /exponentially/ more expensive. See #11731, #12996. - runWhen (strictness || late_dmd_anal) CoreDoDemand, + runWhen (strictness || late_dmd_anal) (CoreDoDemand False), maybe_rule_check FinalPhase, @@ -491,8 +491,8 @@ doCorePass pass guts = do CoreDoExitify -> {-# SCC "Exitify" #-} updateBinds exitifyProgram - CoreDoDemand -> {-# SCC "DmdAnal" #-} - updateBindsM (liftIO . dmdAnal logger dflags fam_envs (mg_rules guts)) + CoreDoDemand before_ww -> {-# SCC "DmdAnal" #-} + updateBindsM (liftIO . dmdAnal logger before_ww dflags fam_envs (mg_rules guts)) CoreDoCpr -> {-# SCC "CprAnal" #-} updateBindsM (liftIO . cprAnalProgram logger fam_envs) @@ -557,10 +557,11 @@ ruleCheckPass current_phase pat guts = do rule_fn (mg_binds guts)) return guts -dmdAnal :: Logger -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram -dmdAnal logger dflags fam_envs rules binds = do +dmdAnal :: Logger -> Bool -> DynFlags -> FamInstEnvs -> [CoreRule] -> CoreProgram -> IO CoreProgram +dmdAnal logger before_ww dflags fam_envs rules binds = do let !opts = DmdAnalOpts { dmd_strict_dicts = gopt Opt_DictsStrict dflags + , dmd_do_boxity = before_ww -- only run Boxity Analysis immediately preceding WW , dmd_unbox_width = dmdUnboxWidth dflags , dmd_max_worker_args = maxWorkerArgs dflags } ===================================== compiler/GHC/Core/Opt/Pipeline/Types.hs ===================================== @@ -45,7 +45,8 @@ data CoreToDo -- These are diff core-to-core passes, | CoreDoStaticArgs | CoreDoCallArity | CoreDoExitify - | CoreDoDemand + | CoreDoDemand Bool -- Bool: Do worker/wrapper afterwards? + -- See Note [Don't change boxity without worker/wrapper] | CoreDoCpr | CoreDoWorkerWrapper | CoreDoSpecialising @@ -74,7 +75,8 @@ instance Outputable CoreToDo where ppr CoreDoStaticArgs = text "Static argument" ppr CoreDoCallArity = text "Called arity analysis" ppr CoreDoExitify = text "Exitification transformation" - ppr CoreDoDemand = text "Demand analysis" + ppr (CoreDoDemand True) = text "Demand analysis (including Boxity)" + ppr (CoreDoDemand False) = text "Demand analysis" ppr CoreDoCpr = text "Constructed Product Result analysis" ppr CoreDoWorkerWrapper = text "Worker Wrapper binds" ppr CoreDoSpecialising = text "Specialise" ===================================== compiler/GHC/Driver/Config/Core/Lint.hs ===================================== @@ -83,7 +83,7 @@ coreDumpFlag CoreLiberateCase = Just Opt_D_verbose_core2core coreDumpFlag CoreDoStaticArgs = Just Opt_D_verbose_core2core coreDumpFlag CoreDoCallArity = Just Opt_D_dump_call_arity coreDumpFlag CoreDoExitify = Just Opt_D_dump_exitify -coreDumpFlag CoreDoDemand = Just Opt_D_dump_stranal +coreDumpFlag (CoreDoDemand {}) = Just Opt_D_dump_stranal coreDumpFlag CoreDoCpr = Just Opt_D_dump_cpranal coreDumpFlag CoreDoWorkerWrapper = Just Opt_D_dump_worker_wrapper coreDumpFlag CoreDoSpecialising = Just Opt_D_dump_spec ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -64,7 +64,8 @@ module GHC.Types.Demand ( -- * Demand signatures DmdSig(..), mkDmdSigForArity, mkClosedDmdSig, mkVanillaDmdSig, splitDmdSig, dmdSigDmdEnv, hasDemandEnvSig, - nopSig, botSig, isNopSig, isDeadEndSig, isDeadEndAppSig, trimBoxityDmdSig, + nopSig, botSig, isNopSig, isBottomingSig, isDeadEndSig, isDeadEndAppSig, + trimBoxityDmdSig, transferArgBoxityDmdSig, -- ** Handling arity adjustments prependArgsDmdSig, etaConvertDmdSig, @@ -2147,6 +2148,13 @@ isNopSig (DmdSig ty) = isNopDmdType ty isDeadEndSig :: DmdSig -> Bool isDeadEndSig (DmdSig (DmdType _ _ res)) = isDeadEndDiv res +-- | True if the signature diverges or throws an imprecise exception in a saturated call. +-- NB: In constrast to 'isDeadEndSig' this returns False for 'exnDiv'. +-- See Note [Dead ends] +-- and Note [Precise vs imprecise exceptions]. +isBottomingSig :: DmdSig -> Bool +isBottomingSig (DmdSig (DmdType _ _ res)) = res == botDiv + -- | True when the signature indicates all arguments are boxed onlyBoxedArguments :: DmdSig -> Bool onlyBoxedArguments (DmdSig (DmdType _ dmds _)) = all demandIsBoxed dmds @@ -2179,6 +2187,38 @@ trimBoxityDmdType (DmdType fvs ds res) = trimBoxityDmdSig :: DmdSig -> DmdSig trimBoxityDmdSig = coerce trimBoxityDmdType +-- | Transfers the boxity of the left arg to the demand structure of the right +-- arg. This only makes sense if applied to new and old demands of the same +-- value. +transferBoxity :: Demand -> Demand -> Demand +transferBoxity from to = go_dmd from to + where + go_dmd (from_n :* from_sd) to_dmd@(to_n :* to_sd) + | isAbs from_n || isAbs to_n = to_dmd + | otherwise = case (from_sd, to_sd) of + (Poly from_b _, Poly _ to_c) -> + to_n :* Poly from_b to_c + (_, Prod _ to_ds) + | Just (from_b, from_ds) <- viewProd (length to_ds) from_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + (Prod from_b from_ds, _) + | Just (_, to_ds) <- viewProd (length from_ds) to_sd + -> to_n :* mkProd from_b (strictZipWith go_dmd from_ds to_ds) + _ -> trimBoxity to_dmd + +transferArgBoxityDmdType :: DmdType -> DmdType -> DmdType +transferArgBoxityDmdType _from@(DmdType _ from_ds _) to@(DmdType to_fvs to_ds to_res) + | equalLength from_ds to_ds + = -- pprTraceWith "transfer" (\r -> ppr _from $$ ppr to $$ ppr r) $ + DmdType to_fvs -- Only arg boxity! See Note [Don't change boxity without worker/wrapper] + (zipWith transferBoxity from_ds to_ds) + to_res + | otherwise + = trimBoxityDmdType to + +transferArgBoxityDmdSig :: DmdSig -> DmdSig -> DmdSig +transferArgBoxityDmdSig = coerce transferArgBoxityDmdType + prependArgsDmdSig :: Int -> DmdSig -> DmdSig -- ^ Add extra ('topDmd') arguments to a strictness signature. -- In contrast to 'etaConvertDmdSig', this /prepends/ additional argument ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -143,7 +143,7 @@ Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 foo :: Int -> Int [GblId, Arity=1, - Str=<1!P(L)>, + Str=<1L>, Cpr=1, Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/stranal/sigs/T21754.hs ===================================== @@ -0,0 +1,7 @@ +{-# OPTIONS_GHC -fno-worker-wrapper #-} + +module Test where + +f :: Int -> Int +f n = n+1 +{-# NOINLINE f #-} ===================================== testsuite/tests/stranal/sigs/T21754.stderr ===================================== @@ -0,0 +1,10 @@ + +==================== Strictness signatures ==================== +Test.f: <1L> + + + +==================== Strictness signatures ==================== +Test.f: <1L> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -34,5 +34,6 @@ test('T20746b', normal, compile, ['']) test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) test('T21717', normal, compile, ['']) +test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5e8f493b015df859833beac5a8e64a0f9b9d4f4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5e8f493b015df859833beac5a8e64a0f9b9d4f4 You're receiving 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 Sep 30 21:46:09 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 30 Sep 2022 17:46:09 -0400 Subject: [Git][ghc/ghc][master] Scrub various partiality involving empty lists. Message-ID: <633763a16d8d8_2c975742bcfe5c12498b3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 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. - - - - - 15 changed files: - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Llvm/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Utils/Misc.hs Changes: ===================================== compiler/GHC/Cmm/Node.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Cmm.Dataflow.Block import GHC.Cmm.Dataflow.Graph import GHC.Cmm.Dataflow.Collections import GHC.Cmm.Dataflow.Label +import Data.Foldable (toList) import Data.Functor.Classes (liftCompare) import Data.Maybe import Data.List (tails,sortBy) @@ -247,7 +248,7 @@ pprNode platform node = pp_node <+> pp_debug (cases, mbdef) = switchTargetsFallThrough ids ppCase (is,l) = hsep [ text "case" - , commafy $ map integer is + , commafy $ toList $ fmap integer is , text ": goto" , ppr l <> semi ] ===================================== compiler/GHC/Cmm/Switch.hs ===================================== @@ -12,7 +12,7 @@ module GHC.Cmm.Switch ( createSwitchPlan, ) where -import GHC.Prelude +import GHC.Prelude hiding (head) import GHC.Utils.Outputable import GHC.Driver.Backend @@ -20,7 +20,7 @@ import GHC.Utils.Panic import GHC.Cmm.Dataflow.Label (Label) import Data.Maybe -import qualified Data.List.NonEmpty as NE +import Data.List.NonEmpty (NonEmpty (..), groupWith, head) import qualified Data.Map as M -- Note [Cmm Switches, the general plan] @@ -200,11 +200,11 @@ switchTargetsToList (SwitchTargets _ _ mbdef branches) -- | Groups cases with equal targets, suitable for pretty-printing to a -- c-like switch statement with fall-through semantics. -switchTargetsFallThrough :: SwitchTargets -> ([([Integer], Label)], Maybe Label) +switchTargetsFallThrough :: SwitchTargets -> ([(NonEmpty Integer, Label)], Maybe Label) switchTargetsFallThrough (SwitchTargets _ _ mbdef branches) = (groups, mbdef) where - groups = map (\xs -> (map fst (NE.toList xs), snd (NE.head xs))) $ - NE.groupWith snd $ + groups = fmap (\xs -> (fmap fst xs, snd (head xs))) $ + groupWith snd $ M.toList branches -- | Custom equality helper, needed for "GHC.Cmm.CommonBlockElim" ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -78,7 +78,7 @@ module GHC.CmmToAsm ) where -import GHC.Prelude +import GHC.Prelude hiding (head) import qualified GHC.CmmToAsm.X86 as X86 import qualified GHC.CmmToAsm.PPC as PPC @@ -140,7 +140,7 @@ import GHC.Data.Stream (Stream) import qualified GHC.Data.Stream as Stream import Data.List (sortBy) -import qualified Data.List.NonEmpty as NE +import Data.List.NonEmpty (groupAllWith, head) import Data.Maybe import Data.Ord ( comparing ) import Control.Monad @@ -776,8 +776,8 @@ makeImportsDoc config imports | needImportedSymbols config = vcat $ (pprGotDeclaration config :) $ - fmap ( pprImportedSymbol config . fst . NE.head) $ - NE.groupAllWith snd $ + fmap (pprImportedSymbol config . fst . head) $ + groupAllWith snd $ map doPpr $ imps | otherwise ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -59,6 +59,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as BS import Data.Char import Data.List (intersperse) +import Data.List.NonEmpty (NonEmpty (..)) import Data.Map (Map) import qualified Data.Map as Map import GHC.Float @@ -347,7 +348,7 @@ pprSwitch platform e ids rep = typeWidth (cmmExprType platform e) -- fall through case - caseify (ix:ixs, ident) = vcat (map do_fallthrough ixs) $$ final_branch ix + caseify (ix:|ixs, ident) = vcat (map do_fallthrough ixs) $$ final_branch ix where do_fallthrough ix = hsep [ text "case" , pprHexVal platform ix rep <> colon , @@ -357,8 +358,6 @@ pprSwitch platform e ids hsep [ text "case" , pprHexVal platform ix rep <> colon , text "goto" , (pprBlockId ident) <> semi ] - caseify (_ , _ ) = panic "pprSwitch: switch with no cases!" - def | Just l <- mbdef = text "default: goto" <+> pprBlockId l <> semi | otherwise = text "default: __builtin_unreachable();" ===================================== compiler/GHC/CmmToLlvm.hs ===================================== @@ -11,7 +11,7 @@ module GHC.CmmToLlvm ) where -import GHC.Prelude +import GHC.Prelude hiding ( head ) import GHC.Llvm import GHC.CmmToLlvm.Base @@ -37,6 +37,7 @@ import GHC.Utils.Logger import qualified GHC.Data.Stream as Stream import Control.Monad ( when, forM_ ) +import Data.List.NonEmpty ( head ) import Data.Maybe ( fromMaybe, catMaybes ) import System.IO @@ -68,7 +69,7 @@ llvmCodeGen logger cfg h cmm_stream "System LLVM version: " <> text (llvmVersionStr ver) $$ "We will try though..." let isS390X = platformArch (llvmCgPlatform cfg) == ArchS390X - let major_ver = head . llvmVersionList $ ver + let major_ver = head . llvmVersionNE $ ver when (isS390X && major_ver < 10 && doWarn) $ putMsg logger $ "Warning: For s390x the GHC calling convention is only supported since LLVM version 10." <+> "You are using LLVM version: " <> text (llvmVersionStr ver) ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -63,6 +63,8 @@ import GHC.Unit.Module( Module ) import GHC.Unit.Module.ModGuts import GHC.Core.Unfold +import Data.List.NonEmpty ( NonEmpty (..) ) + {- ************************************************************************ * * @@ -1201,7 +1203,7 @@ specCase env scrut' case_bndr [Alt con args rhs] | -- See Note [Floating dictionaries out of cases] interestingDict scrut' (idType case_bndr) , not (isDeadBinder case_bndr && null sc_args') - = do { (case_bndr_flt : sc_args_flt) <- mapM clone_me (case_bndr' : sc_args') + = do { case_bndr_flt :| sc_args_flt <- mapM clone_me (case_bndr' :| sc_args') ; let case_bndr_flt' = case_bndr_flt `addDictUnfolding` scrut' scrut_bind = mkDB (NonRec case_bndr_flt scrut') ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1200,12 +1200,9 @@ cpeApp top_env expr arg_ty' = cpSubstTy env arg_ty CpeApp (Coercion co) - -> rebuild_app' env as (App fun' (Coercion co')) floats ss' rt_ticks req_depth + -> rebuild_app' env as (App fun' (Coercion co')) floats (drop 1 ss) rt_ticks req_depth where co' = cpSubstCo env co - ss' - | null ss = [] - | otherwise = tail ss CpeApp arg -> do let (ss1, ss_rest) -- See Note [lazyId magic] in GHC.Types.Id.Make ===================================== compiler/GHC/Data/BooleanFormula.hs ===================================== @@ -16,9 +16,10 @@ module GHC.Data.BooleanFormula ( pprBooleanFormula, pprBooleanFormulaNice ) where -import GHC.Prelude +import GHC.Prelude hiding ( init, last ) import Data.List ( nub, intersperse ) +import Data.List.NonEmpty ( NonEmpty (..), init, last ) import Data.Data import GHC.Utils.Monad @@ -227,7 +228,7 @@ pprBooleanFormulaNice = pprBooleanFormula' pprVar pprAnd pprOr 0 pprAnd p = cparen (p > 1) . pprAnd' pprAnd' [] = empty pprAnd' [x,y] = x <+> text "and" <+> y - pprAnd' xs@(_:_) = fsep (punctuate comma (init xs)) <> text ", and" <+> last xs + pprAnd' (x:xs) = fsep (punctuate comma (init (x:|xs))) <> text ", and" <+> last (x:|xs) pprOr p xs = cparen (p > 1) $ text "either" <+> sep (intersperse (text "or") xs) instance (OutputableBndr a) => Outputable (BooleanFormula a) where ===================================== compiler/GHC/Linker/Loader.hs ===================================== @@ -1779,9 +1779,9 @@ getGccSearchDirectory logger dflags key = do find :: String -> String -> String find r x = let lst = lines x val = filter (r `isPrefixOf`) lst - in if null val - then [] - else case break (=='=') (head val) of + in case val of + [] -> [] + x:_ -> case break (=='=') x of (_ , []) -> [] (_, (_:xs)) -> xs ===================================== compiler/GHC/Llvm/Types.hs ===================================== @@ -181,7 +181,7 @@ getLitType :: LlvmLit -> LlvmType getLitType (LMIntLit _ t) = t getLitType (LMFloatLit _ t) = t getLitType (LMVectorLit []) = panic "getLitType" -getLitType (LMVectorLit ls) = LMVector (length ls) (getLitType (head ls)) +getLitType (LMVectorLit ls@(l:_)) = LMVector (length ls) (getLitType l) getLitType (LMNullLit t) = t getLitType (LMUndefLit t) = t ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2513,10 +2513,10 @@ mkRecConstrOrUpdate _ (L _ (HsVar _ (L l c))) _lrec (fbinds,dd) anns | isRdrDataCon c = do let (fs, ps) = partitionEithers fbinds - if not (null ps) - then addFatalError $ mkPlainErrorMsgEnvelope (getLocA (head ps)) $ - PsErrOverloadedRecordDotInvalid - else return (mkRdrRecordCon (L l c) (mk_rec_fields fs dd) anns) + case ps of + p:_ -> addFatalError $ mkPlainErrorMsgEnvelope (getLocA p) $ + PsErrOverloadedRecordDotInvalid + _ -> return (mkRdrRecordCon (L l c) (mk_rec_fields fs dd) anns) mkRecConstrOrUpdate overloaded_update exp _ (fs,dd) anns | Just dd_loc <- dd = addFatalError $ mkPlainErrorMsgEnvelope dd_loc $ PsErrDotsInRecordUpdate @@ -2546,15 +2546,13 @@ mkRdrRecordUpd overloaded_on exp@(L loc _) fbinds anns = do [ L l lbl | L _ (HsFieldBind _ (L l lbl) _ _) <- fs' , isQual . rdrNameAmbiguousFieldOcc $ lbl ] - if not $ null qualifiedFields - then - addFatalError $ mkPlainErrorMsgEnvelope (getLocA (head qualifiedFields)) $ + case qualifiedFields of + qf:_ -> addFatalError $ mkPlainErrorMsgEnvelope (getLocA qf) $ PsErrOverloadedRecordUpdateNoQualifiedFields - else -- This is a RecordDotSyntax update. - return RecordUpd { - rupd_ext = anns - , rupd_expr = exp - , rupd_flds = Right (toProjUpdates fbinds) } + _ -> return RecordUpd -- This is a RecordDotSyntax update. + { rupd_ext = anns + , rupd_expr = exp + , rupd_flds = Right (toProjUpdates fbinds) } where toProjUpdates :: [Fbind (HsExpr GhcPs)] -> [LHsRecUpdProj GhcPs] toProjUpdates = map (\case { Right p -> p; Left f -> recFieldToProjUpdate f }) ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -178,6 +178,8 @@ import qualified GHC.Data.BooleanFormula as BF import Data.Functor.Classes ( liftEq ) import Data.List ( sortBy, sort ) +import Data.List.NonEmpty ( NonEmpty (..) ) +import qualified Data.List.NonEmpty as NE import Data.Ord import Data.Data ( Data ) import qualified Data.Set as S @@ -2223,10 +2225,8 @@ type Plan = TcM PlanResult -- | Try the plans in order. If one fails (by raising an exn), try the next. -- If one succeeds, take it. -runPlans :: [Plan] -> TcM PlanResult -runPlans [] = panic "runPlans" -runPlans [p] = p -runPlans (p:ps) = tryTcDiscardingErrs (runPlans ps) p +runPlans :: NonEmpty Plan -> Plan +runPlans = foldr1 (flip tryTcDiscardingErrs) -- | Typecheck (and 'lift') a stmt entered by the user in GHCi into the -- GHCi 'environment'. @@ -2298,30 +2298,31 @@ tcUserStmt (L loc (BodyStmt _ expr _ _)) -- See Note [GHCi Plans] - it_plans = [ + it_plans = -- Plan A do { stuff@([it_id], _) <- tcGhciStmts [bind_stmt, print_it] ; it_ty <- zonkTcType (idType it_id) - ; when (isUnitTy $ it_ty) failM - ; return stuff }, + ; when (isUnitTy it_ty) failM + ; return stuff } :| -- Plan B; a naked bind statement - tcGhciStmts [bind_stmt], + [ tcGhciStmts [bind_stmt] -- Plan C; check that the let-binding is typeable all by itself. -- If not, fail; if so, try to print it. -- The two-step process avoids getting two errors: one from -- the expression itself, and one from the 'print it' part -- This two-step story is very clunky, alas - do { _ <- checkNoErrs (tcGhciStmts [let_stmt]) + , do { _ <- checkNoErrs (tcGhciStmts [let_stmt]) --- checkNoErrs defeats the error recovery of let-bindings ; tcGhciStmts [let_stmt, print_it] } ] -- Plans where we don't bind "it" - no_it_plans = [ - tcGhciStmts [no_it_a] , - tcGhciStmts [no_it_b] , - tcGhciStmts [no_it_c] ] + no_it_plans = + tcGhciStmts [no_it_a] :| + tcGhciStmts [no_it_b] : + tcGhciStmts [no_it_c] : + [] ; generate_it <- goptM Opt_NoIt @@ -2413,13 +2414,13 @@ tcUserStmt rdr_stmt@(L loc _) ; let print_result_plan | opt_pr_flag -- The flag says "print result" , [v] <- collectLStmtBinders CollNoDictBinders gi_stmt -- One binder - = [mk_print_result_plan gi_stmt v] - | otherwise = [] + = Just $ mk_print_result_plan gi_stmt v + | otherwise = Nothing -- The plans are: -- [stmt; print v] if one binder and not v::() -- [stmt] otherwise - ; plan <- runPlans (print_result_plan ++ [tcGhciStmts [gi_stmt]]) + ; plan <- runPlans $ maybe id (NE.<|) print_result_plan $ NE.singleton $ tcGhciStmts [gi_stmt] ; return (plan, fix_env) } where mk_print_result_plan stmt v ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -825,12 +825,12 @@ pprGlobalRdrEnv locals_only env remove_locals gres | locals_only = filter isLocalGRE gres | otherwise = gres pp [] = empty - pp gres = hang (ppr occ + pp gres@(gre:_) = hang (ppr occ <+> parens (text "unique" <+> ppr (getUnique occ)) <> colon) 2 (vcat (map ppr gres)) where - occ = nameOccName (greMangledName (head gres)) + occ = nameOccName (greMangledName gre) lookupGlobalRdrEnv :: GlobalRdrEnv -> OccName -> [GlobalRdrElt] lookupGlobalRdrEnv env occ_name = case lookupOccEnv env occ_name of ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -699,8 +699,8 @@ getUnitDbRefs cfg = do let base_conf_refs = case e_pkg_path of Left _ -> system_conf_refs Right path - | not (null path) && isSearchPathSeparator (last path) - -> map PkgDbPath (splitSearchPath (init path)) ++ system_conf_refs + | Just (xs, x) <- snocView path, isSearchPathSeparator x + -> map PkgDbPath (splitSearchPath xs) ++ system_conf_refs | otherwise -> map PkgDbPath (splitSearchPath path) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -124,7 +124,7 @@ module GHC.Utils.Misc ( HasDebugCallStack, ) where -import GHC.Prelude +import GHC.Prelude hiding ( last ) import GHC.Utils.Exception import GHC.Utils.Panic.Plain @@ -133,7 +133,7 @@ import GHC.Utils.Fingerprint import Data.Data import qualified Data.List as List -import Data.List.NonEmpty ( NonEmpty(..) ) +import Data.List.NonEmpty ( NonEmpty(..), last ) import GHC.Exts import GHC.Stack (HasCallStack) @@ -750,7 +750,7 @@ last2 = List.foldl' (\(_,x2) x -> (x2,x)) (partialError,partialError) lastMaybe :: [a] -> Maybe a lastMaybe [] = Nothing -lastMaybe xs = Just $ last xs +lastMaybe (x:xs) = Just $ last (x:|xs) -- | @onJust x m f@ applies f to the value inside the Just or returns the default. onJust :: b -> Maybe a -> (a->b) -> b @@ -1293,9 +1293,9 @@ withAtomicRename targetFile f = do -- string is returned in the first component (and the second one is just -- empty). splitLongestPrefix :: String -> (Char -> Bool) -> (String,String) -splitLongestPrefix str pred - | null r_pre = (str, []) - | otherwise = (reverse (tail r_pre), reverse r_suf) +splitLongestPrefix str pred = case r_pre of + [] -> (str, []) + _:r_pre' -> (reverse r_pre', reverse r_suf) -- 'tail' drops the char satisfying 'pred' where (r_suf, r_pre) = break pred (reverse str) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4baf7b1ceaef2d4f49e81e5786a855e22ed864bf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4baf7b1ceaef2d4f49e81e5786a855e22ed864bf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: